### Example: Authenticate GET /api/teams/ Endpoint with Python Requests Source: https://docsbot.ai/documentation/developer/authentication This Python example utilizes the `requests` library to send a GET request to the `/api/teams/` endpoint. It demonstrates how to set the `Authorization` header for authentication. ```python import requests url = "https://docsbot.ai/api/teams/" payload={} headers = { 'Authorization': 'Bearer 2e9fd6965890e80b9a7bb271900ab859e199a5778f851b73d97136d3495849ef' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Example: Authenticate GET /api/teams/ Endpoint with JavaScript Fetch Source: https://docsbot.ai/documentation/developer/authentication This JavaScript example demonstrates how to authenticate a GET request to the `/api/teams/` endpoint using the Fetch API. It sets the `Authorization` header with the Bearer token. ```javascript var myHeaders = new Headers(); myHeaders.append("Authorization", "Bearer 2e9fd6965890e80b9a7bb271900ab859e199a5778f851b73d97136d3495849ef"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://docsbot.ai/api/teams/", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### Example: Authenticate GET /api/teams/ Endpoint with cURL Source: https://docsbot.ai/documentation/developer/authentication This example shows how to authenticate a GET request to the `/api/teams/` endpoint using cURL. It includes the necessary `Authorization` header with the Bearer token. ```curl curl --request GET 'https://docsbot.ai/api/teams/' \ --header 'Authorization: Bearer 2e9fd6965890e80b9a7bb271900ab859e199a5778f851b73d97136d3495849ef' ``` -------------------------------- ### Help Scout Beacon Initialization (Example) Source: https://docsbot.ai/documentation/developer/widget-integrations/helpscout This is an example of the standard Help Scout Beacon initialization script. It is provided to show the context of the `Beacon('init', 'YOUR_BEACON_ID_HERE')` call within the `supportCallback`. ```javascript window.Beacon('init', 'YOUR_BEACON_ID_HERE') ``` -------------------------------- ### Bot Reports (Monthly) GET Request Example (cURL) Source: https://docsbot.ai/documentation/developer/stats-api This example demonstrates how to fetch monthly bot reports using a cURL command. It shows the necessary URL structure, including placeholders for team ID, bot ID, and the desired month, along with the required Authorization header. ```bash curl --request GET 'https://docsbot.ai/api/teams/YOUR_TEAM_ID/bots/YOUR_BOT_ID/reports?month=2024-06' \ --header 'Authorization: Bearer YOUR_API_KEY' ``` -------------------------------- ### Summarize Conversation API JavaScript Fetch Example Source: https://docsbot.ai/documentation/developer/conversation-summarize This example shows how to use the JavaScript fetch API to call the Conversation Summarize API. It includes setting up the request, headers, and handling the JSON response. ```javascript const response = await fetch( 'https://api.docsbot.ai/teams/your-team-id/bots/your-bot-id/conversations/550e8400-e29b-41d4-a716-446655440000/summarize', { method: 'GET', headers: { 'Authorization': 'Bearer YOUR_API_KEY' } } ); const summary = await response.json(); console.log(summary.title); // Short conversation title console.log(summary.summary); // Summary content console.log(summary.sentiment); // positive/neutral/negative ``` -------------------------------- ### Get Bot Statistics - JavaScript Fetch Examples Source: https://docsbot.ai/documentation/developer/stats-api Examples of how to retrieve bot statistics using JavaScript's Fetch API. Includes direct calls for relative and explicit date ranges, and a helper function for simplified usage with common date ranges. ```javascript const headers = new Headers({ Authorization: 'Bearer YOUR_TOKEN' }) // Relative date range (backwards compatible) fetch('https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/SQMV36O8xi43xbZRzYLy/stats?timeDelta=30', { headers }) .then((r) => r.json()) .then(console.log) ``` ```javascript // Explicit date range fetch('https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/SQMV36O8xi43xbZRzYLy/stats?startDate=2024-06-01&endDate=2024-06-30', { headers }) .then((r) => r.json()) .then(console.log) ``` ```javascript // Helper function for common date ranges function getBotStats(teamId, botId, token, options = {}) { const { timeDelta, startDate, endDate } = options const params = new URLSearchParams() if (startDate && endDate) { params.append('startDate', startDate) params.append('endDate', endDate) } else if (timeDelta) { params.append('timeDelta', timeDelta) } else { params.append('timeDelta', 30) // default } return fetch(`https://docsbot.ai/api/teams/${teamId}/bots/${botId}/stats?${params}`, { headers: { Authorization: `Bearer ${token}` } }).then(r => r.json()) } // Usage examples getBotStats('FOX1XkWo8VMx3hp6Zjkb', 'SQMV36O8xi43xbZRzYLy', 'YOUR_TOKEN', { timeDelta: 7 }) getBotStats('FOX1XkWo8VMx3hp6Zjkb', 'SQMV36O8xi43xbZRzYLy', 'YOUR_TOKEN', { startDate: '2024-06-01', endDate: '2024-06-30' }) ``` -------------------------------- ### Example Request Payload for Docsbot AI Source: https://docsbot.ai/documentation/developer/chat-agent This JSON object represents an example request payload sent to the Docsbot AI. It includes conversation details, user queries, metadata, and various configuration options for controlling the AI's behavior and response format. ```json { "conversationId": "550e8400-e29b-41d4-a716-446655440000", "question": "What is docsbot pricing.", "metadata": { "name": "your_name", "email": "your@gmail.com" }, "context_items": 5, "human_escalation": false, "followup_rating": false, "document_retriever": true, "full_source": false, "stream": false, "auto_cut": false, "image_urls": ["http://example.com/image1.jpg", "data:image/jpeg;base64,XXXXXXXX"], "reasoning_effort": "medium" } ``` -------------------------------- ### WebSocket Connection and Message Sending Source: https://docsbot.ai/documentation/developer/streaming-chat-api Provides examples of how to establish a WebSocket connection to the API and send the initial question to start a conversation. ```APIDOC ## WebSocket Connection and Message Sending ### Open a websocket connection To interact with the API, you need to establish a WebSocket connection. Replace `ZrbLG98bbxZ9EFqiPvyl` and `oFFiXuQsakcqyEdpLvCB` with your specific team and bot IDs. ```javascript const apiUrl = `wss://api.docsbot.ai/teams/ZrbLG98bbxZ9EFqiPvyl/bots/oFFiXuQsakcqyEdpLvCB/chat` const ws = new WebSocket(apiUrl) ``` ### Send the question as the first message Once the WebSocket connection is established, you can send your first message containing the question. The `history` should be an empty array for the initial message. ```javascript // Send message to server when connection is established ws.onopen = function (event) { const question = 'What is WordPress?' const req = { question: question, full_source: false, history: [] } // Set full_source to true if you need full source content ws.send(JSON.stringify(req)) } ``` ### Receiving Messages Messages from the server will be received via the `onmessage` event handler. The `type` property of the received message indicates its nature (e.g., 'typing', 'end'). ```javascript ws.onmessage = function (event) { const data = JSON.parse(event.data) if (data.type === 'typing') { console.log('Bot is typing...') } else if (data.type === 'end') { const messageContent = JSON.parse(data.message) console.log('Answer:', messageContent.answer) console.log('Sources:', messageContent.sources) // Close the connection when done ws.close() } } ws.onerror = function (event) { console.error('WebSocket error observed:', event) } ws.onclose = function (event) { console.log('WebSocket connection closed:', event) } ``` ``` -------------------------------- ### Create a URL Source using JavaScript Fetch API Source: https://docsbot.ai/documentation/developer/source-api This example shows how to create a new URL source for a bot using the JavaScript Fetch API. It sets up headers, constructs the JSON payload, and makes a POST request to the API endpoint. ```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)) ``` -------------------------------- ### Example: Authenticate GET /api/teams/ Endpoint with PHP cURL Source: https://docsbot.ai/documentation/developer/authentication This PHP example uses cURL to make a GET request to the `/api/teams/` endpoint, including the `Authorization` header with the Bearer token for authentication. ```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 Sources using JavaScript Fetch API Source: https://docsbot.ai/documentation/developer/source-api This JavaScript code snippet shows how to fetch a list of all sources for a given team and bot using the Fetch API. It includes setting up headers with an authorization token. ```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 Single Conversation - cURL Example Source: https://docsbot.ai/documentation/developer/conversations-api This snippet demonstrates how to retrieve a single conversation using its ID via a cURL GET request. It requires the team ID, bot ID, conversation ID, and an API key for authentication. ```bash curl --request GET 'https://docsbot.ai/api/teams/YOUR_TEAM_ID/bots/YOUR_BOT_ID/conversations/YOUR_CONVERSATION_ID' \ --header 'Authorization: Bearer YOUR_API_KEY' ``` -------------------------------- ### Initialize DocsBot with Freshdesk Support Callback Source: https://docsbot.ai/documentation/developer/widget-integrations/freshdesk This code initializes the DocsBot AI widget and configures the `supportCallback` function. When a user clicks the support link, this callback prevents the default behavior, hides the DocsBot widget, and opens the Freshdesk ticket form. ```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'); }, }) ``` -------------------------------- ### POST /query Source: https://docsbot.ai/documentation/developer/chat-agent Submit a query to the DocsBot AI and receive a response. The response format depends on the 'stream' parameter. ```APIDOC ## POST /query ### Description Submit a query to the DocsBot AI. The response format varies based on the `stream` parameter. When `stream` is `False`, a JSON object is returned. When `stream` is `True`, Server-Sent Events (SSE) are used. ### Method POST ### Endpoint `/query` ### Parameters #### Request Body - **conversationId** (string) - Required - Unique identifier for the conversation. - **question** (string) - Required - The user's question or query. - **metadata** (object) - Optional - User-related metadata (e.g., name, email). - **name** (string) - Optional - User's name. - **email** (string) - Optional - User's email address. - **context_items** (integer) - Optional - Number of context items to consider. - **human_escalation** (boolean) - Optional - Whether to enable human escalation. - **followup_rating** (boolean) - Optional - Whether to enable follow-up ratings. - **document_retriever** (boolean) - Optional - Whether to enable document retrieval. - **full_source** (boolean) - Optional - Whether to include full source content in the response. - **stream** (boolean) - Optional - If true, response will be streamed via SSE. Defaults to false. - **auto_cut** (boolean) - Optional - Whether to automatically cut responses. - **image_urls** (array) - Optional - Array of image URLs to include in the context. - **reasoning_effort** (string) - Optional - Specifies the reasoning effort level (e.g., 'medium'). ### Request Example ```json { "conversationId": "550e8400-e29b-41d4-a716-446655440000", "question": "What is docsbot pricing.", "metadata": { "name": "your_name", "email": "your@gmail.com" }, "context_items": 5, "human_escalation": false, "followup_rating": false, "document_retriever": true, "full_source": false, "stream": false, "auto_cut": false, "image_urls": ["http://example.com/image1.jpg", "data:image/jpeg;base64,XXXXXXXX"], "reasoning_effort": "medium" } ``` ### Response #### Success Response (200) **When `stream` is `False`:** - **event** (string) - Type of event indicating which type of tool is run. - **data** (object) - Information about the answer. May contain: - **answer** (string) - The answer to the query. - **history** (array) - History of interactions. - **sources** (array) - Sources used (only for `lookup_answer`). - **id** (string) - Unique identifier for rating (not for `is_resolved_question`). - **couldAnswer** (boolean) - Indicates if an answer could be generated. - **options** (object) - Preset options for user response (for `is_resolved_question` or `support_escalation`). **When `stream` is `True`:** - SSE stream of events, each with `event` and `data` fields. The `data` field is a JSON string that needs parsing. #### Source Object (within `data.sources`) - **type** (string) - Type of source (e.g., `url`, `document`). - **title** (string) - Title of the source. - **url** (string) - URL of the source (may be null). - **page** (string) - Page number of the source (may be null). - **content** (string) - Full source text content if `full_source` was true (may be null). - **used** (boolean) - Whether the source was used to answer the question. ### Response Example (stream: false) ```json { "event": "lookup_answer", "data": { "answer": "DocsBot pricing varies based on your needs. Please visit our website for detailed information.", "history": [ { "role": "user", "content": "What is docsbot pricing." }, { "role": "assistant", "content": "DocsBot pricing varies based on your needs. Please visit our website for detailed information." } ], "sources": [ { "type": "url", "title": "DocsBot Pricing Plans", "url": "https://docsbot.ai/pricing", "page": null, "content": null, "used": true } ], "id": "query-12345", "couldAnswer": true } } ``` ``` -------------------------------- ### Available Tools Source: https://docsbot.ai/documentation/developer/mcp-server DocsBot MCP servers expose 'search' for semantic/keyword retrieval and 'fetch' for full document content retrieval. ```APIDOC ## Tools Overview ### Description The DocsBot MCP server exposes the following tools for interacting with the bot's indexed sources: * `search`: Performs hybrid semantic/keyword search across the training library and returns the most relevant excerpts & ids. * `fetch`: Retrieves the full content for a specific source that was previously referenced by `search`. These tools can optionally be restricted when registering the server with a client to ensure requests stay within documented capabilities. Both operations are read-only. ``` -------------------------------- ### Get Bot Statistics - cURL Examples Source: https://docsbot.ai/documentation/developer/stats-api Examples of how to retrieve bot statistics using cURL. Demonstrates requests with relative time deltas and explicit date ranges (ISO and YYYY-MM-DD formats). Includes common relative ranges like last week, quarter, and year. ```bash curl --request GET 'https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/SQMV36O8xi43xbZRzYLy/stats?timeDelta=30' \ --header 'Authorization: Bearer YOUR_TOKEN' ``` ```bash curl --request GET 'https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/SQMV36O8xi43xbZRzYLy/stats?startDate=2024-06-01T00:00:00.000Z&endDate=2024-06-30T23:59:59.999Z' \ --header 'Authorization: Bearer YOUR_TOKEN' ``` ```bash curl --request GET 'https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/SQMV36O8xi43xbZRzYLy/stats?startDate=2024-06-01&endDate=2024-06-30' \ --header 'Authorization: Bearer YOUR_TOKEN' ``` ```bash curl --request GET 'https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/SQMV36O8xi43xbZRzYLy/stats?timeDelta=7' \ --header 'Authorization: Bearer YOUR_TOKEN' # Last week ``` ```bash curl --request GET 'https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/SQMV36O8xi43xbZRzYLy/stats?timeDelta=90' \ --header 'Authorization: Bearer YOUR_TOKEN' # Last quarter ``` ```bash curl --request GET 'https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/SQMV36O8xi43xbZRzYLy/stats?timeDelta=365' \ --header 'Authorization: Bearer YOUR_TOKEN' # Last year ``` -------------------------------- ### Initialize DocsBot with Zendesk Classic Callback Source: https://docsbot.ai/documentation/developer/widget-integrations/zendesk This JavaScript code initializes the DocsBot AI widget and configures the `supportCallback` to open the classic Zendesk Web Widget when the support link is clicked. It prevents the default URL behavior, unmounts the DocsBot widget, and then activates the Zendesk widget using `zE.activate()`. ```javascript ``` -------------------------------- ### List Sources using cURL Source: https://docsbot.ai/documentation/developer/source-api This cURL command demonstrates how to list all sources associated with a specific team and bot. It requires an authorization token and the team and bot IDs. ```bash curl --request GET 'https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/SQMV36O8xi43xbZRzYLy/sources' \ --header 'Authorization: Bearer c0f5c347f0138f76a005921ec723f38185554327f69349dcf220a6f6531ab673' ``` -------------------------------- ### Get Single Conversation - JavaScript Fetch Example Source: https://docsbot.ai/documentation/developer/conversations-api This snippet shows how to fetch a single conversation using its ID with JavaScript's Fetch API. It includes setting up headers for authentication and handling the response, including potential errors. ```javascript var myHeaders = new Headers() myHeaders.append( 'Authorization', 'Bearer YOUR_API_KEY' ) var requestOptions = { method: 'GET', headers: myHeaders, } fetch( 'https://docsbot.ai/api/teams/YOUR_TEAM_ID/bots/YOUR_BOT_ID/conversations/YOUR_CONVERSATION_ID', requestOptions ) .then((response) => response.text()) .then((result) => console.log(result)) .catch((error) => console.log('error', error)) ``` -------------------------------- ### DocsBot AI Initialization with Intercom Support Callback Source: https://docsbot.ai/documentation/developer/widget-integrations/intercom This JavaScript code demonstrates how to initialize the DocsBot AI widget and configure its `supportCallback` function to open the Intercom Messenger. When the support link is clicked, it prevents the default action, hides the DocsBot widget, and then boots and shows the Intercom Messenger. ```javascript DocsBotAI.init({ id: "YOUR_ID_HERE", supportCallback: function (event, history, metadata) { event.preventDefault(); // Prevent default behavior opening the url. DocsBotAI.unmount(); // Hide the widget. // Open the Intercom Messenger. window.Intercom('boot', { app_id: APP_ID, }); window.Intercom('show'); }, }) ``` -------------------------------- ### Streaming Chat API Response Structure Source: https://docsbot.ai/documentation/developer/streaming-chat-api This example shows the JSON structure of messages received from the DocsBot Streaming Chat API. It includes sender, message content, and message type ('start', 'stream', 'info', 'end'). The 'stream' type is sent multiple times for incremental responses. ```json { "sender": "bot", "message": "", "type": "start" } ``` -------------------------------- ### Get Bot Source: https://docsbot.ai/documentation/developer/bot-api This endpoint fetches a specific bot by its ID. It 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 `/api/teams/:teamId/bots/:botId` ### Parameters #### Path Parameters - **teamId** (string) - Required - The ID of the team the bot belongs to. - **botId** (string) - Required - The ID of the bot to retrieve. ``` -------------------------------- ### Initialize DocsBot with Zendesk Messaging Callback Source: https://docsbot.ai/documentation/developer/widget-integrations/zendesk This JavaScript code initializes the DocsBot AI widget and sets up the `supportCallback` to open the Zendesk Web Widget (messaging) when the support link is clicked. It prevents the default action, hides the DocsBot widget, and then opens the Zendesk messenger interface using `zE('messenger', 'open')`. ```javascript ``` -------------------------------- ### Get Research Job Details Source: https://docsbot.ai/documentation/developer/bot-research-api Retrieves a single research job by ID. Accepts a GET request. ```APIDOC ## GET /api/teams/:teamId/bots/:botId/research/:jobId ### Description Retrieves a single research job by ID. Accepts a GET request. ### Method GET ### Endpoint `https://docsbot.ai/api/teams/:teamId/bots/:botId/research/:jobId` ### Request Example ```curl curl --request GET 'https://docsbot.ai/api/teams/YOUR_TEAM_ID/bots/YOUR_BOT_ID/research/YOUR_JOB_ID' \ --header 'Authorization: Bearer YOUR_API_KEY' ``` ### Response #### Success Response (200) Returns the Research Job object for the specified job ID. - **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 } ``` ``` -------------------------------- ### Initialize DocsBot AI with Help Scout Beacon Callback Source: https://docsbot.ai/documentation/developer/widget-integrations/helpscout This JavaScript code initializes the DocsBot AI widget and configures a `supportCallback` function. This callback is triggered when a user requests support, preventing the default behavior, hiding the DocsBot widget, and opening the Help Scout Beacon widget. It also includes logic to prefill ticket information and pass conversation data 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 }); } }, }) ``` -------------------------------- ### Summarize Conversation API cURL Example Source: https://docsbot.ai/documentation/developer/conversation-summarize This example demonstrates how to call the Conversation Summarize API using cURL. It includes the necessary endpoint URL and authorization header. ```bash curl -X GET "https://api.docsbot.ai/teams/your-team-id/bots/your-bot-id/conversations/550e8400-e29b-41d4-a716-446655440000/summarize" \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Initialize DocsBot with Gorgias Support Callback Source: https://docsbot.ai/documentation/developer/widget-integrations/gorgias This JavaScript code initializes the DocsBot AI widget and configures a `supportCallback` function. This callback is triggered when a user requests support, allowing the integration to hide the DocsBot widget, prefill visitor information into the Gorgias widget, and open it for human assistance. It handles both cases where ticket information is available and when it's not. ```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(); } }, }) ``` -------------------------------- ### Summarize Conversation API Request Example Source: https://docsbot.ai/documentation/developer/conversation-summarize This section provides an example of the success response structure for the Conversation Summarize API. It includes the fields for 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" } ``` -------------------------------- ### Summarize Conversation API Python Requests Example Source: https://docsbot.ai/documentation/developer/conversation-summarize This example demonstrates how to use the Python requests library to call the Conversation Summarize API. It shows how to set the URL, headers, and process the JSON response. ```python import requests url = "https://api.docsbot.ai/teams/your-team-id/bots/your-bot-id/conversations/550e8400-e29b-41d4-a716-446655440000/summarize" headers = { "Authorization": "Bearer YOUR_API_KEY" } response = requests.get(url, headers=headers) summary = response.json() print(summary['title']) # Short conversation title print(summary['summary']) # Summary content print(summary['sentiment']) # positive/neutral/negative ``` -------------------------------- ### Initialize DocsBot with HubSpot Support Callback Source: https://docsbot.ai/documentation/developer/widget-integrations/hubspot This JavaScript code initializes the DocsBot widget and configures the `supportCallback` function. When the user clicks the support link in the DocsBot widget, this callback prevents the default URL behavior, hides the DocsBot widget, and then opens the HubSpot widget for live chat. ```javascript DocsBotAI.init({ id: "YOUR_ID_HERE", supportCallback: function (event, history, metadata) { event.preventDefault(); // Prevent default behavior opening the url. DocsBotAI.unmount(); // Hide the widget. // Force the widget to load in an open state window.HubSpotConversations.widget.load({ widgetOpen: true }); // Force the widget to open to a specific chat flow window.HubSpotConversations.widget.refresh({ openToNewThread: true }); }, }) ``` -------------------------------- ### Pre-fill Zoho SalesIQ Message Box with Visitor Question Source: https://docsbot.ai/documentation/developer/widget-integrations/zoho-chat Use the `$zoho.salesiq.visitor.question()` method to automatically populate the chat message box with a pre-defined question. This is useful for providing context to support agents about the user's inquiry. It requires the Zoho SalesIQ JavaScript library to be loaded. ```javascript function() { $zoho.salesiq.visitor.question("Your pre-defined question here"); }; ``` ```javascript $zoho.salesiq.ready = function() { $zoho.salesiq.visitor.question("Hey, I need assistance!"); }; ``` -------------------------------- ### Get Presigned Upload URL using cURL Source: https://docsbot.ai/documentation/developer/source-api This snippet demonstrates how to obtain a presigned URL for uploading files to cloud storage using cURL. It makes a GET request to the upload-url endpoint with a specified filename. ```shell GET https://docsbot.ai/api/teams/:teamId/bots/:botId/upload-url?fileName=FILENAME ``` -------------------------------- ### Create Source with File Upload using JavaScript Fetch Source: https://docsbot.ai/documentation/developer/source-api This script first obtains an upload URL from the DocsBot API, then uploads a local CSV file to that URL, and finally creates a new source using the uploaded file's information. It requires team ID, bot ID, and an authentication 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', }), }) }) ``` -------------------------------- ### Delete Bot API Request Examples Source: https://docsbot.ai/documentation/developer/bot-api Examples for deleting a specific bot using its ID via cURL and JavaScript Fetch API. Both methods demonstrate how to send a DELETE request to the DocsBot API endpoint, including necessary headers for authentication. ```curl curl --request DELETE 'https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/iADcTdrl7R51JiTjrWKy' \ --header 'Authorization: Bearer 2e9fd6965890e80b9a7bb271900ab859e199a5778f851b73d97136d3495849ef' ``` ```javascript var myHeaders = new Headers(); myHeaders.append("Authorization", "Bearer c0f5c347f0138f76a005921ec723f38185554327f69349dcf220a6f6531ab673"); var requestOptions = { method: 'DELETE', 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)); ``` -------------------------------- ### Embed Freshdesk Help Widget Source: https://docsbot.ai/documentation/developer/widget-integrations/freshdesk This code snippet shows the basic embed code for the Freshdesk Help Widget. It initializes the widget and includes a script to load it asynchronously. ```html ``` ```javascript // NOTE: For security reasons, API requests with authentication tokens // should be performed server-side to avoid exposing your API keys in client-side code. // The stats data should be fetched on your server and then passed to the frontend. // Assuming 'statsData' contains the API response from your server const statsData = { // This would be populated with data from your server labels: ["2023-09-01", "2023-09-02", "2023-09-03"], countData: [12, 15, 8], negativeData: [2, 1, 0], positiveData: [8, 10, 6], percentageLabels: ["Neutral", "Negative", "Positive"], counts: [120, 45, 676] }; // Create line chart function createLineChart(stats) { const ctx = document.getElementById('lineChart').getContext('2d'); const lineData = { labels: stats.labels, datasets: [ { label: 'All Messages', data: stats.countData, borderColor: '#76B7B2', backgroundColor: 'rgba(118, 183, 178, 0.1)', tension: 0.3, fill: true, }, { label: 'Rated Negative', data: stats.negativeData, borderColor: '#E15759', backgroundColor: 'rgba(225, 87, 89, 0.1)', tension: 0.3, fill: true, }, { label: 'Rated Positive', data: stats.positiveData, borderColor: '#59A14F', backgroundColor: 'rgba(0, 204, 102, 0.1)', tension: 0.3, fill: true, }, ], }; new Chart(ctx, { type: 'line', data: lineData, options: { maintainAspectRatio: false, responsive: true } }); } // Create pie chart function createPieChart(stats) { const ctx = document.getElementById('pieChart').getContext('2d'); const pieData = { labels: stats.percentageLabels, datasets: [ { data: stats.counts, backgroundColor: ['#76B7B2', '#E15759', '#59A14F'], }, ], }; new Chart(ctx, { type: 'pie', data: pieData, options: { maintainAspectRatio: false, responsive: true } }); } // Initialize charts when the page loads document.addEventListener('DOMContentLoaded', function() { createLineChart(statsData); createPieChart(statsData); }); ``` -------------------------------- ### Get Research Job Details - JavaScript Fetch Source: https://docsbot.ai/documentation/developer/bot-research-api This JavaScript code snippet demonstrates how to fetch the details of a single research job using the Fetch API. It configures the request with authentication headers and sends a GET request to the specific job's endpoint. Error handling is included. ```javascript var myHeaders = new Headers() myHeaders.append('Authorization', 'Bearer YOUR_API_KEY') var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow', } fetch( 'https://docsbot.ai/api/teams/YOUR_TEAM_ID/bots/YOUR_BOT_ID/research/YOUR_JOB_ID', requestOptions ) .then((response) => response.text()) .then((result) => console.log(result)) .catch((error) => console.log('error', error)) ``` -------------------------------- ### Get Source Source: https://docsbot.ai/documentation/developer/source-api Fetches a specific source by its ID, returning the full source object. ```APIDOC ## GET /api/teams/:teamId/bots/:botId/sources/:sourceId ### Description Fetches a specific source by its ID. This will return the full source object unlike listing. It accepts a GET request. ### Method GET ### Endpoint `https://docsbot.ai/api/teams/:teamId/bots/:botId/sources/:sourceId` ### Parameters #### Path Parameters - **teamId** (string) - Required - The ID of the team. - **botId** (string) - Required - The ID of the bot. - **sourceId** (string) - Required - The ID of the source to retrieve. ### Request Example #### cURL ```curl curl --request GET 'https://docsbot.ai/api/teams/FOX1XkWo8VMx3hp6Zjkb/bots/SQMV36O8xi43xbZRzYLy/sources/qGDSDhbdxtqmifTZQrYs' \ --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/SQMV36O8xi43xbZRzYLy/sources/qGDSDhbdxtqmifTZQrYs', requestOptions, ) .then((response) => response.text()) .then((result) => console.log(result)) .catch((error) => console.log('error', error)) ``` ### Response #### Success Response (200) Returns the full source object. #### Response Example ```json { "id": "qGDSDhbdxtqmifTZQrYs", "type": "url", "status": "ready", "title": "Infinite Uploads – Offload Media and Video to Cloud Storage – WordPress plugin | WordPress.org", "url": "https://wordpress.org/plugins/infinite-uploads/", "createdAt": "2023-03-09T22:07:24.442Z", "pageCount": 3, "chunkCount": 10, "scheduleInterval": "none", "faqs": null, "indexedUrls": [], "warnsList": [], "carbonFiles": null } ``` ```