### Glossary Setup Example Source: https://docsbot.ai/documentation/doc/glossary-improve-search-relevance-with-smart-term-replacement Define term-replacement pairs to map informal user terms to your official vocabulary. This example shows how 'upload' and 'save' can be mapped to 'archive'. ```plaintext upload = archive save = archive ``` -------------------------------- ### Start Development Server Source: https://docsbot.ai/documentation/doc/embedding-docsbot-into-a-docusaurus-v3-site Command to start the Docusaurus development server. ```bash npm run start ``` ```bash yarn start ``` -------------------------------- ### SKILL.md Front Matter Example Source: https://docsbot.ai/documentation/developer/skills-technical-guide Illustrates the required YAML front matter for a SKILL.md file, including the skill's name and a description that guides the bot on when to load the Skill. The description is crucial for routing and should clearly state the user intent and domain. ```yaml --- name: example-skill description: "Use when the user needs help with a specific workflow." --- # Example Skill ## Overview Explain what the Skill does and when the bot should use it. ``` -------------------------------- ### Usage Example Source: https://docsbot.ai/documentation/developer/mcp-server An example configuration for an MCP client, specifically for the Question History endpoint. ```APIDOC ## Usage example Example MCP client config with Question History endpoint: ```json { "mcpServers": { "docsbot-question-history": { "url": "https://api.docsbot.ai/teams/{teamId}/bots/{botId}/questions/mcp/", "headers": { "Authorization": "Bearer " } } } } ``` ``` -------------------------------- ### Example MCP Server Description Source: https://docsbot.ai/documentation/doc/connect-remote-mcp-servers-docsbot-agent This is an example of a server description that helps the agent understand when to use tools from the connected server. Descriptions should be practical and reflect the server's capabilities. ```text Use when the user needs invoice history, payment status, or subscription changes from their connected account. ``` -------------------------------- ### Generic Integration Example Source: https://docsbot.ai/documentation/developer/embeddable-chat-widget An example of integrating the `supportCallback` with other support widgets, demonstrating how to prevent the default behavior and unmount the DocsBot widget to open a custom support solution. ```APIDOC ## DocsBotAI.init() with Custom Support Integration ### Description Initializes the DocsBot AI widget and configures a `supportCallback` to integrate with external support systems. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **id** (string) - Required - Your unique DocsBot AI ID. - **supportCallback** (function) - Optional - A function to be called when the user clicks the support link. It receives `event`, `history`, and `metadata` objects. ### Request Example ```javascript DocsBotAI.init({ id: 'YOUR_ID_HERE', supportCallback: function (event, history, metadata) { event.preventDefault(); // Prevent default behavior opening the url. DocsBotAI.unmount(); // Hide the DocsBot widget. // Run some JS here to open your support widget. console.log(metadata.conversationId); }, }); ``` ``` -------------------------------- ### Basic Lead Capture Example Source: https://docsbot.ai/documentation/developer/conversation-lead A fundamental example demonstrating how to post lead information to the API. Ensure you replace placeholders with your actual team ID, bot ID, API key, and conversation ID. ```python url = "https://api.docsbot.ai/teams/your-team-id/bots/your-bot-id/conversations/550e8400-e29b-41d4-a716-446655440000/lead" headers = { "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json" } payload = { "metadata": { "email": "user@example.com", "name": "John Doe", "company": "Acme Corp", "phone": "+1234567890" } } response = requests.post(url, json=payload, headers=headers) if response.status_code == 200: print("Lead captured successfully:", response.json()) else: print(f"Error: {response.status_code} - {response.text}") ``` -------------------------------- ### Help Scout Beacon Initialization (Example) Source: https://docsbot.ai/documentation/developer/widget-integrations/helpscout This is an example of how your existing Help Scout Beacon embed code might look. It includes the initialization script. ```javascript ``` -------------------------------- ### Generic Integration Example Source: https://docsbot.ai/documentation/developer/widget-integrations This example demonstrates the basic structure for integrating the DocsBot widget with a custom support system. It shows how to prevent the default support URL, hide the DocsBot widget, and log relevant conversation details before opening a custom support solution. ```javascript DocsBotAI.init({ id: 'YOUR_ID_HERE', supportCallback: function (event, history, metadata, ticket) { event.preventDefault() // Prevent default behavior opening the url. DocsBotAI.unmount() // Hide the DocsBot widget. // Your custom integration code here console.log('User needs support:', { conversationId: metadata.conversationId, conversationUrl: metadata.conversationUrl, ticket: ticket // AI-generated ticket with subject and message }); // Open your support widget or redirect to support page }, }) ``` -------------------------------- ### Example MCP Client Configuration Source: https://docsbot.ai/documentation/developer/mcp-server This is an example configuration for an MCP client, specifically for the Question History endpoint. It includes the server URL and the Authorization header. ```json { "mcpServers": { "docsbot-question-history": { "url": "https://api.docsbot.ai/teams/{teamId}/bots/{botId}/questions/mcp/", "headers": { "Authorization": "Bearer " } } } } ``` -------------------------------- ### List Leads Response Example Source: https://docsbot.ai/documentation/developer/leads-api This is an example of the JSON response when listing leads. It includes a list of lead objects and pagination details. ```json { "leads": [ { "id": "550e8400-e29b-41d4-a716-446655440000", "createdAt": "2026-02-05T14:12:01.182Z", "updatedAt": "2026-02-05T14:13:21.004Z", "metadata": { "name": "John Doe", "email": "user@example.com", "company": "Acme Corp" }, "ip": "dfebd0b1d7e002b7ff745a5f2885340579ceb966d8a33a7c4b4e0669f0d0384b", "alias": "John Doe", "email": "user@example.com" } ], "pagination": { "perPage": 50, "page": 0, "totalCount": 1, "hasMorePages": false, "planLimit": 1000000 } } ``` -------------------------------- ### Another Rewritten Query Example Source: https://docsbot.ai/documentation/doc/glossary-improve-search-relevance-with-smart-term-replacement This example shows the rewritten query for 'How can I save the form?', demonstrating how the glossary maps 'save' to 'archive'. ```plaintext How can I save (archive) the form? ``` -------------------------------- ### Vanilla Chart.js Example Source: https://docsbot.ai/documentation/developer/stats-api Use this example to create line and pie charts with vanilla JavaScript and Chart.js. It demonstrates secure API data handling by fetching data server-side. Ensure API keys are not exposed client-side. ```html
``` -------------------------------- ### Workflow Example: Create, Clarify, and Check Research Job Status Source: https://docsbot.ai/documentation/developer/research-api This comprehensive example demonstrates a full workflow for creating a research job, providing clarifications, and polling for its status using the Fetch API. Ensure you replace placeholders with your actual credentials. ```javascript // 1. Create a research job const createJob = async () => { const response = await fetch( 'https://api.docsbot.ai/teams/YOUR_TEAM_ID/bots/YOUR_BOT_ID/research', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json', }, body: JSON.stringify({ question: 'What are the current trends in AI customer support?', web_search: true, }), } ) const job = await response.json() console.log('Job created:', job.jobId) console.log('Clarifications:', job.clarifications) return job } // 2. Continue with clarifying answers const continueJob = async (jobId, answers) => { const response = await fetch( `https://api.docsbot.ai/teams/YOUR_TEAM_ID/bots/YOUR_BOT_ID/research/${jobId}`, { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json', }, body: JSON.stringify({ answers }), } ) const result = await response.json() console.log('Job status:', result.status) return result } // 3. Check status via Admin API const checkStatus = async (jobId) => { const response = await fetch( `https://api.docsbot.ai/teams/YOUR_TEAM_ID/bots/YOUR_BOT_ID/research/${jobId}`, { headers: { 'Authorization': 'Bearer YOUR_API_KEY', }, } ) const job = await response.json() console.log('Current status:', job.status) return job } // Example usage (async () => { const job = await createJob() // If clarifications are provided, answer them if (job.clarifications) { await continueJob(job.jobId, 'Focus on SaaS B2B customer support.') } // Poll for completion const status = await checkStatus(job.jobId) console.log('Final status:', status.status) if (status.response) { console.log('Research result:', status.response) } })() ``` -------------------------------- ### Get Specific Team Details (JavaScript Fetch) Source: https://docsbot.ai/documentation/developer/team-api This JavaScript Fetch API example shows how to get details for a single team using its ID. It requires setting the Authorization header and specifying the team ID in the URL. ```javascript var myHeaders = new Headers(); myHeaders.append("Authorization", "Bearer c0f5c347f0138f76a005921ec723f38185554327f69349dcf220a6f6531ab673"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### cURL Request to Admin API Source: https://docsbot.ai/documentation/developer/authentication Example cURL command to make a GET request to the /api/teams/ endpoint. It includes the necessary 'Authorization' header with your user API key. ```bash curl --request GET 'https://docs.ai/api/teams/' \ --header 'Authorization: Bearer 2e9fd6965890e80b9a7bb271900ab859e199a5778f851b73d97136d3495849ef' ``` -------------------------------- ### PHP cURL Authentication Source: https://docsbot.ai/documentation/developer/authentication Authenticate API requests using PHP's cURL library. This example demonstrates setting the Authorization header for a GET request to the DocsBot.ai API. ```php 'https://docsbot.ai/api/teams/', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 1, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'Authorization: Bearer 2e9fd6965890e80b9a7bb271900ab859e199a5778f851b73d97136d3495849ef' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ?> ``` -------------------------------- ### List All Sources (JavaScript Fetch) Source: https://docsbot.ai/documentation/developer/source-api This JavaScript fetch example demonstrates how to retrieve a list of all sources for a given team and bot. It includes setting the Authorization header. ```javascript var myHeaders = new Headers() myHeaders.append( 'Authorization', 'Bearer c0f5c347f0138f76a005921ec723f38185554327f69349dcf220a6f6531ab673', ) var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow', } fetch( 'https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/SQMV36O8xi43xbZRzYLy/sources', requestOptions, ) .then((response) => response.text()) .then((result) => console.log(result)) .catch((error) => console.log('error', error)) ``` -------------------------------- ### Get Specific Source (JavaScript Fetch) Source: https://docsbot.ai/documentation/developer/source-api This JavaScript fetch example shows how to retrieve the complete details of a single source by its ID. It requires the team ID, bot ID, and source ID. ```javascript var myHeaders = new Headers() myHeaders.append( 'Authorization', 'Bearer c0f5c347f0138f76a005921ec723f38185554327f69349dcf220a6f6531ab673', ) var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow', } fetch( 'https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/SQMV36O8xi43xbZRzYLy/sources/qGDSDhbdxtqmifTZQrYs', requestOptions, ) .then((response) => response.text()) .then((result) => console.log(result)) .catch((error) => console.log('error', error)) ``` -------------------------------- ### Initialize DocsBot with Zoho Chat Support Callback Source: https://docsbot.ai/documentation/developer/widget-integrations/zoho-chat Configure the DocsBot widget to open the Zoho Chat widget when the support link is clicked. This example pre-fills visitor information and conversation metadata. ```javascript ``` -------------------------------- ### Conversation Rated Payload Example Source: https://docsbot.ai/documentation/developer/webhooks-api Example JSON payload for the `conversation.rated` webhook event. ```APIDOC ### conversation.rated payload ```json { "event": "conversation.rated", "teamId": "team_123", "botId": "bot_456", "conversation": { "id": "conv_789", "createdAt": "2026-02-10T15:12:44.000000", "updatedAt": "2026-02-11T18:45:22.000000", "metadata": { "email": "user@example.com", "plan": "pro" }, "ip": "a1b2c3d4e5f6...", "ratedAt": "2026-02-11T18:45:22.123456", "rating": 1, "answerId": "ans_321", "resolved": "confirmed", "escalated": "none" } } ``` ``` -------------------------------- ### Conversation Escalated Payload Example Source: https://docsbot.ai/documentation/developer/webhooks-api Example JSON payload for the `conversation.escalated` webhook event. ```APIDOC ### conversation.escalated payload ```json { "event": "conversation.escalated", "teamId": "team_123", "botId": "bot_456", "conversation": { "id": "conv_789", "createdAt": "2026-02-10T15:12:44.000000", "updatedAt": "2026-02-11T18:43:01.000000", "metadata": { "email": "user@example.com", "plan": "pro" }, "ip": "a1b2c3d4e5f6...", "escalatedAt": "2026-02-11T18:43:01.123456", "resolved": "unresolved", "escalated": "handled" } } ``` ``` -------------------------------- ### Lead Created Payload Example Source: https://docsbot.ai/documentation/developer/webhooks-api Example JSON payload for the `lead.created` webhook event. ```APIDOC ### lead.created payload When a `lead.created` webhook is delivered, DocsBot posts JSON like: ```json { "event": "lead.created", "teamId": "team_123", "botId": "bot_123", "lead": { "id": "conversation_123", "createdAt": "2026-02-10T14:30:00.000Z", "updatedAt": null, "metadata": { "name": "Jane Doe", "email": "jane@example.com" }, "ip": "hashed-ip" } } ``` ``` -------------------------------- ### Create Source with File Path using JavaScript Source: https://docsbot.ai/documentation/developer/source-api This comprehensive JavaScript example demonstrates how to obtain an upload URL, upload a file, and then create a source using the DocsBot API. It requires authentication with a bearer token. ```javascript const teamId = '0NZfVRlrjJ6d4YdwUGHt' const botId = 'yR5EwAGpINpmp7XzT9qL' const authToken = '8656f848949372c090cd455cc39c158b5b8bd9a00d0c9807f832bec30b1735a1' // Get upload URL fetch( `https://docsbot.ai/api/teams/${teamId}/bots/${botId}/upload-url?fileName=test.csv`, { headers: { Authorization: `Bearer ${authToken}`, }, }, ) .then((response) => response.json()) .then((data) => { const url = data.url const file = data.file console.log('Uploading to ', url) // Upload file to URL fetch(url, { method: 'PUT', body: require('fs').createReadStream('test.csv'), headers: { 'Content-Type': 'application/octet-stream', }, }) console.log('Creating source...') // Upload source fetch(`https://docsbot.ai/api/teams/${teamId}/bots/${botId}/sources`, { method: 'POST', headers: { Authorization: `Bearer ${authToken}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ type: 'csv', title: 'test', file: file, url: 'https://www.google.com', }), }) }) ``` -------------------------------- ### DocsBot Initialization with LiveChat Support Callback Source: https://docsbot.ai/documentation/developer/widget-integrations/livechat Configure the DocsBot widget to open the LiveChat widget when the support link is clicked. This example sets customer information and custom variables before opening LiveChat, and optionally includes the AI-generated ticket message. ```javascript DocsBotAI.init({ id: "YOUR_ID_HERE", supportCallback: function (event, history, metadata, ticket) { event.preventDefault(); // Prevent default behavior opening the url. DocsBotAI.unmount(); // Hide the widget. // Set customer information using LiveChat API LiveChatWidget.call('set_customer_name', metadata.userName || 'Visitor'); LiveChatWidget.call('set_customer_email', metadata.userEmail || ''); // Set custom variables with conversation metadata LiveChatWidget.call('set_custom_variables', [ { name: 'conversation_link', value: metadata.conversationUrl || window.location.href }, { name: 'ticket_subject', value: ticket ? ticket.subject : 'No ticket generated' } ]); // Open the LiveChat widget with AI-generated ticket message if (ticket && ticket.message) { LiveChatWidget.call('maximize', { messageDraft: ticket.message }); } else { LiveChatWidget.call('maximize'); } }, }) ``` -------------------------------- ### Get Bot Source: https://docsbot.ai/documentation/developer/bot-api Fetches a specific bot by its ID. This endpoint accepts a GET request. ```APIDOC ## GET Bot ### Description This endpoint fetches a specific bot by its ID. It accepts a GET request. ### Method GET ### Endpoint `https://docsbot.ai/api/teams/:teamId/bots/:botId` ### Parameters #### Path Parameters - **teamId** (string) - Required - The ID of the team. - **botId** (string) - Required - The ID of the bot. ### Request Example #### cURL ```curl curl --request GET 'https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/iADcTdrl7R51JiTjrWKy' \ --header 'Authorization: Bearer 2e9fd6965890e80b9a7bb271900ab859e199a5778f851b73d97136d3495849ef' ``` #### JavaScript (Fetch) ```javascript var myHeaders = new Headers(); myHeaders.append("Authorization", "Bearer c0f5c347f0138f76a005921ec723f38185554327f69349dcf220a6f6531ab673"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/iADcTdrl7R51JiTjrWKy", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` ### Response #### Success Response (200) Response is a JSON bot object: ```json { "id": "iADcTdrl7R51JiTjrWKy", "questionCount": 0, "name": "Your Bot Name", "description": "Ask me anything about your product.", "privacy": "public", "indexId": "Document_mlc4lmmc91", "customPrompt": null, "language": "en", "model": "gpt-4o-mini", "createdAt": "2023-03-16T21:15:19.994Z", "sourceCount": 1, "pageCount": 50, "chunkCount": 140, "status": "ready" } ``` ``` -------------------------------- ### Replace Placeholder ID Example Source: https://docsbot.ai/documentation/doc/embedding-docsbot-into-a-docusaurus-v3-site Example of how to replace the placeholder 'YOUR_ID_HERE' with an actual DocsBot ID. ```javascript DocsBotAI.init({ id: '12345' }); ``` -------------------------------- ### HTML Image Tag Example Source: https://docsbot.ai/documentation/doc/enable-learn-from-public-images-docsbot This is an example of an HTML image tag before enabling the 'Learn from Public Images' feature. ```html ``` -------------------------------- ### DocsBot Initialization with Prefilled Freshdesk Form (Pro+ Plan) Source: https://docsbot.ai/documentation/developer/widget-integrations/freshdesk Advanced DocsBot initialization for Pro plans and up. It includes user identification and pre-fills the Freshdesk ticket form with AI-generated subject, description, and conversation URL from the chat history. ```javascript DocsBotAI.init({ id: "YOUR_ID_HERE", // optionally identify logged in user for chat logs identify: { name: "Bilbo Baggins", email: "bilbo@shire.net" }, supportCallback: function (event, history, metadata, ticket) { event.preventDefault(); // Prevent default behavior opening the url. DocsBotAI.unmount(); // Hide the widget. // Open the Freshdesk widget form https://developers.freshdesk.com/widget-api/#prefill-fields FreshworksWidget('open', 'ticketForm'); // Optionally identify user from metadata above. This will work with our upcoming lead collection tool FreshworksWidget('identify', 'ticketForm', { name: metadata.name || null, email: metadata.email || null, }); // Prefill the ticket (Pro+ plan only) if (ticket) { FreshworksWidget('prefill', 'ticketForm', { subject: ticket.subject, description: ticket.message, // Store conversation link in a hidden custom field for agents custom_fields: { cf_conversation_url: metadata.conversationUrl || '' } }); } else if (metadata.conversationUrl) { // Store conversation link in a hidden custom field for agents FreshworksWidget('prefill', 'ticketForm', { custom_fields: { cf_conversation_url: metadata.conversationUrl } }); } }, }) ``` -------------------------------- ### Success Response Example Source: https://docsbot.ai/documentation/developer/conversation-ticket This is an example of a successful API response containing the generated ticket's subject and message. ```json { "subject": "Pricing and Feature Inquiry", "message": "Hello,\n\nI'm interested in learning more about DocsBot's pricing plans and the features included in each tier. Could you please provide details on the following:\n\n- What are the differences between the Hobby, Personal, and Pro plans?\n- How many bots, source pages, and messages per month are included with each plan?\n- Are there any limits on team users or access to advanced analytics?" } ``` -------------------------------- ### Create URL Source via JavaScript Fetch Source: https://docsbot.ai/documentation/developer/source-api This JavaScript Fetch example demonstrates how to create a new 'url' type source. It includes setting necessary headers like Authorization and Content-Type. ```javascript var myHeaders = new Headers() myHeaders.append( 'Authorization', 'Bearer c0f5c347f0138f76a005921ec723f38185554327f69349dcf220a6f6531ab673', ) myHeaders.append('Content-Type', 'application/json') var raw = JSON.stringify({ type: 'url', title: 'Infinite Uploads', url: 'https://infiniteuploads.com', }) var requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow', } fetch( 'https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/SQMV36O8xi43xbZRzYLy/sources', requestOptions, ) .then((response) => response.text()) .then((result) => console.log(result)) .catch((error) => console.log('error', error)) ``` -------------------------------- ### Get Research Job Details Source: https://docsbot.ai/documentation/developer/bot-research-api This endpoint retrieves a single research job by ID. It accepts a GET request. ```APIDOC ## GET /api/teams/:teamId/bots/:botId/research/:jobId ### Description Retrieves details for a specific research job. ### Method GET ### Endpoint /api/teams/:teamId/bots/:botId/research/:jobId ### Response #### Success Response (200) - **jobId** (string) - The research job ID. - **status** (string) - Job status (e.g., `queued`, `running`, `completed`). - **title** (string/null) - The job title if set. - **question** (string/null) - The prompt or question submitted for research. - **response** (object/null) - The model response payload, if completed. - **createdAt** (string/null) - Job creation timestamp. - **completedAt** (string/null) - Completion timestamp if finished. - **cancelledAt** (string/null) - Cancellation timestamp if deleted. ### Response Example ```json { "jobId": "job_123", "status": "completed", "title": "Competitor pricing analysis", "question": "Summarize competitor pricing tiers", "response": { "summary": "..." }, "createdAt": "2024-06-10T18:25:16.980Z", "completedAt": "2024-06-10T18:32:10.120Z", "cancelledAt": null } ``` ``` -------------------------------- ### Example Error Response Source: https://docsbot.ai/documentation/developer/api-errors This is an example of a typical error response from the API, indicating a bad request due to an invalid parameter. ```json { "message": "Invalid param \"privacy\"." } ``` -------------------------------- ### DocsBot AI Initialization with Help Scout Callback Source: https://docsbot.ai/documentation/developer/widget-integrations/helpscout Initialize the DocsBot AI widget and configure the `supportCallback` to open the Help Scout Beacon. This function prevents default behavior, hides the DocsBot widget, initializes and opens the Beacon, and pre-fills ticket information if available. ```javascript DocsBotAI.init({ id: 'YOUR_ID_HERE', // optionally identify logged in user for chat logs metadata: { name: "Bilbo Baggins", email: "bilbo@shire.net", } supportCallback: function (event, history, metadata, ticket) { event.preventDefault() // Prevent default behavior opening the url. DocsBotAI.unmount() // Hide the widget. // Open the Help Scout Beacon widget. Beacon('init', 'YOUR_BEACON_ID_HERE') // Replace with your beacon id, assuming you havn't already initialized the beacon. Beacon('open') if (ticket) { // Add ticket subject and message to Beacon. Note this works for Pro plans only Beacon('prefill', { name: metadata.name || null, //assuming you identified the user above email: metadata.email || null, //assuming you identified the user above subject: ticket.subject, text: ticket.message }); } else { Beacon('prefill', { name: metadata.name || null, email: metadata.email || null, }); } if (metadata.conversationUrl) { // Pass conversation link as session data for agents Beacon('session-data', { conversationUrl: metadata.conversationUrl }); } }, }) ``` -------------------------------- ### History Array Example Source: https://docsbot.ai/documentation/developer/embeddable-chat-widget An example of the history array structure passed to the `supportCallback`. Each object represents a message with sender, content, and timestamp. ```json [ { "Human": "hi", "timestamp": "2025-05-08T22:56:28.514357" }, { "AI": "Hello! How can I assist you today?", "timestamp": "2025-05-08T22:56:30.645700", "type": "answer" }, { "Human": "How do i connect to Zapier?", "timestamp": "2025-05-23T14:54:47.215796" }, { "AI": "Visit the integrations tab in your bot...", "timestamp": "2025-05-23T14:54:52.215796" }, { "AI": "Did that answer your question?", "timestamp": "2025-05-23T14:54:55.215796" } ] ``` -------------------------------- ### User Query Example Source: https://docsbot.ai/documentation/doc/glossary-improve-search-relevance-with-smart-term-replacement An example of a user query that uses informal language. This query will be processed using the defined glossary terms. ```plaintext How do I upload a document? ``` -------------------------------- ### Initialize DocsBot with Gorgias Support Callback Source: https://docsbot.ai/documentation/developer/widget-integrations/gorgias Configure the DocsBot widget to open the Gorgias chat interface when the support link is clicked. This snippet shows how to use the `supportCallback` to prefill information and open the Gorgias widget. ```javascript DocsBotAI.init({ id: "YOUR_ID_HERE", supportCallback: function (event, history, metadata, ticket) { event.preventDefault(); // Prevent default behavior opening the url. DocsBotAI.unmount(); // Hide the widget. // Prefill visitor information and conversation metadata if (window.GorgiasWidget) { if (ticket) { // Add ticket subject and message to Gorgias window.GorgiasWidget.prefill({ name: metadata.userName || 'Visitor', email: metadata.userEmail || '', custom_fields: { conversation_link: metadata.conversationUrl || window.location.href, subject: ticket.subject } }); // Set the message using GorgiasChat.setCurrentInput window.GorgiasChat.setCurrentInput(ticket.message); } else { window.GorgiasWidget.prefill({ name: metadata.userName || 'Visitor', email: metadata.userEmail || '', custom_fields: { conversation_link: metadata.conversationUrl || window.location.href } }); } // Open the Gorgias widget window.GorgiasWidget.open(); } }, }) ``` -------------------------------- ### DocsBot Initialization with Freshdesk Support Callback Source: https://docsbot.ai/documentation/developer/widget-integrations/freshdesk Initialize the DocsBot widget and configure the `supportCallback` to open the Freshdesk ticket form when the support link is clicked. This prevents the default URL behavior and hides the DocsBot widget before opening Freshdesk. ```javascript DocsBotAI.init({ id: "YOUR_ID_HERE", supportCallback: function (event, history) { event.preventDefault(); // Prevent default behavior opening the url. DocsBotAI.unmount(); // Hide the widget. // Open the Freshdesk widget form https://developers.freshdesk.com/widget-api/#open-contact-form FreshworksWidget('open', 'ticketForm'); }, }) ``` -------------------------------- ### Success Response Example Source: https://docsbot.ai/documentation/developer/conversation-summarize This is an example of a successful response from the Conversation Summarize API, detailing the conversation's title, summary, and sentiment. ```json { "title": "Pricing plans Overview", "summary": "User inquired about pricing plans and received detailed information about Hobby, Personal, and Pro plans. The conversation was resolved satisfactorily.", "sentiment": "positive" } ``` -------------------------------- ### Create Source with File Path Source: https://docsbot.ai/documentation/developer/source-api This section demonstrates how to upload a file and then create a source using the obtained upload URL. It covers getting the upload URL, uploading the file, and finally creating the source with the file details. ```APIDOC ## Create Source with the File Path This process involves three main steps: getting an upload URL, uploading the file to that URL, and then creating the source with the file information. ### Get Upload URL Send a GET request to the `/upload-url` endpoint to obtain a pre-signed URL for uploading files. #### Endpoint `GET https://docsbot.ai/api/teams/:teamId/bots/:botId/upload-url?fileName=your_file_name` #### Request Example (JavaScript Fetch) ```javascript const teamId = 'YOUR_TEAM_ID'; const botId = 'YOUR_BOT_ID'; const authToken = 'YOUR_AUTH_TOKEN'; fetch( `https://docsbot.ai/api/teams/${teamId}/bots/${botId}/upload-url?fileName=test.csv`, { headers: { Authorization: `Bearer ${authToken}`, }, } ) .then((response) => response.json()) .then((data) => { const url = data.url; const file = data.file; console.log('Uploading to:', url); // Proceed to upload file and create source }); ``` ### Upload File Use the obtained URL to upload the file using a PUT request. The `Content-Type` should be `application/octet-stream`. #### Method `PUT` #### Endpoint (Provided by the Get Upload URL step) #### Request Example (JavaScript Fetch) ```javascript // Assuming 'url' and 'file' are obtained from the previous step fetch(url, { method: 'PUT', body: require('fs').createReadStream('test.csv'), headers: { 'Content-Type': 'application/octet-stream', }, }); ``` ### Create Source Send a POST request to the `/sources` endpoint to create the source entry in the system. #### Endpoint `POST https://docsbot.ai/api/teams/:teamId/bots/:botId/sources` #### Request Body - **type** (string) - Required - The type of the source (e.g., 'csv', 'url'). - **title** (string) - Required - The title of the source. - **file** (string) - Required - The file identifier obtained from the upload URL step. - **url** (string) - Optional - The original URL if the source is from a web page. #### Request Example (JavaScript Fetch) ```javascript // Assuming 'file' is obtained from the upload URL step fetch(`https://docsbot.ai/api/teams/${teamId}/bots/${botId}/sources`, { method: 'POST', headers: { Authorization: `Bearer ${authToken}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ type: 'csv', title: 'test', file: file, // The file identifier from the upload URL response url: 'https://www.google.com', // Optional: original URL }), }); ``` ```