# Best Practices (/en/docs/best-practices) ## Overview [#overview] The quality of MuChat's answers comes down to four things you control: the instructions you give it, the data sources you train it on, the model you pick, and how you correct it once it's live. This page covers each in turn. Work through these in order. Instructions and data sources account for most quality problems, so fix those before reaching for a different model. ## Refine MuChat's instructions [#refine-muchats-instructions] The instructions shape MuChat's behavior and responses. Use them to set a persona, define tone, or specify the types of questions it can answer. Clear, precise instructions keep MuChat aligned with your goals and your user experience. Open **Laboratory** from the agent menu and edit **Instructions (Prompt)**. You can start with a prompt like this: ```text You are the support assistant for [business name]. Reply clearly and warmly in the user's language. Use the knowledge base for product information, services, and policies. If a question is unclear, ask a clarifying question. If information is missing, say so and do not guess. ``` To keep MuChat focused on your business information, say so explicitly. For example: *"Only answer using information from the knowledge base. Do not guess missing information."* Feel free to use the example below after customizing it to suit your business: ```text ### Role You are the support assistant for [business name], which provides [business area]. Answer questions about this business's products, services, and policies. ### Tone and personality Be friendly, respectful, and clear. Reply in the user's language and keep the answer relevant to their question. ### Boundaries 1. Use only the knowledge base for prices, product features, delivery times, and policies. 2. If the sources do not contain an answer, acknowledge missing information and do not invent one. 3. If the question is unclear, ask a clarifying question before answering. 4. If the topic is outside the business's scope, politely guide the conversation back to relevant topics. ``` Test your changes in the conversation. When you're happy with the results, select **Save to agent** and confirm to save the settings to MuChat. For a walkthrough of this section, see [testing and response settings](/en/build-your-first-ai-agent#fine-tune-settings). ## Improve readability of data sources [#improve-readability-of-data-sources] The quality of MuChat's answers depends heavily on the data sources you provide. MuChat needs clear, readable text to answer detailed questions about your business, so check the content of web pages and files before adding them. Some websites aren't scraper-friendly. If MuChat struggles to answer questions based on your website, review the source content. When needed, add the information using **Text**, or upload a readable file in a supported format such as TXT, Markdown, or DOCX. File content needs to contain extractable text for training. If important information appears only in an image or scan, add that information to the knowledge base as text too. Product: Widget123, colors not specified, possibly red or blue. Discount details unclear. Weight: Approx. 1 kg or 1.5 kg? Shipping: Delivery time uncertain, could be fast or delayed. Availability: Global shipping not confirmed. Packaging: Uncertain if it comes in a box. Assembly: Information unclear. Limited stock? Not confirmed. Product: Widget123\ Colors: Red, Blue\ Discount: 50% off\ Weight: 1.5 kg\ Shipping: Estimated delivery within 1-2 weeks (depends on location)\ Availability: Ships worldwide\ Packaging: Comes in a standard-sized box\ Assembly: Some assembly required\ Order Now: Limited stock available, don't miss out! The product is a thing. Its color is unspecified, and its size is unknown. The product might be useful, but it's not clear. Its availability is uncertain, and shipping times are not mentioned. There might be a discount, but it's not specified. Assembly instructions? Unclear. Get it soon? It's unclear when stock might run out. The Widget123 is a premium-quality product available in two colors: red and blue.\ It offers a 50% discount, making it an excellent deal.\ The product weighs 1.5 kg and is shipped worldwide.\ You can expect delivery within 1-2 weeks, depending on your location.\ The item comes in a standard-sized box and requires minimal assembly.\ Act fast, stock is limited! ## Add suggestable images [#add-suggestable-images] To display an image in MuChat's response, ask it to send a direct image link in Markdown format. The image address must be public and open in a browser without signing in. You can add an instruction like the following to show an image relevant to the user's request. Replace the example URL with your actual image address: ```text When the user asks for a product image or illustrated guide, use a valid link from the sources and display the image in this format: ![Image description](https://example.com/product.jpg) ``` After adding the instruction and image link, check the result in the Laboratory: ## Choose the right AI model [#choose-the-right-ai-model] Selecting the right model affects answer quality and speed. Match it to your use case: answering frequent questions, explaining a complex topic, and following detailed instructions place different demands on a model. In **Laboratory**, use **Model** to choose from the models available to your account. Consider answer quality, speed, and credit usage together, then revisit the choice as your business needs grow. ### Compare models with the same questions [#compare-models-with-the-same-questions] Test a few real customer questions with one model. Then change the model, select **Reset test**, and ask the same questions again. Compare: - Response quality and accuracy - Response time and speed - Tone and personality - Handling questions that aren't covered by your sources Keep the sources, instructions, and temperature unchanged while comparing models. Once you choose a model, select **Save to agent** and confirm. ## Correct answers with Improve response and Q&A [#correct-answers-with-improve-response-and-qa] Two methods let you add correct information to the knowledge base so MuChat can use it in future answers. To **add Q&A**, open **Datastores**, select a knowledge base, and choose **Create Datasource → Q&A**. Enter the question and its accurate answer, then select **Add**. This becomes a source MuChat can use when answering related questions. To **improve a response**, open **Inbox** from the agent menu and select a conversation. Choose **Improve response** below MuChat's answer. Review the question, write the complete corrected answer, and select **Save**. Watch the Improve response video {/* */} The correction is saved to the knowledge base as a Q&A source, and the original chat message stays unchanged. After source processing finishes, test the same question and a few variations in the Laboratory. The **Improve response** option depends on your plan's features and your permissions to manage the inbox and knowledge base. ## Next steps [#next-steps] Define MuChat's role, tone, and response boundaries clearly. Add, organize, and train on the content MuChat learns from. Compare available models using the same questions. Follow customer conversations and improve quality by correcting answers. # Build Your First AI Agent (/en/docs/build-your-first-ai-agent) ## Overview [#overview] In just a few minutes, you'll have a working MuChat answering questions about your business and engaging with your website visitors. Here's what we'll do: Create your agent and add a website, files, or other information to its knowledge base. Ask questions in the Laboratory and refine the tone and quality of its responses. Add the widget code to your site so visitors can start a conversation. **Estimated time:** About 5 minutes from setup to deployment. ## Before you start [#before-you-start] You'll need an active MuChat account to follow this guide. [**Sign up here**](https://app.mu.chat/auth/signin) if you haven't already. ## Step 1: Create and train your MuChat [#step-1-create-and-train-your-muchat] ### Navigate to your dashboard [#navigate-to-your-dashboard] Select **Create new agent** in your dashboard. Enter your website address and select **Continue** to retrieve initial business information, a logo, and brand colors from your site. If you don't have a site, select **I don't have any website.** and enter the information in the next step. MuChat creation screen with a website address field and an option to continue without a website ### Review the initial settings [#review-the-initial-settings] The following three screens appear in order. Review the suggested information and make any changes you need. Set the title, description, color, avatar, and widget icon in **Agent's UI**. Review the preview and select **Looks Good**. MuChat title, description, and color settings next to the widget preview Complete the tone, bot name, industry, target audience, and business details. Select **Save** to continue. Business information form with tone, bot name, industry, and target audience fields In **Write Your Prompt**, describe MuChat's role and how it should answer. For example: > You are our business's support assistant. Reply clearly and warmly. Use the knowledge base for products, shipping, and returns. If information is missing, say so and do not guess. Select **Publish**, then choose **Continue** in the welcome message to open your knowledge base. MuChat instructions editor and the Publish button to complete setup ### Choose your training data [#choose-your-training-data] MuChat needs information to learn from. Open **Datastores**, select a knowledge base, and choose **Create Datasource**. You can train it using various data sources: Knowledge base source list and the Create Datasource button **Upload your documents** Train MuChat on your documents. Select **File**, upload a document, and choose **Add**. Supported formats are DOCX, MD, TXT, CSV, and JSON. **Best for:** Business documents, manuals, FAQs, and product information. File source form with the upload area, supported formats, and Add button **Direct text input** Paste your content directly into MuChat. For information without a separate document or web page, select **Text**, enter a name and content, then select **Train text**. **Best for:** Support hours, service descriptions, and custom training content. Text source form with a Support hours title and content entered in the editor **Crawl your website** MuChat discovers your website's pages so you can choose the content to use for training. **Best for:** Websites, help centers, product pages, or sitemaps. Choose **website**, **webpage**, or **sitemap** and enter the address. Select **next** to review the discovered pages and choose what to include. Continue to **Review**, then select **Sync website**. Website sync form with link type options, the website address, and next button **Add your own Q&A** Add frequently asked questions with the answers you want MuChat to use. In **Add Manually**, enter the question and answer, then select **Add**. **Best for:** Returns policies, shipping information, and specific customer questions. To import multiple questions and answers, use **Upload File**. Your CSV must contain `question` and `answer` columns. Q&A form with a shipping question and answer, plus the Upload File tab **Connect your WordPress content** Add WooCommerce products, pages, or posts to the knowledge base. Enter your site address, select **Next**, and choose the content type. Finish with **Sync WordPress**. **Best for:** WooCommerce stores and WordPress websites. The MuChat plugin must be installed and active on your WordPress site. For products, you can choose only in-stock items or all products. WordPress connection form with the site address and Connect, Content, Stock, and Review steps **Add information from your own service** Use your system's API as a training source. Enter the endpoint and authentication method, then select **Check Links** to validate the connection and add the source. **Best for:** Custom systems and product catalogs, with help from your technical team. API source form with an endpoint address and authentication options for none, API key, and bearer token Processing starts after you add each source. Once its status is **Synced**, MuChat is ready to test with that source. Processing time depends on the type and amount of information. **Storage limit:** Knowledge base capacity varies by plan. If you reach the limit, check your usage and plan capacity in the dashboard. ## Step 2: Test and optimize MuChat [#step-2-test-and-optimize-muchat] ### Open the Laboratory [#open-the-laboratory] Once your sources are ready, open **Laboratory** from the agent menu. Ask questions similar to your customers' questions and compare the answers with your business information. You can change the model, instructions, and temperature here to test the results. The MuChat Laboratory with model and instruction settings alongside a test conversation ### Fine-tune settings [#fine-tune-settings] **Test responses with different models** Choose an available model. Ask the same questions with different models and compare: - **Response quality and accuracy** - **Response time and speed** - **Tone and personality** - **Handling questions that aren't covered by your sources** Based on the comparison, select the model that best fits your use case and brand voice. Change one setting at a time and ask the same questions again. Use **Reset test** to start a fresh test conversation. Define how MuChat should behave and respond to users. These instructions shape its personality, tone, and approach to conversations. **How to write effective instructions:** - Define MuChat's tone: professional, friendly, casual, or another style. - Define its role: lead collection, support, sales, or another purpose. - Set clear boundaries about what topics to discuss or avoid. - Define your brand voice and personality. - Add specific words you want MuChat to use. - Define the languages it should respond in, such as the user's language. - Add any other instructions you want MuChat to follow. Specify what MuChat should do when the sources don't contain an answer. For example, ask it to acknowledge missing information and avoid guessing. Controls how varied the responses are: - **Low (0.1–0.3):** More consistent, less varied responses - **Medium (0.4–0.7):** Balanced variation in wording - **High (0.8–1.0):** More creative, varied responses A lower value does not guarantee factual accuracy. Check answers against your sources. When you're happy with the results, select **Save to agent** and confirm. This saves the settings you've tested in the Laboratory to MuChat. ## Step 3: Deploy to your website [#step-3-deploy-to-your-website] ### Open the deployment section [#open-the-deployment-section] Once you're satisfied with MuChat's responses, it's time to make it live. Open **Deploy** and select **Manage** on the **Chat Widget** card. **Channel status:** The widget channel must be active to respond to your website visitors. Check its status before installation. ### Choose your deployment method [#choose-your-deployment-method] You can display MuChat as a floating chat bubble or in a fixed section of your page. Select **Deploy** above the preview and choose **Website widget** or **Website iframe**. MuChat deployment menu with Website widget and Website iframe options Copy the installation code from the panel. The **HTML**, **React.js**, and **Next.js** tabs provide the example for each setup. Widget installation panel with HTML, React.js, and Next.js tabs and the copy button **Perfect for most websites** Adds a floating chat icon that visitors can click to start a conversation. The chat window opens when needed and doesn't occupy a fixed section of your page. **Pros:** - Keeps your site's main layout unchanged - Users can open and close the chat window as needed - Works well on mobile devices - A familiar chat experience for visitors **Best for:** Business websites, blogs, and e-commerce stores. **For dedicated chat sections** Embeds the full chat interface directly into your page layout. It stays visible in the space you choose, ready for interaction. **Pros:** - Always visible on the page - More prominent than the chat bubble - Good for dedicated support pages - Dimensions can be adjusted to fit your page **Best for:** Support pages, help centers, and dedicated chat sections. ### Add code to your website [#add-code-to-your-website] Find where you can add JavaScript to your website. In site builders and content management systems, look for a custom code or scripts section. For HTML installation, place the snippet before the closing `` tag. For React or Next.js, use the example from the matching tab in the deployment panel. Copy your MuChat's installation code and paste it into the section you selected. Save your changes and publish your website updates. ### Verify installation [#verify-installation] Visit your website and look for the chat bubble. Open it, ask a question covered by your knowledge base, and check the answer. Test the display and responses on a mobile device too. **Success!** Your MuChat is now ready to help your website visitors. ### Customize appearance (optional) [#customize-appearance-optional] Want to match your brand? Return to **Deploy → Chat Widget → Manage**, update the settings, and select **Save**. - Upload a custom chat bubble icon and avatar - Change colors to match your brand - Customize the welcome message - Set default questions visitors can click to start a conversation - Show the welcome message after a delay - Configure the welcome message on mobile - Collect user feedback - Show answer sources and allow visitors to start a new conversation ## Next steps [#next-steps] You've created, trained, tested, and deployed your first MuChat. From here: Improve MuChat's answers with clear instructions, up-to-date sources, and the right model. Add human operator requests, customer information collection, and API calls to conversations. Connect MuChat to messaging channels and your business tools. Review conversations and customer feedback to improve MuChat's performance. # Welcome to MuChat (/en/docs) ## Overview [#overview] MuChat is an AI assistant for answering your customers' questions. Add your website content, files, text, and business Q&A to its knowledge base so it can use that information in its answers. You can adjust MuChat's tone and instructions to suit your business. Actions also let you collect customer information or request a human operator during a conversation. ## Why choose MuChat? [#why-choose-muchat] Add website content, files, and Q&A to the knowledge base so MuChat can refer to them when answering questions. Add the chat widget to your website or share a link to MuChat's standalone chat page with your customers. Handle tasks during conversations, from tracking WooCommerce orders to calling your business APIs. Review conversation history, question topics, and customer feedback to find areas for improvement. Use conversation forms to collect names, phone numbers, or other details and review them in the dashboard. Connect MuChat to channels such as Telegram, WhatsApp, Instagram, and Bale, and manage conversations in the inbox. Access to some channels and features depends on your plan. ## Next steps [#next-steps] Follow the next guide to create your first MuChat, add sources, test its answers, and publish it on your website. Refine instructions and knowledge base content to make MuChat's answers more accurate and useful. Let MuChat collect customer information, request a human operator, and call your APIs. Explore ways to connect MuChat to your website and the messaging channels your customers use. Review conversations and customer feedback, and measure MuChat's performance. # Response settings (/en/docs/user-guides/chatbot/build) ## Overview [#overview] Response settings define how your agent behaves and answers: its instructions, AI model, and temperature. This page explains each setting, the available models, and the controls for editing, comparing, and saving changes. You can find these settings in **Laboratory**. Related features are covered separately: | Section | What it covers | | --- | --- | | **Instructions, model, and temperature** | Configuring response behavior; covered on this page | | [Knowledge base](/en/build-your-first-ai-agent#choose-your-training-data) | The information and sources MuChat uses to answer questions | | [Actions](/en/user-guides/chatbot/playground#ai-actions) | Tasks MuChat performs beyond answering questions | | [Laboratory](/en/user-guides/chatbot/playground) | Test conversations, the preview, and reviewing changes | Keep product information, services, and business policies in your **knowledge base**. Use instructions to tell MuChat how to use that information and how to respond. ## Instructions [#instructions] Instructions shape MuChat's behavior, role, and response guidelines. To edit them, open your agent, go to **Laboratory**, and find **Instructions (Prompt)**. ### General instructions [#general-instructions] Make these points clear in the prompt: - Your business or product context - MuChat's role and responsibilities - Response language, style, and tone - Answer format, such as brief replies or lists - What to do when a question is unclear or information is missing For longer text, use the editor's expand icon. When you're done, select **Finish editing** to return to the settings. Select **Select Template**, choose a template, and review its text in the dialog. **Use Template** replaces the current prompt with the selected template. Then adapt the business name, MuChat's role, contact details, and response rules. Copy any parts of your current prompt you want to keep before replacing it. ### Response rules and boundaries [#response-rules-and-boundaries] Write behavioral rules in the same prompt. For example, specify that MuChat should: - Answer questions within your business's scope - Use source information for prices, policies, and specifications - Avoid guessing when an answer is missing - Ask for clarification when a question is unclear - Politely guide unrelated conversations back to your business's scope Start with a simple, clear description of MuChat's purpose, then add specific rules based on real user questions. For a full example you can copy, see [Best Practices](/en/best-practices#refine-the-ai-agents-instructions). ### AI Model [#ai-model] The AI model processes the user's question and the available information to generate MuChat's response. Models differ in instruction following, handling complex requests, speed, and credit usage. Your choice affects both the conversation experience and your account's credit consumption. Open **Model** and select the model you want to use. You can search by name. On desktop, hover over an option to view its description and credit usage. MuChat's available models, grouped by family: MuChat's optimized, economical model for everyday questions and customer support. It appears as **auto** in the model selector. - **auto**: 1 credit per message - **GPT-6 Luna**: 1 credit per message; for common questions, text summaries, and recurring requests. - **GPT-6 Sol**: 20 credits per message; for complex questions, technical topics, and requests that need analysis across multiple steps. - **Claude Sonnet 5**: 20 credits per message; for writing and editing, reviewing information, and shaping tone and response structure. - **Gemini 3.8 Flash**: 5 credits per message; for answering questions, summarizing information, and organizing scattered content. - **Gemini 3.5 Flash Lite**: 3 credits per message; for everyday conversations, short answers, and rewriting text. - **DeepSeek Flash**: 3 credits per message; for everyday questions, summaries, and recurring conversations. - **Grok 4.6**: 15 credits per message; for brainstorming, exploring open questions, and developing content through conversation. Model access depends on your plan's features. When choosing, also check the current model list and credit usage shown in your dashboard. The number beside a model shows its credit usage per message. On desktop, it appears as a multiplier such as **1x**; hover over the model to see the credit amount in its details card. On mobile, the credit amount is written next to the model name. Models unavailable to your account show a lock icon and cannot be selected. Choose an available model to continue; access to other models depends on your plan's features. If you use actions, check any warnings for your selected model. If you see "Selected model doesn't support AI Actions", choose a compatible model. To enable existing actions, see [AI actions in the Laboratory](/en/user-guides/chatbot/playground#ai-actions). To evaluate models using the same questions, see [choosing and comparing models](/en/best-practices#choose-the-right-ai-model). ### Temperature [#temperature] Temperature controls creativity and variation in generated responses. It affects wording and how predictable the response will be: - **Lower, close to 0:** the model favors more likely outputs, producing focused, consistent wording. Start low for support and frequently asked questions. - **Higher, close to 1:** wording becomes more varied and creative, making the exact response less predictable. Try a higher value for uses that benefit from varied writing. Drag the slider between **Reserved** and **Creative**. The range is **0 to 1**, in **0.1** increments. The number beside the label shows the current value; the information icon opens an explanation of the setting. **The default temperature is 0.** After changing it, retry the same questions to see how the response style changes. A low value does not guarantee factual accuracy; accurate answers also need clear, current sources and well-written instructions. ## Compare and apply settings [#compare-and-apply-settings] To find a suitable configuration, try a set of real questions with different prompts, models, or temperatures. In MuChat, you compare them in sequence within the Laboratory: test one configuration, keep the results, then try the next with the same questions. Settings and the conversation preview sit together so you can review the result while editing. Each control has a specific purpose: ### Agent controls [#agent-controls] Each agent has its own response settings. In the selected agent's Laboratory, these controls are available: | Control | What it does | | --- | --- | | **Training status** | Shows source readiness, the last training time, and information volume. Use **Datastores** to add or correct content. | | **Model** | Selects the model generating responses. Its description and credit usage are available in the model list. | | **Temperature** | Changes response variation between 0 and 1. | | **AI actions** | Enables or disables existing actions. Create and edit them from **Actions** in the agent menu. | | **Instructions (Prompt)** | Edits the text defining the agent's role, tone, and response rules. | | **Select Template** | Opens templates to review and replace the prompt text. | | **Editor expand icon** | Opens a larger editor for longer prompts. | | **Finish editing** | Closes the expanded editor and returns to settings. Use the final save to apply changes to your main agent. | | **Save to agent** | After confirmation, saves the current model, temperature, prompt, and enabled actions to your main agent. | ### Test and preview controls [#test-and-preview-controls] Use these controls to review the result of your settings: | Control | What it does | | --- | --- | | **Reset test** | Starts a fresh test conversation with the **current Laboratory settings**. It does not restore the previous model, temperature, or prompt. | | **Laboratory and Preview tabs** | Switch between settings and the test conversation on smaller screens. | | **Preview resize handle** | Changes the conversation's display width on desktop so you can check message layout at different sizes. | To compare results: 1. Set the model, temperature, prompt, and enabled actions, then ask a few real questions. 2. Change **one setting at a time**. For example, change the model while keeping sources, temperature, and instructions unchanged. 3. Select **Reset test** and ask the same questions in the same order to keep the conversation context comparable. 4. Evaluate accuracy, completeness, tone, rule following, speed, and credit usage, then keep the configuration that fits your needs. Editing settings prepares them for testing. In an ongoing conversation, the new model, temperature, and prompt apply from the **next message**; earlier responses are not generated again. When you're happy with the result, select **Save to agent**, then **Save** in the confirmation dialog. This applies the current **model, temperature, prompt, and enabled actions** to your main agent. Review all of them before confirming. Alongside regular questions, try an unclear question and one outside your sources to check how MuChat follows your tone and rules in more difficult situations. For starting conversations, initial forms, and action behavior during testing, see the [Laboratory guide](/en/user-guides/chatbot/playground#chat-as-user). ## Troubleshooting [#troubleshooting] Check that you selected **Save to agent** after testing and confirmed the save. Editing text or closing the editor alone does not change your main agent's settings. Models with a lock icon are unavailable to your account. Try a selectable model and review your plan's features if needed. Temperature changes how varied the wording is. Review the source content and training status, and check that your prompt asks MuChat to answer using sources. For a step-by-step review, see [Best Practices](/en/best-practices#improve-readability-of-data-sources). ## Next steps [#next-steps] Add and organize the information MuChat needs to answer questions. Evaluate available models using real questions from your business. Prepare instructions and sources for better answers. Check your settings in test conversations and the preview. # Playground (/en/docs/user-guides/chatbot/playground) ## Overview [#overview] The **Playground** lets you preview and interact with MuChat from your users' perspective, and adjust its model, instructions, and actions while you check the result. Select your agent and open **Laboratory** from its sidebar. Response settings sit alongside the conversation preview, so you can test changes without switching pages. Changes to the **model, temperature, instructions, or active actions** are prepared for testing automatically. **You can test them without selecting Save to agent.** **Save to agent** applies the settings you have tested to your **live agent**. See MuChat the way a visitor will, change its behavior and responses in place, and test the result before anything goes live. Use the Playground to: - Preview MuChat's behavior in real time - Test conversations and responses - Change the **model**, **temperature**, **instructions**, and **active actions**, and check how those changes affect the responses The widget's appearance, initial messages, and suggested questions come from its widget settings. To edit them, open **Deploy** from the agent menu and select **Manage** on the **Chat Widget** card. ## Tabs and settings [#tabs-and-settings] On larger screens, settings and the conversation appear side by side. On smaller screens, switch between the **Laboratory** and **Preview** tabs to move between settings and the conversation. The Playground includes these settings: | Section | What it controls | | --- | --- | | **Training status** | Shows the agent's training status, last training time, and total characters. Add or edit sources in **Datastores**. | | **Model** | Choose the response model from those available to your account. | | **Temperature** | Adjust response variety between 0 and 1. Lower values produce more consistent responses; higher values allow more varied wording. A lower value alone does not guarantee factual accuracy. | | **AI actions** | Enable or disable existing actions for testing. | | **Instructions (Prompt)** | Define MuChat's role, tone, language, and response boundaries. | Create or edit actions under **Actions** in the agent menu. Then return to the Laboratory and enable the action you want to test under **AI actions**. Enabling or disabling actions that MuChat chooses while answering takes effect on the next message. **Before the conversation starts**, enabling or disabling a startup form action shows or hides the form in the preview automatically. **After sending the first message or submitting a startup form**, select **Reset test** to see the form with its updated settings. Changes to actions triggered by events, such as reaching a specific message count, also require a fresh test. If a startup form is required, complete it first to make the message composer available. ### Instructions and saving changes [#instructions-and-saving-changes] Use **Instructions (Prompt)** to describe how MuChat should behave for your business. Start with **Select Template** and adapt the text, or use the expand icon to edit longer instructions in a larger space. After changing the settings, check the result in the same preview: | Test state | When changes apply | | --- | --- | | **Before the conversation starts** | The preview and startup forms update automatically. | | **During a conversation** | The updated model, temperature, and instructions are used for the **next message**. Earlier responses are not regenerated. | | **After Reset test** | The conversation starts again with the **current Laboratory settings**, including the updated startup forms and event-triggered actions. | After editing the settings, the **Settings synced** notification at the bottom means your changes are ready to test. If the conversation has started, you will see **Settings ready to test** with **Your changes will apply to the next message** instead. Once you are happy with the test results, select **Save to agent** and then **Save** in the confirmation dialog. Confirming replaces your live agent's settings with the **current model, temperature, instructions, and active actions**. ## Test conversations [#test-conversations] Write and send a question in the preview to see MuChat's response with the current settings. Use questions your customers actually ask to check the experience: - **Real questions:** ask about your products, services, or policies, and compare the answer with your knowledge base sources. - **Follow-up questions:** continue the conversation to check that MuChat follows the context, tone, and instructions. Once a conversation has started, select **Reset test** at the top of the conversation to start again with the **current Laboratory settings**. Use it to compare models and prompts from the same starting point, or to see changes to startup forms and event-triggered actions. ## Preview [#preview] The conversation preview appears within the Laboratory. On smaller screens, open the **Preview** tab to see and chat with MuChat. To check the display and conversation experience, try: - **Preview size:** on larger screens, drag the handle on the side of the preview to change its width and see how messages look at different sizes. - **Widget appearance and content:** check the initial messages, suggested questions, and colors. To change them, use [widget appearance settings](/en/build-your-first-ai-agent#customize-appearance-optional), then return to the Laboratory. ## Deploying [#deploying] After testing, open **Deploy** from the agent menu to choose your deployment method. For widget code, select **Manage** on the **Chat Widget** card, then open **Deploy** above its preview. | Option | What it does | | --- | --- | | **Website widget** | Adds a floating chat bubble to your website. | | **Website iframe** | Embeds the conversation as an inline section of your website. | | **WordPress** | Connects the widget to your WordPress site using the MuChat plugin. Manage this method from the **WordPress** card on the **Deploy** page. | Send MuChat a few questions a real visitor would ask, and confirm the answers and styling both hold up before you deploy. ## Limitations [#limitations] - **The Playground does not replace testing on your website or final channel.** After deploying, check mobile display, widget settings, and action execution where MuChat will actually be used. ## Next steps [#next-steps] Configure how MuChat is deployed and its display settings. Edit MuChat's instructions, model, and temperature. Give MuChat things to do beyond answering questions. Proven ways to improve the answers you're seeing in the preview. # API v2 Overview (/en/docs/api-reference) **Standard Plan required.** The MuChat API v2 is available starting from the Standard Plan. [View pricing →](https://app.mu.chat/pricing) Prefer the terminal? Use the [MuChat CLI](/en/cli) for the same API v2 surface from your shell or CI. Most conversation endpoints apply exclusively to conversations created programmatically via the MuChat API. Conversations generated through the bubble or external integrations cannot be accessed using these endpoints. The exceptions are [Export conversations](/en/api-reference/v2/conversations/export-conversations), which returns conversations from **all sources**, including a single conversation when you pass `conversationId`, and [Search conversations](/en/api-reference/v2/conversation-search), which searches conversations from all sources. ## What is the MuChat API v2? [#what-is-the-muchat-api-v2] The MuChat API v2 is a redesigned REST API that provides a clean, consistent interface for interacting with your AI agents. It features structured error codes, cursor-based pagination, streaming support via Server-Sent Events, and a predictable response format. **Base URL:** ``` https://api.mu.chat/api/v2 ``` ## Quick Start [#quick-start] 1. Go to the [MuChat Dashboard](https://app.mu.chat/dashboard) 2. Go to **Workspace settings** → **API keys** 3. Click **Create API Key** and copy the generated key Store your API key securely. Never expose it in client-side code. 1. Select your AI Agent in the dashboard 2. Go to the AI agent’s **Settings** → **General** 3. Copy the **Agent ID** from the **Agent details** card ```bash theme={null} curl -X POST 'https://api.mu.chat/api/v2/agents/YOUR_AGENT_ID/chat' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "message": "Hello! How can you help me?" }' ``` **Response:** ```json theme={null} { "data": { "id": "msg_abc123", "role": "assistant", "parts": [ { "type": "text", "text": "Hello! I'm here to help. What can I assist you with today?" } ], "metadata": { "userMessageId": "msg_xyz789", "conversationId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d", "userId": null, "finishReason": "stop", "usage": { "credits": 2 } } } } ``` ## Endpoints [#endpoints] **Base URL:** `https://api.mu.chat/api/v2` | Method | Endpoint | Notes | | -------- | --------------------------------------------------------------------------------------- | ---------------------- | | `GET` | `/api/v2/health` | | | `GET` | `/api/v2/agents` | | | `POST` | `/api/v2/agents` | | | `GET` | `/api/v2/agents/{agentId}` | | | `PUT` | `/api/v2/agents/{agentId}` | | | `DELETE` | `/api/v2/agents/{agentId}` | | | `PUT` | `/api/v2/agents/{agentId}/styles` | | | `PUT` | `/api/v2/agents/{agentId}/auto-retrain` | (auto-resync schedule) | | `POST` | `/api/v2/agents/{agentId}/clone` | | | `POST` | `/api/v2/agents/{agentId}/train` | (deprecated, no-op) | | `POST` | `/api/v2/agents/{agentId}/chat` | | | `POST` | `/api/v2/agents/{agentId}/conversations/{conversationId}/retry` | | | `GET` | `/api/v2/agents/{agentId}/conversations` | | | `GET` | `/api/v2/agents/{agentId}/conversations/export` | | | `GET` | `/api/v2/agents/{agentId}/conversations/search` | | | `GET` | `/api/v2/agents/{agentId}/conversations/{conversationId}` | | | `GET` | `/api/v2/agents/{agentId}/conversations/{conversationId}/messages` | | | `GET` | `/api/v2/agents/{agentId}/users/{userId}/conversations` | | | `POST` | `/api/v2/agents/{agentId}/conversations/{conversationId}/tool-result` | | | `PATCH` | `/api/v2/agents/{agentId}/conversations/{conversationId}/messages/{messageId}/feedback` | | | `GET` | `/api/v2/agents/{agentId}/sources/summary` | | | `GET` | `/api/v2/agents/{agentId}/sources` | | | `POST` | `/api/v2/agents/{agentId}/sources` | | | `GET` | `/api/v2/agents/{agentId}/sources/{sourceId}` | | | `PUT` | `/api/v2/agents/{agentId}/sources/{sourceId}` | | | `DELETE` | `/api/v2/agents/{agentId}/sources/{sourceId}` | | | `POST` | `/api/v2/agents/{agentId}/sources/{sourceId}/restore` | (deprecated, no-op) | **File upload base URL:** `https://api.mu.chat/api/v2` | Method | Endpoint | Notes | | ------ | --------------------------------------------- | ----- | | `POST` | `/api/v2/agents/{agentId}/sources` | | | `PUT` | `/api/v2/agents/{agentId}/sources/{sourceId}` | | ## Response Headers [#response-headers] Every response includes these headers: | Header | Description | | ----------------------- | ---------------------------------------------------------------- | | `x-request-id` | Unique request identifier. Include this when contacting support. | | `X-RateLimit-Limit` | Maximum requests allowed in the current window. | | `X-RateLimit-Remaining` | Requests remaining in the current window. | | `X-RateLimit-Reset` | Unix timestamp (seconds) when the rate limit window resets. | ## Next Steps [#next-steps] API keys, Bearer tokens, and rate limiting Real-time SSE streaming responses Structured error codes and troubleshooting Cursor-based pagination for list endpoints # REST API Integration (/en/docs/developer-guide/api-integration) **Standard Plan required.** The MuChat API v2 is available starting from the Standard Plan. [View pricing →](https://app.mu.chat/pricing) ## Overview [#overview] The MuChat REST API enables you to integrate AI-powered conversations into any application or workflow. Build custom chat experiences, automate customer interactions, and manage your AI agents programmatically. API v2 features structured error codes, cursor-based pagination, and real-time streaming via Server-Sent Events (SSE). **Base URL:** ``` https://api.mu.chat/api/v2 ``` Chat with your AI agents and handle real-time streaming responses Create, configure, and update AI agents and their training sources Retrieve conversations and messages from your AI interactions ## Quick Start [#quick-start] Creating API key in MuChat dashboard 1. Visit your [MuChat Dashboard](https://app.mu.chat/dashboard) 2. Go to **Workspace settings** → **API keys** 3. Click **Create API Key** and copy the generated key Store your API key securely and never expose it in client-side code. Finding Agent ID in MuChat settings 1. Select your AI Agent in the dashboard 2. Go to **Settings** → **General** 3. Copy the **Agent ID** from the **Agent details** card Test your integration with a simple chat request: ```bash theme={null} curl -X POST 'https://api.mu.chat/api/v2/agents/YOUR_AGENT_ID/chat' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "message": "Hello! How can you help me?", "stream": false }' ``` **Expected Response:** ```json theme={null} { "data": { "id": "msg_abc123", "role": "assistant", "parts": [ { "type": "text", "text": "Hello! I'm here to help answer your questions and assist with any information you need. What can I help you with today?" } ], "metadata": { "userMessageId": "msg_xyz789", "conversationId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d", "userId": null, "finishReason": "stop", "usage": { "credits": 2 } } } } ``` `stream` defaults to `true` in API v2. Set it to `false` to receive the complete message as a single JSON response. Conversation history is stored by MuChat — you don't need to resend previous messages. Pass the `conversationId` from the previous response to send a follow-up: ```bash theme={null} curl -X POST 'https://api.mu.chat/api/v2/agents/YOUR_AGENT_ID/chat' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "message": "Tell me more about your pricing.", "conversationId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d", "stream": false }' ``` To associate a new conversation with one of your users, pass a `userId` on the first message. See [User Conversations](/en/api-reference/v2/user-conversations) for details. ### Chat API Streaming [#chat-api-streaming] The [chat API](/en/api-reference/v2/agents/chat-with-an-agent) streams responses in real time using Server-Sent Events. Each event is a `data:` line containing a JSON object with a `type` field, and the stream ends with `data: [DONE]`. Concatenate the `text-delta` events to build the full reply, and read the `conversationId` from the `finish` event to continue the conversation. ```javascript Node.js theme={null} // streamer.js (Node.js 18+) const apiKey = '' const agentId = '' const apiUrl = `https://api.mu.chat/api/v2/agents/${agentId}/chat` async function readAgentReply() { const response = await fetch(apiUrl, { method: 'POST', headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ message: '', stream: true, // conversationId: '', // omit to start a new conversation }), }) if (!response.ok) { const { error } = await response.json() throw new Error(`${error.code}: ${error.message}`) } const reader = response.body.getReader() const decoder = new TextDecoder() let buffer = '' let conversationId while (true) { const { done, value } = await reader.read() if (done) break buffer += decoder.decode(value, { stream: true }) const lines = buffer.split('\n') buffer = lines.pop() // keep any incomplete line for the next chunk for (const line of lines) { if (!line.startsWith('data: ')) continue const data = line.slice('data: '.length) if (data === '[DONE]') continue const event = JSON.parse(data) switch (event.type) { case 'text-delta': process.stdout.write(event.delta) break case 'finish': conversationId = event.messageMetadata.conversationId break case 'error': console.error('\nStream error:', event.errorText) break } } } console.log('\nConversation ID:', conversationId) } readAgentReply().catch((error) => console.log('Error:', error.message)) ``` ```python Python theme={null} ## streamer.py import json import requests api_key = '' agent_id = '' api_url = f'https://api.mu.chat/api/v2/agents/{agent_id}/chat' def read_agent_reply(): try: headers = { 'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json' } data = { 'message': '', 'stream': True, # 'conversationId': '', # omit to start a new conversation } response = requests.post(api_url, json=data, headers=headers, stream=True) response.raise_for_status() conversation_id = None for line in response.iter_lines(decode_unicode=True): if not line or not line.startswith('data: '): continue payload = line[len('data: '):] if payload == '[DONE]': continue event = json.loads(payload) if event['type'] == 'text-delta': print(event['delta'], end='', flush=True) elif event['type'] == 'finish': conversation_id = event['messageMetadata']['conversationId'] elif event['type'] == 'error': print(f"\nStream error: {event['errorText']}") print(f'\nConversation ID: {conversation_id}') except requests.exceptions.RequestException as error: print('Error:', error) read_agent_reply() ``` For the full list of stream events — including client action (tool call) events — see the [Streaming guide](/en/api-reference/v2/streaming). ## Error Handling [#error-handling] API v2 returns structured errors with a machine-readable `code`: ```json theme={null} { "error": { "code": "RATE_LIMIT_TOO_MANY_REQUESTS", "message": "Too many requests, please try again later" } } ``` Every response includes an `x-request-id` header — include it when contacting support. See [Error Handling](/en/api-reference/v2/error-handling) for all error codes and [Rate Limiting](/en/api-reference/v2/authentication#rate-limiting) for limits and retry guidance. ## Performance Best Practices [#performance-best-practices] **Optimization Strategies:** - Use streaming for chat responses to improve perceived performance - Reuse `conversationId` for follow-ups instead of starting new conversations - Cache AI agent responses when appropriate - Respect the `Retry-After` header when you receive a `429` response - Use cursor-based [pagination](/en/api-reference/v2/pagination) when listing conversations, messages, or sources ## 🚀 Try It Live! [#-try-it-live] Ready to see the magic in action? Dive straight into our interactive playground where you can test every API endpoint, experiment with real responses, and build your integration in real-time. Test APIs instantly • No setup required • Real-time responses • Copy working code snippets ### Key API Endpoints [#key-api-endpoints] Send messages and receive AI responses with streaming support Create, update, and configure AI agents programmatically Access chat history and conversation messages Add and manage the training sources for your AI agents Explore the full API v2 reference — authentication, streaming, client actions, pagination, and more # Developer Overview (/en/docs/developer-guide) ## Choose Your Integration Path [#choose-your-integration-path] Embed your AI agent on your website as a Chat Bubble or Center Stage. Build custom chat interfaces and server-to-server integrations with the REST API. Add AI agents to native mobile apps with the [Android SDK](/en/android-sdk) (Alpha) or the [iOS SDK](/en/ios-sdk) (Beta). Manage AI agents, sources, conversations, and more from your terminal or CI. ## Explore Developer Features [#explore-developer-features] Get real-time notifications for chat events. Connect MCP clients like Claude and Cursor to your workspace. Show rich, interactive UI inside conversations. ## Common Integration Patterns [#common-integration-patterns] - [Embed script](/en/developer-guide/website-integration/chat-bubble) on product pages - [Identity verification](/en/developer-guide/website-integration/identity-verification) for logged-in customers - [Custom actions](/en/developer-guide/website-integration/client-side-custom-actions) for order lookup and returns - [Embed script](/en/developer-guide/website-integration/chat-bubble) as a contextual help widget - [Event listeners](/en/developer-guide/website-integration/chatbot-event-listeners) to track user interactions - [Custom actions](/en/developer-guide/website-integration/client-side-custom-actions) for tutorials and account management - [API integration](/en/developer-guide/api-integration) for an internal dashboard - [Identity verification](/en/developer-guide/website-integration/identity-verification) for employees - [Analytics](/en/user-guides/chatbot/analytics) for usage insights