options = get_option('mxchat_options'); $this->chat_count = get_option('mxchat_chat_count', 0); $this->is_activated = $this->is_license_active(); // Initialize default options if they are not set if (!$this->options) { $this->initialize_default_options(); } // Add admin menu and initialize settings add_action('admin_menu', array($this, 'mxchat_add_plugin_page')); add_action('admin_init', array($this, 'mxchat_page_init')); add_action('admin_init', array($this, 'mxchat_prompts_page_init')); // Add this line add_action('admin_enqueue_scripts', array($this, 'mxchat_enqueue_admin_assets')); add_action('wp_ajax_mxchat_delete_chat_history', array($this, 'mxchat_delete_chat_history')); add_action('admin_post_mxchat_submit_content', array($this, 'mxchat_handle_content_submission')); add_action('admin_post_mxchat_delete_prompt', array($this, 'mxchat_handle_delete_prompt')); add_action('wp_ajax_mxchat_fetch_chat_history', array($this, 'mxchat_fetch_chat_history')); add_action('wp_ajax_nopriv_mxchat_fetch_chat_history', array($this, 'mxchat_fetch_chat_history')); add_action('admin_post_mxchat_submit_sitemap', array($this, 'mxchat_handle_sitemap_submission')); add_action('wp_footer', array($this, 'mxchat_append_chatbot_to_body')); add_action('admin_head-mxchat-prompts', array($this, 'mxchat_enqueue_admin_assets')); add_action('admin_head-toplevel_page_mxchat-max', array($this, 'mxchat_enqueue_admin_assets')); add_action('wp_ajax_mxchat_activate_license', array($this, 'mxchat_handle_activate_license')); add_action('admin_notices', array($this, 'mxchat_display_admin_notice')); // Add the AJAX handler for logged-in users add_action('wp_ajax_mxchat_save_inline_prompt', array($this, 'mxchat_save_inline_prompt')); add_action('admin_post_mxchat_delete_all_prompts', array($this, 'mxchat_handle_delete_all_prompts')); // Define admin_post actions for form submission handling add_action('admin_post_mxchat_add_intent', array($this, 'mxchat_handle_add_intent')); add_action('admin_post_mxchat_delete_intent', array($this, 'mxchat_handle_delete_intent')); add_action('admin_post_mxchat_update_intent_threshold', array($this, 'mxchat_handle_update_intent_threshold')); add_action('admin_post_mxchat_stop_processing', array($this, 'mxchat_stop_processing')); add_action('admin_post_mxchat_edit_intent', array($this, 'handle_edit_intent')); add_action('save_post', array($this, 'handle_post_update'), 10, 3); add_action('post_updated', array($this, 'handle_post_update'), 10, 3); add_action('wp_ajax_mxchat_save_setting', array($this, 'mxchat_save_setting_callback')); } // Method to check if the license is active private function is_license_active() { $license_status = get_option('mxchat_license_status', 'inactive'); return $license_status === 'active'; } // Initialize default options private function initialize_default_options() { $default_options = array( 'api_key' => '', 'xai_api_key' => '', 'claude_api_key' => '', 'system_prompt_instructions' => '[EXAMPLE INSTRUCTIONS] You are an AI Chatbot assistant for this website. The primary subject you should focus on is [insert proper subject here]. Your main goal is to assist visitors with questions related to this specific topic. Here are some key things to keep in mind: - Your name is [Chatbot Name]. - Stay focused on topics related to [insert proper subject here]. If a visitor asks about an unrelated topic, politely redirect the conversation to how you can assist them with this subject. - Do not make up links to pages. Only use specific links you see in your knowledgebase. - Keep your responses short, concise, and to the point. Provide clear and direct answers suitable for a chatbot interaction. - Provide answers based on the knowledge available to you. If you do not have an answer to a specific question, let the visitor know that you don’t have the information.', 'model' => 'gpt-4o', 'rate_limit_logged_in' => '100', 'rate_limit_logged_out' => '100', 'rate_limit_message' => 'Rate limit exceeded. Please try again later.', 'enable_email_block' => '', 'email_blocker_header_content' => "
Let's get started. Enter your email to begin chatting with us.
", 'email_blocker_button_text' => 'Start Chat', 'top_bar_title' => 'MxChat', 'intro_message' => 'Hello! How can I assist you today?', 'input_copy' => 'How can I assist?', 'append_to_body' => 'off', 'close_button_color' => '#fff', 'chatbot_bg_color' => '#fff', 'user_message_bg_color' => '#fff', 'user_message_font_color' => '#212121', 'bot_message_bg_color' => '#212121', 'bot_message_font_color' => '#fff', 'top_bar_bg_color' => '#212121', 'send_button_font_color' => '#212121', 'chat_input_font_color' => '#212121', 'chatbot_background_color' => '#212121', 'icon_color' => '#fff', 'enable_woocommerce_integration' => '0', 'link_target_toggle' => 'off', 'pre_chat_message' => 'Hey there! Ask me anything!', // New fields for Loops Integration 'loops_api_key' => '', 'loops_mailing_list' => '', 'triggered_phrase_response' => 'Would you like to join our mailing list? Please provide your email below.', 'email_capture_response' => 'Thank you for providing your email! You\'ve been added to our list.', 'popular_question_1' => '', 'popular_question_2' => '', 'popular_question_3' => '', 'pdf_intent_trigger_text' => "Please provide the URL to the PDF you'd like to discuss.", 'pdf_intent_success_text' => "I've processed the PDF. What questions do you have about it?", 'pdf_intent_error_text' => "Sorry, I couldn't process the PDF. Please ensure it's a valid file.", 'pdf_max_pages' => 69, // Live Agent Integration 'live_agent_webhook_url' => '', 'live_agent_secret_key' => '', 'live_agent_bot_token' => '', 'live_agent_message_bg_color' => '#ffffff', 'live_agent_message_font_color' => '#333333', 'chat_toolbar_toggle' => 'off', 'mode_indicator_bg_color' => '#767676', 'mode_indicator_font_color' => '#ffffff', 'toolbar_icon_color' => '#212121', ); // Merge existing options with defaults $existing_options = get_option('mxchat_options', array()); $merged_options = wp_parse_args($existing_options, $default_options); // Update the options if they have changed if ($existing_options !== $merged_options) { update_option('mxchat_options', $merged_options); } // Update the $this->options property $this->options = $merged_options; } public function mxchat_add_plugin_page() { // Main menu page add_menu_page( 'MxChat Settings', 'MxChat', 'manage_options', 'mxchat-max', array($this, 'mxchat_create_admin_page'), 'dashicons-testimonial', 6 ); // Submenu page for Knowledge add_submenu_page( 'mxchat-max', 'Prompts', 'Knowledge', 'manage_options', 'mxchat-prompts', array($this, 'mxchat_create_prompts_page') ); // Submenu page for Chat Transcripts add_submenu_page( 'mxchat-max', // Corrected parent slug to match the main menu 'Chat Transcripts', 'Transcripts', 'manage_options', 'mxchat-transcripts', array($this, 'mxchat_create_transcripts_page') // Prefixed function name with mxchat_ ); // Submenu page for Intents add_submenu_page( 'mxchat-max', // Parent slug 'MxChat Intents', // Page title 'Intents', // Menu title 'manage_options', // Capability 'mxchat-intents', // Menu slug array($this, 'mxchat_intents_page_html') // Callback function ); // Submenu page for Activation Key add_submenu_page( 'mxchat-max', 'Pro Upgrade', 'Pro Upgrade', 'manage_options', 'mxchat-activation', array($this, 'mxchat_create_activation_page') ); } public function mxchat_save_setting_callback() { check_ajax_referer('mxchat_save_setting_nonce'); if (!current_user_can('manage_options')) { wp_send_json_error(['message' => 'Unauthorized']); } $name = isset($_POST['name']) ? $_POST['name'] : ''; // Strip slashes from the value before saving $value = isset($_POST['value']) ? stripslashes($_POST['value']) : ''; if (empty($name)) { wp_send_json_error(['message' => 'Invalid field name']); } // Load the full options array $options = get_option('mxchat_options', []); // Handle special cases switch ($name) { case 'additional_popular_questions': $questions = json_decode($value, true); // No need for stripslashes here if (is_array($questions)) { $options[$name] = $questions; // Also update old option for backwards compatibility update_option('additional_popular_questions', $questions); } break; case 'close_button_color': case 'user_message_bg_color': case 'user_message_font_color': case 'bot_message_bg_color': case 'bot_message_font_color': case 'top_bar_bg_color': case 'send_button_font_color': case 'chatbot_background_color': case 'icon_color': case 'chat_input_font_color': case 'live_agent_message_bg_color': case 'live_agent_message_font_color': case 'mode_indicator_bg_color': case 'mode_indicator_font_color': case 'toolbar_icon_color': // Store color values directly $options[$name] = $value; break; case 'live_agent_status': // Set the new value $options[$name] = ($value === 'on') ? 'on' : 'off'; break; case 'enable_woocommerce_integration': // Handle values that used to be 1/0 $options[$name] = ($value === 'on' || $value === '1') ? 'on' : 'off'; break; default: // Handle toggles if (strpos($name, 'toggle') !== false || in_array($name, [ 'chat_persistence_toggle', 'privacy_toggle', 'complianz_toggle', 'chat_toolbar_toggle' // Removed live_agent_status from here ])) { $options[$name] = ($value === 'on') ? 'on' : 'off'; } else { // Store all other values directly $options[$name] = $value; } break; } // Save all updates $updated = update_option('mxchat_options', $options); // Handle backwards compatibility for certain fields $legacy_fields = ['brave_api_key', 'brave_image_count', 'brave_safe_search', 'brave_news_count', 'brave_country', 'brave_language', 'similarity_threshold']; if (in_array($name, $legacy_fields)) { // Also update the individual option for backwards compatibility update_option($name, $value); } if ($updated) { wp_send_json_success(['message' => 'Setting saved']); } else { wp_send_json_error(['message' => 'Update failed or no changes']); } } public function mxchat_display_admin_notice() { // Success notice if ($message = get_transient('mxchat_admin_notice_success')) { ?>If you’re having trouble with setup or getting the responses you need, we encourage you to review our documentation or create a support ticket.
If you like our plugin, please consider leaving us a review.
The Claude API, provided by Anthropic, allows for intelligent, context-aware chatbot responses in MxChat. To use it, you will need both an OpenAI API key and a Claude API key. This is necessary because the system utilizes OpenAI for vector embedding in the Retrieval-Augmented Generation (RAG) process, as Claude does not currently offer an embedding API.
When using the Claude API, your custom content is sent to Claude for generating responses, while the embeddings are processed through OpenAI. This ensures your chatbot provides accurate and engaging responses while maintaining knowledge relevant to your website.
You can obtain your Claude API key by signing up on the Anthropic API page.
The X.AI API, released on 10.21.24, is currently in beta. To use it, you will need both an OpenAI API key and an X.AI API key. This is because OpenAI handles vector embeddings in the Retrieval-Augmented Generation (RAG) process, as X.AI does not yet provide an embedding API.
Custom content is sent to the X.AI API for generating responses, while OpenAI processes the embeddings. This allows the chatbot to provide advanced responses while maintaining context from your website. You can get your X.AI API key from the X.AI API documentation.
Yes, you will need an OpenAI API key to power the chatbot. You can obtain an API key by signing up on the OpenAI platform. After signing up, you must add credits to your account—typically, $5 in credits is sufficient to get started.
Once you have your API key, simply enter it in the chatbot's settings to enable functionality. The chatbot relies on OpenAI’s models for generating responses, so having sufficient credits in your OpenAI account is essential for smooth operation.
You can add the chatbot using the shortcode [mxchat_chatbot floating="yes"] or [mxchat_chatbot floating="no"]. For initial testing and styling, it's best to use the shortcode on a draft or non-public page. Once you’re ready to go live, enable the “Append Chat Widget to Body” option in the settings for site-wide integration (recommended) or add shortcode to the footer.
The chatbot uses AI and vector embeddings to connect users with relevant information. When you submit content, it converts it into a mathematical format. When a user asks a question, the bot matches it to your stored content and generates a response based on relevance. For example, submitting "Our phone number is 910-123-4567" allows the bot to retrieve this information when asked about contact details. To ensure related information is provided together, submit it in one entry.
Occasionally, the chatbot may generate inaccurate links or information, known as "hallucinations." To minimize this, you can add system instructions to guide its behavior. For example, include an instruction like: "Only provide links you directly have access to or retrieve from the knowledge base. Do not make up links or information that you do not have direct access to." This helps the bot stay aligned with your content.
Intents allow MxChat to recognize user requests and trigger specific actions, such as capturing emails or displaying product information. This helps provide a more interactive and responsive experience. For a detailed explanation of each intent, please refer to our Intents Documentation.
The Pro version offers direct integration with the Complianz GDPR plugin, making it easy to stay compliant with GDPR. If Complianz is enabled on your website, users must accept consent before the chatbot widget appears. The chatbot will only display once the user has accepted, ensuring compliance with data privacy regulations.
With WooCommerce integration, the chatbot automatically embeds new products and updates existing ones. For already-published products, you can click update or submit the product sitemap. The “Order History Access” setting allows the bot to access users' order history (requires login) and assist with order inquiries. To enable the “Add to Cart” feature, add this system instruction: “After discussing a product, ask if the user wants to add it to their cart. The user must say 'Add to cart' exactly.” Currently, this feature supports English only, with more languages coming soon.
AI chatbots can sometimes behave in unexpected ways, especially if you're new to configuring AI for specific tasks. We're committed to helping you get the most out of your chatbot experience. While we’re working on comprehensive guides and video tutorials, our team is here to assist you directly. If your chatbot isn't delivering the responses you need, please don’t hesitate to contact us for personalized support.
We’re dedicated to your success and ready to guide you in aligning the AI's behavior to meet your goals.
Loops is a powerful SaaS email service that helps you automate and enhance your email marketing campaigns, making it easy to reach and engage with your audience. To integrate Loops with MxChat, you’ll need an API key from Loops. You can obtain this key by logging into your Loops account and navigating to the API settings. Visit the Loops website to get started or to sign up for an account.
' . esc_html__('All knowledge has been deleted successfully.', 'mxchat') . '
Import content from various sources:
| ID | Article Content | URL | Actions |
|---|---|---|---|
| id); ?> | article_content))); ?> | source_url)) : ?> source_url); ?> N/A | Delete |