# Table of Contents - [Twilio Alpha | Twilio](#twilio-alpha-twilio) - [AI Constellations | Twilio](#ai-constellations-twilio) - [AI Assistants Overview | Twilio](#ai-assistants-overview-twilio) - [Docs: API Reference, Tutorials, and Integration | Twilio](#docs-api-reference-tutorials-and-integration-twilio) - [Assistant Knowledge Resource | Twilio](#assistant-knowledge-resource-twilio) - [Messages Resource | Twilio](#messages-resource-twilio) - [Assistants Resource | Twilio](#assistants-resource-twilio) - [Conversation History | Twilio](#conversation-history-twilio) - [Assistant Tools Resource | Twilio](#assistant-tools-resource-twilio) - [Feedback Resource | Twilio](#feedback-resource-twilio) - [Knowledge Chunk Resource | Twilio](#knowledge-chunk-resource-twilio) - [Knowledge Resource | Twilio](#knowledge-resource-twilio) - [Policies Resource | Twilio](#policies-resource-twilio) - [Sessions Resource | Twilio](#sessions-resource-twilio) - [Tools Resource | Twilio](#tools-resource-twilio) - [Channels | Twilio](#channels-twilio) - [Use Twilio Conversations as a Channel | Twilio](#use-twilio-conversations-as-a-channel-twilio) - [Use Twilio Messaging as a Channel | Twilio](#use-twilio-messaging-as-a-channel-twilio) - [AI Assistant Code Samples | Twilio](#ai-assistant-code-samples-twilio) - [Connect your AI Assistant to Twilio Conversations with React | Twilio](#connect-your-ai-assistant-to-twilio-conversations-with-react-twilio) - [Transition to Twilio Flex | Twilio](#transition-to-twilio-flex-twilio) - [Transition to Twilio Studio | Twilio](#transition-to-twilio-studio-twilio) - [Customer Memory | Twilio](#customer-memory-twilio) - [FAQs and Troubleshooting | Twilio](#faqs-and-troubleshooting-twilio) - [Knowledge | Twilio](#knowledge-twilio) - [How to Track Human Feedback | Twilio](#how-to-track-human-feedback-twilio) --- # Twilio Alpha | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page Twilio Alpha ============ Positive FeedbackNegative Feedback * * * Twilio Alpha is a program to investigate the future of customer engagement by leveraging the power of the full Twilio platform, artificial intelligence, and other emerging technologies. Here, you can explore and get access to tools based on this program's research. * * * AI Assistants ------------- [ai-assistants page anchor](#ai-assistants) Positive FeedbackNegative Feedback Twilio AI Assistants are an opinionated framework to build and host conversational AI Assistants for your customer-facing use cases. AI Assistants are built on top of various Large Language Models (LLMs), including models from OpenAI amongst others, and are in continuous development following the latest advancements in AI. (warning) Twilio Alpha - Developer Preview -------------------------------- AI Assistants is a [Twilio Alpha(link takes you to an external page)](https://twilioalpha.com "Twilio Alpha") project that's in **Developer Preview**. View the [current limitations](/docs/alpha/ai-assistants/pricing-and-limits "current limitations") for details about feature limits during developer preview. To get starting building an Assistant, visit the [AI Assistants Overview](/docs/alpha/ai-assistants "AI Assistants Overview") . * * * Learn more about Twilio Alpha's projects ---------------------------------------- [learn-more-about-twilio-alphas-projects page anchor](#learn-more-about-twilio-alphas-projects) Positive FeedbackNegative Feedback Check out the [Twilio Alpha page(link takes you to an external page)](https://www.twilioalpha.com/ "Twilio Alpha page") to see all of the past and current Alpha projects. If you have any questions or feedback, please email [twilioalpha@twilio.com](mailto:twilioalpha@twilio.com "twilioalpha@twilio.com") . --- # AI Constellations | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page AI Constellations ================= Positive FeedbackNegative Feedback * * * AI Constellations define which AI models and prompt strategies your AI Assistant will use. They allow you to select from different model types—such as v1-base or v0.5-base—to choose the appropriate LLM provider and logic that best fits your application's needs. Constellations allow your Assistant to leverage a number of available agents to best meet your application's specific needs. * * * Constellation model types ------------------------- [constellation-model-types page anchor](#constellation-model-types) Positive FeedbackNegative Feedback **v1-base:** An updated Constellation featuring significant improvements in speed, cost, and task completion rates. The underlying model supporting this Constellation is gpt-4o. **v0.5-base:** _\[Deprecated\]_ The original Constellation designed for early testers, featuring a single agent. While it can solve tasks using Tools and Knowledge, it lacks the efficiency of newer Constellations. The underlying model supporting this Constellation is gpt4. * * * Use AI Constellations --------------------- [use-ai-constellations page anchor](#use-ai-constellations) Positive FeedbackNegative Feedback From any **AI Assistant's properties tab** in the Twilio Console, select an AI Constellation from the AI Constellation dropdown. --- # AI Assistants Overview | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page AI Assistants Overview ====================== Positive FeedbackNegative Feedback * * * (warning) Twilio Alpha - Developer Preview -------------------------------- AI Assistants is a [Twilio Alpha(link takes you to an external page)](https://twilioalpha.com "Twilio Alpha") project that's in **Developer Preview**. View the [current limitations](/docs/alpha/ai-assistants/pricing-and-limits "current limitations") for details about feature limits during developer preview. Twilio AI Assistants is an opinionated framework to build and host conversational AI Assistants for your customer-facing use cases. Built on large language models (LLMs) like OpenAI's GPT-4, Assistants can handle complex interactions, providing personalized and dynamic responses based on customer data. * * * Core components --------------- [core-components page anchor](#core-components) Positive FeedbackNegative Feedback * [**Customer Memory**](/docs/alpha/ai-assistants/customer-memory) : During conversations, Assistants create a customer profile that can be augmented, referenced, and built upon in future interactions using Twilio Segment. This allows for a more personalized and consistent customer experience. * [**Tools**](/docs/alpha/ai-assistants/tools) : Assistants can interact with other systems by making API requests through interfaces that you define. This enables seamless integration with external services and databases, extending the functionality of your AI Assistant. * [**Knowledge sources**](/docs/alpha/ai-assistants/knowledge) : Your Assistant can access and use unstructured knowledge sources, such as websites and databases, to provide additional context and answer user questions more effectively. * [**Channels**](/docs/alpha/ai-assistants/channels) : Assistants can integrate with various communication channels, allowing you to deploy your Assistant where your customers are most active. * [**Simulator**](/docs/alpha/ai-assistants/simulator) : The Simulator is a sandbox that allows you to interact with your AI Assistant via the Twilio Console for testing, demo, and debugging purposes. * [**Human feedback**](/docs/alpha/ai-assistants/guides/feedback) : You can track human feedback on Assistant responses via the Simulator and the API. * **Guardrails and Monitoring**: Twilio AI Assistants include robust safeguards like prompt injection detection rules, and content moderation. These features ensure the trustworthiness and observability of each interaction, protecting both the user experience and your brand integrity. Twilio AI Assistants are built on top of various Large Language Models (LLMs), including models from OpenAI and others, providing a powerful foundation for natural and dynamic conversations. * * * Getting started --------------- [getting-started page anchor](#getting-started) Positive FeedbackNegative Feedback Explore the core features of Twilio AI Assistants in the sections that follow, or dive right in with our [Quickstart Guide](/docs/alpha/ai-assistants/quickstart "Quickstart Guide") to build your first Assistant. ### Base configuration [base-configuration page anchor](#base-configuration) Positive FeedbackNegative Feedback Assistants are highly configurable, enabling you to customize their behavior, personality, and functionality to align with your brand and specific use cases. Setting up an AI Assistant involves configuring several components that define its identity: * **Name**: The name you assign to your AI Assistant is for identification within the Twilio Console UI. If you want your Assistant to refer to itself by name during interactions, ensure you include it in the personality prompt. * **AI Constellation**: AI Constellations define what AI models and prompt strategies your AI Assistant will use. [Learn more about AI Constellations.](/docs/alpha/ai-assistants/ai-constellations "Learn more about AI Constellations.") * **Personality prompt**: This prompt sets the tone, voice, and purpose of your AI Assistant. It should be concise and aligned with your brand's voice, offering a high-level overview of what the Assistant should do. You can also define rules for your Assistant in the personality prompt like: "Never talk about competitors". Avoid overly detailed instructions; instead, focus on creating a framework that guides the Assistant's interactions. Best practices include: * Clear and concise language to avoid ambiguity. * Alignment with your brand's voice and the Assistant's intended persona. * Prompts that encourage user engagement, such as open-ended questions or choices for further exploration. * **Customer Memory**: Twilio AI Assistants can be enhanced by integrating with Twilio's Segment Profiles, making them "customer aware." This integration uses data from Twilio Segment to personalize interactions more effectively. It includes: * [**AI Personalization Engine**(link takes you to an external page)](https://twilioalpha.com/personalization-engine) : Leverages customer data from Segment to tailor responses and solve problems more efficiently. * [**AI Perception Engine**(link takes you to an external page)](https://twilioalpha.com/perception-engine) : Captures data from conversations and updates the Segment profile, allowing the Assistant to improve over time. * * * Best practices -------------- [best-practices page anchor](#best-practices) Positive FeedbackNegative Feedback * **Clarity and consistency**: Ensure that all configuration settings are clear and consistent with your brand's objectives. * **Data-driven personalization**: Leverage Customer Memory to make your Assistant more responsive and personalized based on real-time customer data. * **Ongoing optimization**: Regularly review and update your Assistant's configuration to adapt to changing customer needs and new model capabilities. --- # Docs: API Reference, Tutorials, and Integration | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search Twilio Docs =========== Build better and engage your customers across all channels with our API reference documentation, quickstarts, SDKs and multi-language code samples. --------------------------------------------------------------------------------------------------------------------------------------------------- [Discover our featured content](/docs#featured-content) [Get started with Twilio essentials](/docs#twilio-essentials) [Start building with our developer toolkit](/docs#developer-toolkit) Explore Documentation by... --------------------------- Product category Use case [Communications](#communications) * * * [Customer Data](#customer-data) * * * [Engagement applications](#engagement-applications) ### Communications Twilio SendGrid Documentation [SendGrid Email](/docs/sendgrid) Reach customers with Twilio's Email API and scalable marketing tools for all the email that you send. Twilio Messaging Documentation [Messaging](/docs/messaging) Send and receive SMS/MMS and WhatsApp messages using the programming languages you already know and love. Twilio Voice Documentation [Voice](/docs/voice) Build unique phone call experiences with one API to make, receive, control, and monitor calls around the globe. Twilio Elastic SIP Trunking Documentation [Elastic SIP Trunking](/docs/sip-trunking) Instantly achieve global connectivity for VoIP infrastructure using our SIP trunking service. Twilio Phone Numbers Documentation [Phone Numbers](/docs/phone-numbers) Purchase Toll-free, 10-digit long code (10DLC), short codes, and Alphanumeric Sender IDs to deliver your communications. Twilio Event Streams Documentation [Event Streams](/docs/events) Configure a centralized stream of Twilio event data that you can send to any team. Twilio TrustHub Documentation [Trust Hub](/docs/trust-hub) Create a Twilio identity and unlock services such as SHAKEN/STIR, A2P Messaging, and Branded Calls. Twilio WhatsApp Business Platform Documentation [WhatsApp](/docs/whatsapp) Reach users on the world's most popular messaging app through one streamlined API, officially supported by WhatsApp. Twilio Verify Documentation [Verify](/docs/verify) Quickly verify phone number ownership via SMS or Voice, reduce fraudulent accounts, and speed up account onboarding. Twilio Lookup Documentation [Lookup](/docs/lookup) Determine local-friendly number formats, phone types, fraud risk, and more, through mobile-based authoritative signals. Twilio Conversations Documentation [Conversations](/docs/conversations) Build conversational messaging across Chat, SMS, WhatsApp, and more with a single API. Twilio Video Documentation [Video](/docs/video) Add video chat functionality to your web, iOS, and Android applications. ### Customer data Twilio Segment Documentation [Segment](https://segment.com/docs) Collect, responsibly manage, and integrate your customer data with hundreds of tools. Twilio Voice Intelligence Documentation [Voice Intelligence](/docs/voice/intelligence) Identify important signals from unstructured dataCall transcription and AI-powered language operators. ### Engagement applications Twilio Engage Documentation [Twilio Engage](https://segment.com/docs/engage) Personalize omnichannel campaigns on a unified, data-first platform. Twilio Flex Documentation [Twilio Flex](/docs/flex) Build digital engagement for your contact center, sales conversations, and personalized support. Twilio SendGrid Marketing Campaigns Documentation [Marketing Campaigns](/docs/sendgrid/ui/sending-email/how-to-send-email-with-marketing-campaigns) Design and send engaging emails at scale with our suite of email marketing tools. Featured content ---------------- Dive into our handpicked selection of developer-focused content. [One-time password (OTP)\ \ ### Create your first verification\ \ Quickly verify users via SMS, Passkeys, Silent Network Auth, Voice, WhatsApp, TOTP, Push, Silent Device Approval, and Email.](/docs/verify/quickstarts) [Fraud prevention\ \ ### Format and validate phone numbers\ \ Format and validate phone numbers to increase deliverability. Add on data packages to get even more in-depth carrier and caller information.](/docs/lookup/quickstart) Twilio Essentials ----------------- [General Usage](/docs/usage) Learn how to interact with the REST API for account management, development testing, and fraud protection. [IAM](/docs/iam) Manage your projects, securely authenticate REST API requests, and learn best practices for accessing Twilio's resources. [Global Infrastructure](/docs/global-infrastructure) Control where your application's Twilio-related data is routed, processed, and stored. [Helper Libraries](/docs/libraries) Familiarize yourself with Twilio's server-side, front-end, and mobile SDKs, OpenAPI specifications and Postman collections. [Phone numbers](/docs/phone-numbers) Purchase Toll-free, 10-digit long code (10DLC), short codes, and Alphanumeric Sender IDs to deliver your communications. [Regulatory & Compliance](https://www.twilio.com/en-us/guidelines) Compiled resources to help ensure you're communicating effectively and compliantly around the world. Developer Toolkit ----------------- Explore essential tools, resources, and community links, all designed to help elevate your project and keep you informed. Tools ----- [Code Exchange](https://www.twilio.com/code-exchange) Get started and build faster with usable code samples for common Twilio use cases. [Functions](/docs/serverless/functions-assets) A serverless environment to quickly create production-grade, event-driven Twilio applications. [Marketplace](/docs/marketplace) Seamlessly integrate third-party's partner technology into your Twilio applications. [OpenAPI](/docs/openapi) Integrate our API with community tools for mocking, testing, generating libraries, Postman integrations, and more. [Serverless](/docs/serverless) Quickly build and deploy communication apps with no servers to spin up or infrastructure to maintain. [Studio](/docs/studio) A drag-and-drop builder to create communication workflows. [TwiML Bins](/docs/serverless/twiml-bins) Provide Twilio-hosted instructions to your Twilio applications. [Twilio CLI](/docs/twilio-cli) Manage your Twilio resources from your terminal or command prompt. Resources --------- [API status](https://status.twilio.com/) Check real time monitoring of APIs and all services. [Changelog](https://www.twilio.com/en-us/changelog) See updates and additions to Twilio products. [Error codes](/docs/api/errors) Full list of all possible Twilio REST API error codes. [Glossary](/docs/glossary) Understand our key terms and concepts. Community --------- [Blog](https://www.twilio.com/en-us/blog) Read tutorials, community projects and product updates. [Champions](https://www.twilio.com/en-us/champions) Become a Twilio community champion. [Developer Events](https://www.twilio.com/en-us/events) Join upcoming group events. [Stack Overflow](https://stackoverflow.com/collectives/twilio) Ask the Twilio community for help. Twilio is the trusted platform for data-driven customer engagement across any channel. -------------------------------------------------------------------------------------- ![Twilio logo](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftwilio.55e79a90.webp&w=384&q=75&dpl=dpl_ATAJdnvkBtxiXJHhvv9SRHz4BYqq)![Twilio Segment logo](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fsegment.ac406c91.webp&w=384&q=75&dpl=dpl_ATAJdnvkBtxiXJHhvv9SRHz4BYqq)![Twilio Sendgrid logo](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fsendgrid.f1a831e1.webp&w=384&q=75&dpl=dpl_ATAJdnvkBtxiXJHhvv9SRHz4BYqq) --- # Assistant Knowledge Resource | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page Assistant Knowledge Resource ============================ Positive FeedbackNegative Feedback * * * Manage Knowledge sources connected to an Assistant * * * Knowledge Properties -------------------- [knowledge-properties page anchor](#knowledge-properties) Positive FeedbackNegative Feedback Property nameTypeRequiredDescriptionChild properties descriptionstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The type of knowledge source. * * * idstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The description of knowledge. Pattern: `^aia_know_*$` * * * account\_sidSID Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The SID of the [Account](/docs/iam/api/account "Account") that created the Knowledge resource. Pattern: `^AC[0-9a-fA-F]{32}$`Min length: `34`Max length: `34` * * * knowledge\_source\_detailsobject Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The details of the knowledge source based on the type. * * * namestring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The name of the knowledge source. * * * statusstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED') * * * typestring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The type of knowledge source ('Web', 'Database', 'Text', 'File') * * * urlstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The url of the knowledge resource. * * * date\_createdstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Knowledge was created specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * date\_updatedstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Knowledge was last updated specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * List all Knowledge sources connected to an Assistant ---------------------------------------------------- [list-all-knowledge-sources-connected-to-an-assistant page anchor](#list-all-knowledge-sources-connected-to-an-assistant) Positive FeedbackNegative Feedback `GET https://assistants.twilio.com/v1/Assistants/{assistantId}/Knowledge` ### Path parameters [path-parameters page anchor](#path-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription assistantIdstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The assistant ID. ### Query parameters [query-parameters page anchor](#query-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription Pageinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page index. This value is simply for client state. Minimum: `0` * * * PageSizeinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) How many resources to return in each list page. The default is 50, and the maximum is 1000. Minimum: `1`Maximum: `1000` * * * PageTokenstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page token. This is provided by the API. List Knowledge sources connected to an Assistant[Link to code sample: List Knowledge sources connected to an Assistant](#code-list-knowledge-sources-connected-to-an-assistant) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function listKnowledgeByAssistant() { 11 const assistantsKnowledges \= await client.assistants.v1 12 .assistants("aia\_asst\_00000000-1111-2222-3333-444444444444") 13 .assistantsKnowledge.list({ limit: 20 }); 14 15 assistantsKnowledges.forEach((a) \=> console.log(a.description)); 16 } 17 18 listKnowledgeByAssistant(); ### Output Copy output 1 { 2 "knowledge": \[\ \ 3\ \ {\ \ 4\ \ "description": "description",\ \ 5\ \ "id": "aia\_know",\ \ 6\ \ "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 7\ \ "knowledge\_source\_details": {},\ \ 8\ \ "name": "name",\ \ 9\ \ "status": "status",\ \ 10\ \ "type": "type",\ \ 11\ \ "url": "url",\ \ 12\ \ "date\_created": "2009-07-06T20:30:00Z",\ \ 13\ \ "date\_updated": "2009-07-06T20:30:00Z"\ \ 14\ \ }\ \ 15\ \ \], 16 "meta": { 17 "first\_page\_url": "https://www.example.com", 18 "key": "key", 19 "next\_page\_url": "https://www.example.com", 20 "page": 42, 21 "page\_size": 42, 22 "previous\_page\_url": "https://www.example.com", 23 "url": "https://www.example.com" 24 } 25 } * * * Connect a Knowledge source to an Assistant ------------------------------------------ [connect-a-knowledge-source-to-an-assistant page anchor](#connect-a-knowledge-source-to-an-assistant) Positive FeedbackNegative Feedback `POST https://assistants.twilio.com/v1/Assistants/{assistantId}/Knowledge/{id}` After you've [**created a Knowledge source**](/docs/alpha/ai-assistants/api/knowledge#create-new-knowledge-sources) using the `/v1/Knowledge` endpoint, you must connect it to an Assistant to allow that Assistant to use the Knowledge. ### Path parameters [path-parameters-1 page anchor](#path-parameters-1) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription assistantIdstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The assistant ID. * * * idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The knowledge ID. Connect a Knowledge source to an Assistant[Link to code sample: Connect a Knowledge source to an Assistant](#code-connect-a-knowledge-source-to-an-assistant) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function createAssistantKnowledgeAttachment() { 11 const assistantsKnowledge \= await client.assistants.v1 12 .assistants("aia\_asst\_00000000-1111-2222-3333-444444444444") 13 .assistantsKnowledge("aia\_knowledge") 14 .create(); 15 16 console.log(assistantsKnowledge.sid); 17 } 18 19 createAssistantKnowledgeAttachment(); * * * Detach a Knowledge source from an Assistant ------------------------------------------- [detach-a-knowledge-source-from-an-assistant page anchor](#detach-a-knowledge-source-from-an-assistant) Positive FeedbackNegative Feedback `DELETE https://assistants.twilio.com/v1/Assistants/{assistantId}/Knowledge/{id}` This endpoint removes a Knowledge source from your Assistant's configuration, so it can no longer be used by that Assistant. ### Path parameters [path-parameters-2 page anchor](#path-parameters-2) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription assistantIdstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The assistant ID. * * * idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The knowledge ID. Detach a Knowledge source from an Assistant[Link to code sample: Detach a Knowledge source from an Assistant](#code-detach-a-knowledge-source-from-an-assistant) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function deleteAssistantKnowledgeAttachment() { 11 await client.assistants.v1 12 .assistants("aia\_asst\_00000000-1111-2222-3333-444444444444") 13 .assistantsKnowledge("aia\_knowledge") 14 .remove(); 15 } 16 17 deleteAssistantKnowledgeAttachment(); --- # Messages Resource | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page Messages Resource ================= Positive FeedbackNegative Feedback * * * Send a message to an Assistant * * * Message Properties ------------------ [message-properties page anchor](#message-properties) Positive FeedbackNegative Feedback Property nameTypeRequiredDescriptionChild properties statusstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) success or failure based on whether the request successfully generated a response. * * * flaggedboolean Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) If successful, this property will denote whether the response was flagged or not. * * * abortedboolean Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) This property will denote whether the request was aborted or not. * * * session\_idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The unique name for the session. * * * account\_sidSIDrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The SID of the [Account](/docs/iam/api/account "Account") that sent the Message. Pattern: `^AC[0-9a-fA-F]{32}$`Min length: `34`Max length: `34` * * * bodystring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) If successful, the body of the generated response * * * errorstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The error message if generation was not successful * * * Send a message to the Assistant ------------------------------- [send-a-message-to-the-assistant page anchor](#send-a-message-to-the-assistant) Positive FeedbackNegative Feedback `POST https://assistants.twilio.com/v1/Assistants/{id}/Messages` ### Path parameters [path-parameters page anchor](#path-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) the Assistant ID. ### Request body parameters [request-body-parameters page anchor](#request-body-parameters) Positive FeedbackNegative Feedback Encoding type:`application/json` Schema Property nameTypeRequiredDescriptionChild properties identitystringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The unique identity of user for the session. * * * session\_idstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The unique name for the session. * * * bodystringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The query to ask the assistant. * * * webhookstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The webhook url to call after the assistant has generated a response or report an error. * * * modestring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) one of the modes 'chat', 'email' or 'voice' Default: `chat` Send a message to the Assistant[Link to code sample: Send a message to the Assistant](#code-send-a-message-to-the-assistant) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function createMessage() { 11 const message \= await client.assistants.v1 12 .assistants("aia\_asst\_00000000-1111-2222-3333-444444444444") 13 .messages.create({ 14 identity: "email:test@api.com", 15 body: "When was Twilio founded?", 16 }); 17 18 console.log(message.status); 19 } 20 21 createMessage(); ### Output Copy output 1 { 2 "aborted": false, 3 "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 4 "body": "This will be the body of the new message!", 5 "error": "error", 6 "flagged": false, 7 "session\_id": "session\_id", 8 "status": "status" 9 } --- # Assistants Resource | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page Assistants Resource =================== Positive FeedbackNegative Feedback * * * Create and configure [**Assistants**](/docs/alpha/ai-assistants) programatically using the REST API. * * * Assistant Properties -------------------- [assistant-properties page anchor](#assistant-properties) Positive FeedbackNegative Feedback Property nameTypeRequiredDescriptionChild properties account\_sidSIDrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The SID of the [Account](/docs/iam/api/account "Account") that created the Assistant resource. Pattern: `^AC[0-9a-fA-F]{32}$`Min length: `34`Max length: `34` * * * customer\_aiobjectrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Personalization and Perception Engine settings. * * * idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Assistant ID. Pattern: `^aia_asst_*$` * * * modelstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The default model used by the assistant. * * * namestringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The name of the assistant. * * * ownerstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The owner/company of the assistant. * * * urlstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The url of the assistant resource. * * * personality\_promptstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The personality prompt to be used for assistant. * * * date\_createdstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Assistant was created specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * date\_updatedstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Assistant was last updated specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * Create an Assistant ------------------- [create-an-assistant page anchor](#create-an-assistant) Positive FeedbackNegative Feedback `POST https://assistants.twilio.com/v1/Assistants` ### Request body parameters [request-body-parameters page anchor](#request-body-parameters) Positive FeedbackNegative Feedback Encoding type:`application/json` Schema Property nameTypeRequiredDescriptionChild properties customer\_aiobject Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Personalization and Perception Engine settings. Show child properties for customer\_ai Property nameTypeRequiredDescriptionChild properties perception\_engine\_enabledbooleanrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) True if the perception engine is enabled. * * * personalization\_engine\_enabledbooleanrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) True if the personalization engine is enabled. * * * namestringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The name of the assistant. * * * ownerstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The owner/company of the assistant. * * * personality\_promptstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The personality prompt to be used for assistant. * * * segment\_credentialobject Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Segment Credentials to be used for the assistant. Show child properties for segment\_credential Property nameTypeRequiredDescriptionChild properties profile\_api\_keystring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The profile API key. * * * space\_idstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The space ID. * * * write\_keystring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The write key. Create an Assistant[Link to code sample: Create an Assistant](#code-create-an-assistant) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function createAssistant() { 11 const assistant \= await client.assistants.v1.assistants.create({ 12 name: "Your first Assistant", 13 personality\_prompt: "You are a helpful assistant.", 14 }); 15 16 console.log(assistant.accountSid); 17 } 18 19 createAssistant(); ### Output Copy output 1 { 2 "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3 "customer\_ai": {}, 4 "date\_created": "2009-07-06T20:30:00Z", 5 "date\_updated": "2009-07-06T20:30:00Z", 6 "id": "aia\_asst", 7 "model": "model", 8 "name": "name", 9 "owner": "owner", 10 "personality\_prompt": "personality\_prompt", 11 "url": "url" 12 } * * * Get an Assistant ---------------- [get-an-assistant page anchor](#get-an-assistant) Positive FeedbackNegative Feedback `GET https://assistants.twilio.com/v1/Assistants/{id}` ### Path parameters [path-parameters page anchor](#path-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) Get an Assistant[Link to code sample: Get an Assistant](#code-get-an-assistant) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function fetchAssistant() { 11 const assistant \= await client.assistants.v1 12 .assistants("aia\_asst\_00000000-1111-2222-3333-444444444444") 13 .fetch(); 14 15 console.log(assistant.accountSid); 16 } 17 18 fetchAssistant(); ### Output Copy output 1 { 2 "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3 "customer\_ai": {}, 4 "date\_created": "2009-07-06T20:30:00Z", 5 "date\_updated": "2009-07-06T20:30:00Z", 6 "id": "aia\_asst\_00000000-1111-2222-3333-444444444444", 7 "knowledge": \[\ \ 8\ \ {\ \ 9\ \ "description": "description",\ \ 10\ \ "id": "aia\_know",\ \ 11\ \ "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 12\ \ "knowledge\_source\_details": {},\ \ 13\ \ "name": "name",\ \ 14\ \ "status": "status",\ \ 15\ \ "type": "type",\ \ 16\ \ "url": "url",\ \ 17\ \ "date\_created": "2009-07-06T20:30:00Z",\ \ 18\ \ "date\_updated": "2009-07-06T20:30:00Z"\ \ 19\ \ }\ \ 20\ \ \], 21 "model": "model", 22 "name": "name", 23 "owner": "owner", 24 "personality\_prompt": "personality\_prompt", 25 "tools": \[\ \ 26\ \ {\ \ 27\ \ "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 28\ \ "description": "description",\ \ 29\ \ "enabled": false,\ \ 30\ \ "id": "aia\_tool",\ \ 31\ \ "meta": {},\ \ 32\ \ "name": "name",\ \ 33\ \ "requires\_auth": false,\ \ 34\ \ "type": "type",\ \ 35\ \ "url": "url",\ \ 36\ \ "date\_created": "2009-07-06T20:30:00Z",\ \ 37\ \ "date\_updated": "2009-07-06T20:30:00Z"\ \ 38\ \ }\ \ 39\ \ \], 40 "url": "url" 41 } * * * List Assistants --------------- [list-assistants page anchor](#list-assistants) Positive FeedbackNegative Feedback `GET https://assistants.twilio.com/v1/Assistants` ### Query parameters [query-parameters page anchor](#query-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription Pageinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page index. This value is simply for client state. Minimum: `0` * * * PageSizeinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) How many resources to return in each list page. The default is 50, and the maximum is 1000. Minimum: `1`Maximum: `1000` * * * PageTokenstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page token. This is provided by the API. List Assistants[Link to code sample: List Assistants](#code-list-assistants) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function listAssistants() { 11 const assistants \= await client.assistants.v1.assistants.list({ limit: 20 }); 12 13 assistants.forEach((a) \=> console.log(a.accountSid)); 14 } 15 16 listAssistants(); ### Output Copy output 1 { 2 "assistants": \[\ \ 3\ \ {\ \ 4\ \ "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 5\ \ "customer\_ai": {},\ \ 6\ \ "id": "aia\_asst",\ \ 7\ \ "model": "model",\ \ 8\ \ "name": "name",\ \ 9\ \ "owner": "owner",\ \ 10\ \ "url": "url",\ \ 11\ \ "personality\_prompt": "personality\_prompt",\ \ 12\ \ "date\_created": "2009-07-06T20:30:00Z",\ \ 13\ \ "date\_updated": "2009-07-06T20:30:00Z"\ \ 14\ \ }\ \ 15\ \ \], 16 "meta": { 17 "first\_page\_url": "https://www.example.com", 18 "key": "key", 19 "next\_page\_url": "https://www.example.com", 20 "page": 42, 21 "page\_size": 42, 22 "previous\_page\_url": "https://www.example.com", 23 "url": "https://www.example.com" 24 } 25 } * * * Delete an Assistant ------------------- [delete-an-assistant page anchor](#delete-an-assistant) Positive FeedbackNegative Feedback `DELETE https://assistants.twilio.com/v1/Assistants/{id}` ### Path parameters [path-parameters-1 page anchor](#path-parameters-1) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) Delete an Assistant[Link to code sample: Delete an Assistant](#code-delete-an-assistant) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function deleteAssistant() { 11 await client.assistants.v1 12 .assistants("aia\_asst\_00000000-1111-2222-3333-444444444444") 13 .remove(); 14 } 15 16 deleteAssistant(); --- # Conversation History | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page Conversation History ==================== Positive FeedbackNegative Feedback * * * This API returns the **Conversation History** for a given session. Conversation History contains a list of all Messages (both user and Assistant-generated) as well as Tool and Knowledge calls from the provided session. The API returns Tool and Knowledge calls as Messages, where the `role` property is either `tool` or `knowledge`, respectively. * * * Message Properties ------------------ [message-properties page anchor](#message-properties) Positive FeedbackNegative Feedback Property nameTypeRequiredDescriptionChild properties idstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The message ID. Pattern: `^aia_msg_*$` * * * account\_sidSID Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The SID of the [Account](/docs/iam/api/account "Account") that created the Message resource. Pattern: `^AC[0-9a-fA-F]{32}$`Min length: `34`Max length: `34` * * * assistant\_idstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Assistant ID. Pattern: `^aia_asst_*$` * * * session\_idstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Session ID. * * * identitystring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The identity of the user. * * * rolestring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The role of the user associated with the message. * * * contentobject Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The content of the message. * * * metaobject Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The metadata of the message. * * * date\_createdstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Message was created specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * date\_updatedstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Message was last updated specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * Get Conversation History ------------------------ [get-conversation-history page anchor](#get-conversation-history) Positive FeedbackNegative Feedback `GET https://assistants.twilio.com/v1/Sessions/{sessionId}/Messages` ### Path parameters [path-parameters page anchor](#path-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription sessionIdstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) Session id or name ### Query parameters [query-parameters page anchor](#query-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription Pageinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page index. This value is simply for client state. Minimum: `0` * * * PageSizeinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) How many resources to return in each list page. The default is 50, and the maximum is 1000. Minimum: `1`Maximum: `1000` * * * PageTokenstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page token. This is provided by the API. Get Conversation History[Link to code sample: Get Conversation History](#code-get-conversation-history) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function listMessages() { 11 const messages \= await client.assistants.v1 12 .sessions("your-session-id") 13 .messages.list({ limit: 20 }); 14 15 messages.forEach((m) \=> console.log(m.id)); 16 } 17 18 listMessages(); ### Output Copy output 1 { 2 "messages": \[\ \ 3\ \ {\ \ 4\ \ "id": "aia\_msg",\ \ 5\ \ "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 6\ \ "assistant\_id": "aia\_asst",\ \ 7\ \ "session\_id": "session\_id",\ \ 8\ \ "identity": "identity",\ \ 9\ \ "role": "role",\ \ 10\ \ "content": {},\ \ 11\ \ "meta": {},\ \ 12\ \ "date\_created": "2009-07-06T20:30:00Z",\ \ 13\ \ "date\_updated": "2009-07-06T20:30:00Z"\ \ 14\ \ }\ \ 15\ \ \], 16 "meta": { 17 "first\_page\_url": "https://www.example.com", 18 "key": "key", 19 "next\_page\_url": "https://www.example.com", 20 "page": 42, 21 "page\_size": 42, 22 "previous\_page\_url": "https://www.example.com", 23 "url": "https://www.example.com" 24 } 25 } --- # Assistant Tools Resource | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page Assistant Tools Resource ======================== Positive FeedbackNegative Feedback * * * Manage Tools connected to an Assistant * * * Tool Properties --------------- [tool-properties page anchor](#tool-properties) Positive FeedbackNegative Feedback Property nameTypeRequiredDescriptionChild properties account\_sidSID Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The SID of the [Account](/docs/iam/api/account "Account") that created the Tool resource. Pattern: `^AC[0-9a-fA-F]{32}$`Min length: `34`Max length: `34` * * * descriptionstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The description of the tool. * * * enabledbooleanrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) True if the tool is enabled. * * * idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The tool ID. Pattern: `^aia_tool_*$` * * * metaobjectrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The metadata related to method, url, input\_schema to used with the Tool. * * * namestringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The name of the tool. * * * requires\_authbooleanrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The authentication requirement for the tool. * * * typestringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The type of the tool. ('WEBHOOK') * * * urlstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The url of the tool resource. * * * date\_createdstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Tool was created specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * date\_updatedstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Tool was last updated specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * List all Tools connected to an Assistant ---------------------------------------- [list-all-tools-connected-to-an-assistant page anchor](#list-all-tools-connected-to-an-assistant) Positive FeedbackNegative Feedback `GET https://assistants.twilio.com/v1/Assistants/{assistantId}/Tools` ### Path parameters [path-parameters page anchor](#path-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription assistantIdstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The assistant ID. ### Query parameters [query-parameters page anchor](#query-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription Pageinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page index. This value is simply for client state. Minimum: `0` * * * PageSizeinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) How many resources to return in each list page. The default is 50, and the maximum is 1000. Minimum: `1`Maximum: `1000` * * * PageTokenstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page token. This is provided by the API. List all Tools connected to an Assistant[Link to code sample: List all Tools connected to an Assistant](#code-list-all-tools-connected-to-an-assistant) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function listToolsByAssistant() { 11 const assistantsTools \= await client.assistants.v1 12 .assistants("aia\_asst\_00000000-1111-2222-3333-444444444444") 13 .assistantsTools.list({ limit: 20 }); 14 15 assistantsTools.forEach((a) \=> console.log(a.accountSid)); 16 } 17 18 listToolsByAssistant(); ### Output Copy output 1 { 2 "meta": { 3 "first\_page\_url": "https://www.example.com", 4 "key": "key", 5 "next\_page\_url": "https://www.example.com", 6 "page": 42, 7 "page\_size": 42, 8 "previous\_page\_url": "https://www.example.com", 9 "url": "https://www.example.com" 10 }, 11 "tools": \[\ \ 12\ \ {\ \ 13\ \ "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 14\ \ "description": "description",\ \ 15\ \ "enabled": false,\ \ 16\ \ "id": "aia\_tool",\ \ 17\ \ "meta": {},\ \ 18\ \ "name": "name",\ \ 19\ \ "requires\_auth": false,\ \ 20\ \ "type": "type",\ \ 21\ \ "url": "url",\ \ 22\ \ "date\_created": "2009-07-06T20:30:00Z",\ \ 23\ \ "date\_updated": "2009-07-06T20:30:00Z"\ \ 24\ \ }\ \ 25\ \ \] 26 } * * * Connect a Tool to an Assistant ------------------------------ [connect-a-tool-to-an-assistant page anchor](#connect-a-tool-to-an-assistant) Positive FeedbackNegative Feedback `POST https://assistants.twilio.com/v1/Assistants/{assistantId}/Tools/{id}` Once you've [**created a tool**](/docs/alpha/ai-assistants/api/tools#create-a-tool) using the `/v1/Tools` endpoint, you must connect it to an Assistant to allow your Assistant to call the tool. ### Path parameters [path-parameters-1 page anchor](#path-parameters-1) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription assistantIdstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The assistant ID. * * * idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The tool ID. Connect a Tool to an Assistant[Link to code sample: Connect a Tool to an Assistant](#code-connect-a-tool-to-an-assistant) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function createAssistantToolAttachment() { 11 const assistantsTool \= await client.assistants.v1 12 .assistants("aia\_asst\_00000000-1111-2222-3333-444444444444") 13 .assistantsTools("aia\_tool") 14 .create(); 15 16 console.log(assistantsTool.sid); 17 } 18 19 createAssistantToolAttachment(); * * * Detach a Tool from an Assistant ------------------------------- [detach-a-tool-from-an-assistant page anchor](#detach-a-tool-from-an-assistant) Positive FeedbackNegative Feedback `DELETE https://assistants.twilio.com/v1/Assistants/{assistantId}/Tools/{id}` This endpoint removes a Tool from your Assistant's configuration, so it can no longer be called by that Assistant. ### Path parameters [path-parameters-2 page anchor](#path-parameters-2) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription assistantIdstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The assistant ID. * * * idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The tool ID. Detach a Tool from an Assistant[Link to code sample: Detach a Tool from an Assistant](#code-detach-a-tool-from-an-assistant) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function deleteAssistantToolAttachment() { 11 await client.assistants.v1 12 .assistants("aia\_asst\_00000000-1111-2222-3333-444444444444") 13 .assistantsTools("aia\_tool") 14 .remove(); 15 } 16 17 deleteAssistantToolAttachment(); --- # Feedback Resource | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page Feedback Resource ================= Positive FeedbackNegative Feedback * * * This API tracks [**Human Feedback**](/docs/alpha/ai-assistants/guides/feedback) that you gather on AI Assistant responses. * * * Feedback Properties ------------------- [feedback-properties page anchor](#feedback-properties) Positive FeedbackNegative Feedback Property nameTypeRequiredDescriptionChild properties assistant\_idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Assistant ID. * * * idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Feedback ID. Pattern: `^aia_fdbk_*$` * * * account\_sidSID Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The SID of the [Account](/docs/iam/api/account "Account") that created the Feedback. Pattern: `^AC[0-9a-fA-F]{32}$`Min length: `34`Max length: `34` * * * user\_sidSID Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The SID of the User created the Feedback. Pattern: `^US[0-9a-fA-F]{32}$`Min length: `34`Max length: `34` * * * message\_idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Message ID. * * * scorenumberrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Score to provide as Feedback (0-1) Minimum: `0`Maximum: `1` * * * session\_idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Session ID. * * * textstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The text to be given as feedback. * * * date\_createdstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Feedback was created specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * date\_updatedstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Feedback was last updated specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * Track Feedback -------------- [track-feedback page anchor](#track-feedback) Positive FeedbackNegative Feedback `POST https://assistants.twilio.com/v1/Assistants/{id}/Feedbacks` ### Path parameters [path-parameters page anchor](#path-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The assistant ID. ### Request body parameters [request-body-parameters page anchor](#request-body-parameters) Positive FeedbackNegative Feedback Encoding type:`application/json` Schema Property nameTypeRequiredDescriptionChild properties message\_idstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The message ID. Pattern: `^aia_msg_*$` * * * scorenumber Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The score to be given(0-1). Minimum: `0`Maximum: `1` * * * session\_idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Session ID. * * * textstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The text to be given as feedback. ### Track feedback on a session [track-feedback-on-a-session page anchor](#track-feedback-on-a-session) Positive FeedbackNegative Feedback Track Feedback[Link to code sample: Track Feedback](#code-track-feedback) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function createFeedback() { 11 const feedback \= await client.assistants.v1 12 .assistants("aia\_asst\_00000000-1111-2222-3333-444444444444") 13 .feedbacks.create({ 14 session\_id: "your-session-id", 15 score: 0.5, 16 }); 17 18 console.log(feedback.assistantId); 19 } 20 21 createFeedback(); ### Output Copy output 1 { 2 "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3 "assistant\_id": "assistant\_id", 4 "date\_created": "2009-07-06T20:30:00Z", 5 "date\_updated": "2009-07-06T20:30:00Z", 6 "id": "aia\_asst\_00000000-1111-2222-3333-444444444444", 7 "message\_id": "message\_id", 8 "score": 0.042, 9 "session\_id": "session\_id", 10 "text": "text", 11 "user\_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 12 } ### Track feedback on a specific message [track-feedback-on-a-specific-message page anchor](#track-feedback-on-a-specific-message) Positive FeedbackNegative Feedback Track Feedback[Link to code sample: Track Feedback](#code-track-feedback-1) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function createFeedback() { 11 const feedback \= await client.assistants.v1 12 .assistants("aia\_asst\_00000000-1111-2222-3333-444444444444") 13 .feedbacks.create({ 14 message\_id: "aia\_msg", 15 session\_id: "your-session-id", 16 score: 0.5, 17 }); 18 19 console.log(feedback.assistantId); 20 } 21 22 createFeedback(); ### Output Copy output 1 { 2 "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3 "assistant\_id": "assistant\_id", 4 "date\_created": "2009-07-06T20:30:00Z", 5 "date\_updated": "2009-07-06T20:30:00Z", 6 "id": "aia\_asst\_00000000-1111-2222-3333-444444444444", 7 "message\_id": "message\_id", 8 "score": 0.042, 9 "session\_id": "session\_id", 10 "text": "text", 11 "user\_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 12 } * * * List feedbacks -------------- [list-feedbacks page anchor](#list-feedbacks) Positive FeedbackNegative Feedback `GET https://assistants.twilio.com/v1/Assistants/{id}/Feedbacks` ### Path parameters [path-parameters-1 page anchor](#path-parameters-1) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The assistant ID. ### Query parameters [query-parameters page anchor](#query-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription Pageinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page index. This value is simply for client state. Minimum: `0` * * * PageSizeinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) How many resources to return in each list page. The default is 50, and the maximum is 1000. Minimum: `1`Maximum: `1000` * * * PageTokenstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page token. This is provided by the API. List multiple Feedbacks[Link to code sample: List multiple Feedbacks](#code-list-multiple-feedbacks) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function listFeedback() { 11 const feedbacks \= await client.assistants.v1 12 .assistants("id") 13 .feedbacks.list({ limit: 20 }); 14 15 feedbacks.forEach((f) \=> console.log(f.assistantId)); 16 } 17 18 listFeedback(); ### Output Copy output 1 { 2 "feedbacks": \[\ \ 3\ \ {\ \ 4\ \ "assistant\_id": "assistant\_id",\ \ 5\ \ "id": "aia\_fdbk",\ \ 6\ \ "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 7\ \ "user\_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 8\ \ "message\_id": "message\_id",\ \ 9\ \ "score": 0.042,\ \ 10\ \ "session\_id": "session\_id",\ \ 11\ \ "text": "text",\ \ 12\ \ "date\_created": "2009-07-06T20:30:00Z",\ \ 13\ \ "date\_updated": "2009-07-06T20:30:00Z"\ \ 14\ \ }\ \ 15\ \ \], 16 "meta": { 17 "first\_page\_url": "https://www.example.com", 18 "key": "key", 19 "next\_page\_url": "https://www.example.com", 20 "page": 42, 21 "page\_size": 42, 22 "previous\_page\_url": "https://www.example.com", 23 "url": "https://www.example.com" 24 } 25 } --- # Knowledge Chunk Resource | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page Knowledge Chunk Resource ======================== Positive FeedbackNegative Feedback * * * When you create a Knowledge source, Twilio AI Assistants processes that Knowledge and breaks it into discrete pieces called **Chunks**. These pieces can help you troubleshoot unexpected behavior with your Assistant. This API returns a list of all **Knowledge Chunks** created from uploading Knowledge sources. * * * Chunk Properties ---------------- [chunk-properties page anchor](#chunk-properties) Positive FeedbackNegative Feedback Property nameTypeRequiredDescriptionChild properties account\_sidSID Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The SID of the [Account](/docs/iam/api/account "Account") that created the Knowledge resource. Pattern: `^AC[0-9a-fA-F]{32}$`Min length: `34`Max length: `34` * * * contentstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The chunk content. * * * metadataobject Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The metadata of the chunk. * * * date\_createdstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Chunk was created specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * date\_updatedstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Chunk was updated specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * List knowledge chunks --------------------- [list-knowledge-chunks page anchor](#list-knowledge-chunks) Positive FeedbackNegative Feedback `GET https://assistants.twilio.com/v1/Knowledge/{id}/Chunks` ### Path parameters [path-parameters page anchor](#path-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The knowledge ID. ### Query parameters [query-parameters page anchor](#query-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription PageSizeinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) How many resources to return in each list page. The default is 50, and the maximum is 1000. Minimum: `1`Maximum: `1000` * * * PageTokenstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page token. This is provided by the API. Get Chunks for a given Knowledge source[Link to code sample: Get Chunks for a given Knowledge source](#code-get-chunks-for-a-given-knowledge-source) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function listKnowledgeChunks() { 11 const chunks \= await client.assistants.v1 12 .knowledge("aia\_know") 13 .chunks.list({ limit: 20 }); 14 15 chunks.forEach((c) \=> console.log(c.accountSid)); 16 } 17 18 listKnowledgeChunks(); ### Output Copy output 1 { 2 "chunks": \[\ \ 3\ \ {\ \ 4\ \ "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 5\ \ "content": "content",\ \ 6\ \ "metadata": {},\ \ 7\ \ "date\_created": "2009-07-06T20:30:00Z",\ \ 8\ \ "date\_updated": "2009-07-06T20:30:00Z"\ \ 9\ \ }\ \ 10\ \ \], 11 "meta": { 12 "first\_page\_url": "https://www.example.com", 13 "key": "key", 14 "next\_page\_url": "https://www.example.com", 15 "page": 42, 16 "page\_size": 42, 17 "previous\_page\_url": "https://www.example.com", 18 "url": "https://www.example.com" 19 } 20 } --- # Knowledge Resource | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page Knowledge Resource ================== Positive FeedbackNegative Feedback * * * [**Knowledge**](/docs/alpha/ai-assistants/knowledge) provides your Assistant with access to unstructured data sources. This API allows you to programatically upload Knowledge for your Assistant to consume. * * * Knowledge Properties -------------------- [knowledge-properties page anchor](#knowledge-properties) Positive FeedbackNegative Feedback Property nameTypeRequiredDescriptionChild properties descriptionstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The type of knowledge source. * * * idstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The description of knowledge. Pattern: `^aia_know_*$` * * * account\_sidSID Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The SID of the [Account](/docs/iam/api/account "Account") that created the Knowledge resource. Pattern: `^AC[0-9a-fA-F]{32}$`Min length: `34`Max length: `34` * * * knowledge\_source\_detailsobject Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The details of the knowledge source based on the type. * * * namestring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The name of the knowledge source. * * * statusstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED') * * * typestring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The type of knowledge source ('Web', 'Database', 'Text', 'File') * * * urlstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The url of the knowledge resource. * * * date\_createdstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Knowledge was created specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * date\_updatedstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Knowledge was last updated specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * Create new Knowledge sources ---------------------------- [create-new-knowledge-sources page anchor](#create-new-knowledge-sources) Positive FeedbackNegative Feedback `POST https://assistants.twilio.com/v1/Knowledge` ### Request body parameters [request-body-parameters page anchor](#request-body-parameters) Positive FeedbackNegative Feedback Encoding type:`application/json` Schema Property nameTypeRequiredDescriptionChild properties assistant\_idstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Assistant ID. Pattern: `^aia_asst_*$` * * * descriptionstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The description of the knowledge source. * * * knowledge\_source\_detailsobject Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The details of the knowledge source based on the type. * * * namestringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The name of the tool. * * * policyobject Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The policy associated with the knowledge source. Show child properties for policy Property nameTypeRequiredDescriptionChild properties descriptionstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The description of the policy. * * * idstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Policy ID. Pattern: `^aia_plcy_*$` * * * namestring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The name of the policy. * * * policy\_detailsobjectrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) * * * typestring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The description of the policy. * * * typestringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The type of the knowledge source. You can [configure Knowledge sources](/docs/alpha/ai-assistants/knowledge#configure-knowledge-sources "configure Knowledge sources") of type: `Web`, `Text`, and `File` from the API. ### Crawl a website [crawl-a-website page anchor](#crawl-a-website) Positive FeedbackNegative Feedback Give your Assistant a publicly-accessible URL to index information from. [See additional details about web crawling limits.](/docs/alpha/ai-assistants/knowledge#configure-knowledge-sources "See additional details about web crawling limits.") Crawl a website[Link to code sample: Crawl a website](#code-crawl-a-website) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function createKnowledge() { 11 const knowledge \= await client.assistants.v1.knowledge.create({ 12 name: "Info about Twilio Alpha", 13 type: "Web", 14 description: "Use this for information about Twilio Alpha or AI Assistants", 15 knowledge\_source\_details: { 16 source: "https://twilioalpha.com", 17 }, 18 }); 19 20 console.log(knowledge.description); 21 } 22 23 createKnowledge(); ### Upload text [upload-text page anchor](#upload-text) Positive FeedbackNegative Feedback Provide plain text for your Assistant. Upload text[Link to code sample: Upload text](#code-upload-text) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function createKnowledge() { 11 const knowledge \= await client.assistants.v1.knowledge.create({ 12 name: "Star Wars Quotes", 13 type: "Text", 14 description: "Use this for famous Star Wars quotes", 15 knowledge\_source\_details: { 16 content: "This is the ship that made the Kessel Run in fourteen parsecs?", 17 }, 18 }); 19 20 console.log(knowledge.description); 21 } 22 23 createKnowledge(); ### Upload a file [upload-a-file page anchor](#upload-a-file) Positive FeedbackNegative Feedback Upload a file for your Assistant to reference. [See supported file types](/docs/alpha/ai-assistants/knowledge#configure-knowledge-sources "See supported file types") . Upload a file[Link to code sample: Upload a file](#code-upload-a-file) Copy code block 1 const fs \= require('fs'); 2 // Before running this code, install "form-data" and "axios" using \`npm install form-data axios\` 3 const FormData \= require('form-data'); 4 const axios \= require('axios'); 5 6 // Provision API Keys at twilio.com/console/runtime/api-keys 7 // and set the environment variables. See http://twil.io/secure 8 const apiKey \= process.env.TWILIO\_API\_KEY; 9 const apiSecret \= process.env.TWILIO\_API\_SECRET; 10 11 const uploadUrl \= \`https://assistants-upload.twilio.com/v1/Knowledge/Upload\`; 12 13 const form \= new FormData(); 14 form.append('name', 'File Demo'); 15 form.append('description', 'A description of this file') 16 form.append('type', 'File'); 17 form.append('assistant\_id', 'aia\_asst\_xxxxxxxxxxxxxxxx'); 18 form.append('file\_0', fs.createReadStream('README.md'), { 19 contentType: 'text/markdown', 20 }); 21 22 // Create a new Function Version 23 axios 24 .post(uploadUrl, form, { 25 auth: { 26 username: apiKey, 27 password: apiSecret, 28 }, 29 headers: form.getHeaders(), 30 }) 31 .then((response) \=> { 32 const newKnowledgeId \= response.data.id; 33 console.log(newKnowledgeId); 34 }); * * * Get a Knowledge source ---------------------- [get-a-knowledge-source page anchor](#get-a-knowledge-source) Positive FeedbackNegative Feedback `GET https://assistants.twilio.com/v1/Knowledge/{id}` ### Path parameters [path-parameters page anchor](#path-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) ### Get a Knowledge source [get-a-knowledge-source-1 page anchor](#get-a-knowledge-source-1) Positive FeedbackNegative Feedback Fetch details about a single Knowledge source Get a Knowledge source[Link to code sample: Get a Knowledge source](#code-get-a-knowledge-source) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function fetchKnowledge() { 11 const knowledge \= await client.assistants.v1.knowledge("aia\_know").fetch(); 12 13 console.log(knowledge.description); 14 } 15 16 fetchKnowledge(); ### Output Copy output 1 { 2 "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3 "date\_created": "2009-07-06T20:30:00Z", 4 "date\_updated": "2009-07-06T20:30:00Z", 5 "description": "description", 6 "id": "aia\_know", 7 "knowledge\_source\_details": {}, 8 "name": "name", 9 "status": "status", 10 "type": "type", 11 "url": "url" 12 } ### Fetch status of a Knowledge source [fetch-status-of-a-knowledge-source page anchor](#fetch-status-of-a-knowledge-source) Positive FeedbackNegative Feedback `GET https://assistants.twilio.com/v1/Knowledge/{id}/Status` When you create a Knowledge source, Twilio AI Assistants processes the Knowledge so it's accessible to your Assistant. You can fetch the **status** of processing for a given Knowledge Source. Get the status of a Knowledge source[Link to code sample: Get the status of a Knowledge source](#code-get-the-status-of-a-knowledge-source) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function fetchKnowledgeStatus() { 11 const knowledgeStatus \= await client.assistants.v1 12 .knowledge("aia\_know") 13 .knowledgeStatus() 14 .fetch(); 15 16 console.log(knowledgeStatus.accountSid); 17 } 18 19 fetchKnowledgeStatus(); ### Output Copy output 1 { 2 "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3 "date\_updated": "2009-07-06T20:30:00Z", 4 "last\_status": "last\_status", 5 "status": "status" 6 } * * * List Knowledge sources ---------------------- [list-knowledge-sources page anchor](#list-knowledge-sources) Positive FeedbackNegative Feedback `GET https://assistants.twilio.com/v1/Knowledge` ### Query parameters [query-parameters page anchor](#query-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription AssistantIdstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) * * * Pageinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page index. This value is simply for client state. Minimum: `0` * * * PageSizeinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) How many resources to return in each list page. The default is 50, and the maximum is 1000. Minimum: `1`Maximum: `1000` * * * PageTokenstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page token. This is provided by the API. List multiple Knowledges[Link to code sample: List multiple Knowledges](#code-list-multiple-knowledges) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function listKnowledge() { 11 const knowledge \= await client.assistants.v1.knowledge.list({ limit: 20 }); 12 13 knowledge.forEach((k) \=> console.log(k.description)); 14 } 15 16 listKnowledge(); ### Output Copy output 1 { 2 "knowledge": \[\ \ 3\ \ {\ \ 4\ \ "description": "description",\ \ 5\ \ "id": "aia\_know",\ \ 6\ \ "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 7\ \ "knowledge\_source\_details": {},\ \ 8\ \ "name": "name",\ \ 9\ \ "status": "status",\ \ 10\ \ "type": "type",\ \ 11\ \ "url": "url",\ \ 12\ \ "date\_created": "2009-07-06T20:30:00Z",\ \ 13\ \ "date\_updated": "2009-07-06T20:30:00Z"\ \ 14\ \ }\ \ 15\ \ \], 16 "meta": { 17 "first\_page\_url": "https://www.example.com", 18 "key": "key", 19 "next\_page\_url": "https://www.example.com", 20 "page": 42, 21 "page\_size": 42, 22 "previous\_page\_url": "https://www.example.com", 23 "url": "https://www.example.com" 24 } 25 } * * * Delete a Knowledge source ------------------------- [delete-a-knowledge-source page anchor](#delete-a-knowledge-source) Positive FeedbackNegative Feedback `DELETE https://assistants.twilio.com/v1/Knowledge/{id}` ### Path parameters [path-parameters-1 page anchor](#path-parameters-1) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) the Knowledge ID. Delete a Knowledge source[Link to code sample: Delete a Knowledge source](#code-delete-a-knowledge-source) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function deleteKnowledge() { 11 await client.assistants.v1.knowledge("aia\_know").remove(); 12 } 13 14 deleteKnowledge(); --- # Policies Resource | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page Policies Resource ================= Positive FeedbackNegative Feedback * * * * * * Policy Properties ----------------- [policy-properties page anchor](#policy-properties) Positive FeedbackNegative Feedback Property nameTypeRequiredDescriptionChild properties idstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Policy ID. Pattern: `^aia_plcy_*$` * * * namestring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The name of the policy. * * * descriptionstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The description of the policy. * * * account\_sidSID Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The SID of the [Account](/docs/iam/api/account "Account") that created the Policy resource. Pattern: `^AC[0-9a-fA-F]{32}$`Min length: `34`Max length: `34` * * * user\_sidSID Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The SID of the User that created the Policy resource. Pattern: `^US[0-9a-fA-F]{32}$`Min length: `34`Max length: `34` * * * typestringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The type of the policy. * * * policy\_detailsobjectrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The details of the policy based on the type. * * * date\_createdstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Policy was created specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * date\_updatedstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Policy was last updated specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * List policies ------------- [list-policies page anchor](#list-policies) Positive FeedbackNegative Feedback `GET https://assistants.twilio.com/v1/Policies` ### Query parameters [query-parameters page anchor](#query-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription ToolIdstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The tool ID. * * * KnowledgeIdstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The knowledge ID. * * * Pageinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page index. This value is simply for client state. Minimum: `0` * * * PageSizeinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) How many resources to return in each list page. The default is 50, and the maximum is 1000. Minimum: `1`Maximum: `1000` * * * PageTokenstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page token. This is provided by the API. List multiple Policys[Link to code sample: List multiple Policys](#code-list-multiple-policys) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function listPolicies() { 11 const policies \= await client.assistants.v1.policies.list({ limit: 20 }); 12 13 policies.forEach((p) \=> console.log(p.id)); 14 } 15 16 listPolicies(); ### Output Copy output 1 { 2 "meta": { 3 "first\_page\_url": "https://www.example.com", 4 "key": "key", 5 "next\_page\_url": "https://www.example.com", 6 "page": 42, 7 "page\_size": 42, 8 "previous\_page\_url": "https://www.example.com", 9 "url": "https://www.example.com" 10 }, 11 "policies": \[\ \ 12\ \ {\ \ 13\ \ "id": "aia\_plcy",\ \ 14\ \ "name": "name",\ \ 15\ \ "description": "description",\ \ 16\ \ "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 17\ \ "user\_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 18\ \ "type": "type",\ \ 19\ \ "policy\_details": {},\ \ 20\ \ "date\_created": "2009-07-06T20:30:00Z",\ \ 21\ \ "date\_updated": "2009-07-06T20:30:00Z"\ \ 22\ \ }\ \ 23\ \ \] 24 } --- # Sessions Resource | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page Sessions Resource ================= Positive FeedbackNegative Feedback * * * * * * Session Properties ------------------ [session-properties page anchor](#session-properties) Positive FeedbackNegative Feedback Property nameTypeRequiredDescriptionChild properties idstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Session ID. * * * account\_sidSID Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The SID of the [Account](/docs/iam/api/account "Account") that created the Session resource. Pattern: `^AC[0-9a-fA-F]{32}$`Min length: `34`Max length: `34` * * * assistant\_idstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Assistant ID. Pattern: `^aia_asst_*$` * * * verifiedboolean Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) True if the session is verified. * * * identitystring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The unique identity of user for the session. * * * date\_createdstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Session was created specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * date\_updatedstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Session was last updated specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * Get a Session ------------- [get-a-session page anchor](#get-a-session) Positive FeedbackNegative Feedback `GET https://assistants.twilio.com/v1/Sessions/{id}` ### Path parameters [path-parameters page anchor](#path-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) Get a Session[Link to code sample: Get a Session](#code-get-a-session) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function fetchSession() { 11 const session \= await client.assistants.v1 12 .sessions("your-session-id") 13 .fetch(); 14 15 console.log(session.id); 16 } 17 18 fetchSession(); ### Output Copy output 1 { 2 "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3 "assistant\_id": "aia\_asst", 4 "date\_created": "2009-07-06T20:30:00Z", 5 "date\_updated": "2009-07-06T20:30:00Z", 6 "id": "your-session-id", 7 "identity": "identity", 8 "verified": false 9 } * * * List Sessions ------------- [list-sessions page anchor](#list-sessions) Positive FeedbackNegative Feedback `GET https://assistants.twilio.com/v1/Sessions` ### Query parameters [query-parameters page anchor](#query-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription Pageinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page index. This value is simply for client state. Minimum: `0` * * * PageSizeinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) How many resources to return in each list page. The default is 50, and the maximum is 1000. Minimum: `1`Maximum: `1000` * * * PageTokenstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page token. This is provided by the API. List Sessions[Link to code sample: List Sessions](#code-list-sessions) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function listSessions() { 11 const sessions \= await client.assistants.v1.sessions.list({ limit: 20 }); 12 13 sessions.forEach((s) \=> console.log(s.id)); 14 } 15 16 listSessions(); ### Output Copy output 1 { 2 "meta": { 3 "first\_page\_url": "https://www.example.com", 4 "key": "key", 5 "next\_page\_url": "https://www.example.com", 6 "page": 42, 7 "page\_size": 42, 8 "previous\_page\_url": "https://www.example.com", 9 "url": "https://www.example.com" 10 }, 11 "sessions": \[\ \ 12\ \ {\ \ 13\ \ "id": "id",\ \ 14\ \ "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 15\ \ "assistant\_id": "aia\_asst",\ \ 16\ \ "verified": false,\ \ 17\ \ "identity": "identity",\ \ 18\ \ "date\_created": "2009-07-06T20:30:00Z",\ \ 19\ \ "date\_updated": "2009-07-06T20:30:00Z"\ \ 20\ \ }\ \ 21\ \ \] 22 } --- # Tools Resource | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page Tools Resource ============== Positive FeedbackNegative Feedback * * * Create and configure [**Tools**](/docs/alpha/ai-assistants/tools) that an AI Assistant can use. * * * Tool Properties --------------- [tool-properties page anchor](#tool-properties) Positive FeedbackNegative Feedback Property nameTypeRequiredDescriptionChild properties account\_sidSID Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The SID of the [Account](/docs/iam/api/account "Account") that created the Tool resource. Pattern: `^AC[0-9a-fA-F]{32}$`Min length: `34`Max length: `34` * * * descriptionstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The description of the tool. * * * enabledbooleanrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) True if the tool is enabled. * * * idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The tool ID. Pattern: `^aia_tool_*$` * * * metaobjectrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The metadata related to method, url, input\_schema to used with the Tool. * * * namestringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The name of the tool. * * * requires\_authbooleanrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The authentication requirement for the tool. * * * typestringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The type of the tool. ('WEBHOOK') * * * urlstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The url of the tool resource. * * * date\_createdstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Tool was created specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * date\_updatedstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The date and time in GMT when the Tool was last updated specified in [ISO 8601(link takes you to an external page)](https://en.wikipedia.org/wiki/ISO_8601 "ISO 8601") format. * * * Create a Tool ------------- [create-a-tool page anchor](#create-a-tool) Positive FeedbackNegative Feedback `POST https://assistants.twilio.com/v1/Tools` ### Request body parameters [request-body-parameters page anchor](#request-body-parameters) Positive FeedbackNegative Feedback Encoding type:`application/json` Schema Property nameTypeRequiredDescriptionChild properties assistant\_idstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Assistant ID. Pattern: `^aia_asst_*$` * * * descriptionstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The description of the tool. * * * enabledbooleanrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) True if the tool is enabled. * * * metaobject Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The metadata related to method, url, input\_schema to used with the Tool. * * * namestringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The name of the tool. * * * policyobject Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The policy associated with the tool. Show child properties for policy Property nameTypeRequiredDescriptionChild properties descriptionstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The description of the policy. * * * idstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The Policy ID. Pattern: `^aia_plcy_*$` * * * namestring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The name of the policy. * * * policy\_detailsobjectrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) * * * typestring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The description of the policy. * * * typestringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The description of the tool. Create a Tool[Link to code sample: Create a Tool](#code-create-a-tool) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function createTool() { 11 const tool \= await client.assistants.v1.tools.create({ 12 name: "Schedule a Meeting", 13 type: "WEBHOOK", 14 description: "Use this to schedule a meeting", 15 enabled: true, 16 meta: { 17 url: "https://example.com", 18 method: "POST", 19 input\_schema: "export type Data = { date: string }", 20 }, 21 }); 22 23 console.log(tool.accountSid); 24 } 25 26 createTool(); ### Output Copy output 1 { 2 "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3 "date\_created": "2009-07-06T20:30:00Z", 4 "date\_updated": "2009-07-06T20:30:00Z", 5 "description": "description", 6 "enabled": false, 7 "id": "aia\_tool", 8 "meta": {}, 9 "name": "name", 10 "requires\_auth": false, 11 "type": "type", 12 "url": "url" 13 } * * * Get a Tool ---------- [get-a-tool page anchor](#get-a-tool) Positive FeedbackNegative Feedback `GET https://assistants.twilio.com/v1/Tools/{id}` ### Path parameters [path-parameters page anchor](#path-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) Get a Tool[Link to code sample: Get a Tool](#code-get-a-tool) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function fetchTool() { 11 const tool \= await client.assistants.v1.tools("aia\_tool").fetch(); 12 13 console.log(tool.accountSid); 14 } 15 16 fetchTool(); ### Output Copy output 1 { 2 "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3 "date\_created": "2009-07-06T20:30:00Z", 4 "date\_updated": "2009-07-06T20:30:00Z", 5 "description": "description", 6 "enabled": false, 7 "id": "aia\_tool", 8 "meta": {}, 9 "name": "name", 10 "policies": \[\ \ 11\ \ {\ \ 12\ \ "id": "aia\_plcy",\ \ 13\ \ "name": "name",\ \ 14\ \ "description": "description",\ \ 15\ \ "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 16\ \ "user\_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 17\ \ "type": "type",\ \ 18\ \ "policy\_details": {},\ \ 19\ \ "date\_created": "2009-07-06T20:30:00Z",\ \ 20\ \ "date\_updated": "2009-07-06T20:30:00Z"\ \ 21\ \ }\ \ 22\ \ \], 23 "requires\_auth": false, 24 "type": "type", 25 "url": "url" 26 } * * * List Tools ---------- [list-tools page anchor](#list-tools) Positive FeedbackNegative Feedback `GET https://assistants.twilio.com/v1/Tools` ### Query parameters [query-parameters page anchor](#query-parameters) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription AssistantIdstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) * * * Pageinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page index. This value is simply for client state. Minimum: `0` * * * PageSizeinteger Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) How many resources to return in each list page. The default is 50, and the maximum is 1000. Minimum: `1`Maximum: `1000` * * * PageTokenstring Optional [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The page token. This is provided by the API. List multiple Tools[Link to code sample: List multiple Tools](#code-list-multiple-tools) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function listTools() { 11 const tools \= await client.assistants.v1.tools.list({ limit: 20 }); 12 13 tools.forEach((t) \=> console.log(t.accountSid)); 14 } 15 16 listTools(); ### Output Copy output 1 { 2 "meta": { 3 "first\_page\_url": "https://www.example.com", 4 "key": "key", 5 "next\_page\_url": "https://www.example.com", 6 "page": 42, 7 "page\_size": 42, 8 "previous\_page\_url": "https://www.example.com", 9 "url": "https://www.example.com" 10 }, 11 "tools": \[\ \ 12\ \ {\ \ 13\ \ "account\_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",\ \ 14\ \ "description": "description",\ \ 15\ \ "enabled": false,\ \ 16\ \ "id": "aia\_tool",\ \ 17\ \ "meta": {},\ \ 18\ \ "name": "name",\ \ 19\ \ "requires\_auth": false,\ \ 20\ \ "type": "type",\ \ 21\ \ "url": "url",\ \ 22\ \ "date\_created": "2009-07-06T20:30:00Z",\ \ 23\ \ "date\_updated": "2009-07-06T20:30:00Z"\ \ 24\ \ }\ \ 25\ \ \] 26 } * * * Delete a Tool ------------- [delete-a-tool page anchor](#delete-a-tool) Positive FeedbackNegative Feedback `DELETE https://assistants.twilio.com/v1/Tools/{id}` ### Path parameters [path-parameters-1 page anchor](#path-parameters-1) Positive FeedbackNegative Feedback Property nameTypeRequiredPIIDescription idstringrequired [Not PII](/docs/glossary/what-is-personally-identifiable-information-pii#fields-marked-not-pii) The tool ID. Delete a Tool[Link to code sample: Delete a Tool](#code-delete-a-tool) Copy code block 1 // Download the helper library from https://www.twilio.com/docs/node/install 2 const twilio \= require("twilio"); // Or, for ESM: import twilio from "twilio"; 3 4 // Find your Account SID and Auth Token at twilio.com/console 5 // and set the environment variables. See http://twil.io/secure 6 const accountSid \= process.env.TWILIO\_ACCOUNT\_SID; 7 const authToken \= process.env.TWILIO\_AUTH\_TOKEN; 8 const client \= twilio(accountSid, authToken); 9 10 async function deleteTool() { 11 await client.assistants.v1.tools("aia\_tool").remove(); 12 } 13 14 deleteTool(); --- # Channels | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page Channels ======== Positive FeedbackNegative Feedback * * * Twilio AI Assistants can integrate with various communication channels, allowing you to deploy your Assistant where your customers are most active. Each channel offers unique capabilities and is configurable to meet the specific needs of your business, ensuring a seamless customer experience across all platforms. * * * Channel configuration --------------------- [channel-configuration page anchor](#channel-configuration) Positive FeedbackNegative Feedback Use Quick Deploy for easy channel setup To simplify the setup process, you can use [Twilio Quick Deploy](/code-exchange/ai-assistants-samples "Twilio Quick Deploy") which provides a collection of pre-built [Twilio Functions](/docs/serverless/functions-assets/functions "Twilio Functions") to connect your AI Assistant to various channels including: * SMS * WhatsApp * Twilio Conversations (Web, iOS, Android) * Flex Webchat * React web chat This Quick Deploy also provides common tools for an AI Assistant, such as: * Conversation hand-off to a Flex agent * Conversation hand-off to a Studio Flow [Quick Deploy in minutes(link takes you to an external page)](https://twilio.com/code-exchange/ai-assistants-samples) ### Connect your Assistant to your preferred channels [connect-your-assistant-to-your-preferred-channels page anchor](#connect-your-assistant-to-your-preferred-channels) Positive FeedbackNegative Feedback Connect your AI Assistant to your preferred channels [Twilio Conversations](/docs/alpha/ai-assistants/code-samples/channel-conversations) [SMS & WhatsApp](/docs/alpha/ai-assistants/code-samples/channel-messaging) [Website with React](/docs/alpha/ai-assistants/code-samples/react) ### Send messages with the API [send-messages-with-the-api page anchor](#send-messages-with-the-api) Positive FeedbackNegative Feedback You can use the Twilio Assistants API to trigger a message. Aside from a `body`, you can pass in an `identity` and a `session_id` of your choice to maintain message history . #### Send a message using curl [send-a-message-using-curl page anchor](#send-a-message-using-curl) Copy code block 1 ASSISTANT\_SID\= 2 curl \-X POST \-H 'Content-Type:application/json' \\ 3 https://assistants.twilio.com/v1/Assistants/$ASSISTANT\_SID/Messages \\ 4 \-d '{"identity":"user\_id:example", "session\_id": "demo", "body":"Ahoy there"}' \\ 5 \-u $TWILIO\_ACCOUNT\_SID:$TWILIO\_AUTH\_TOKEN --- # Use Twilio Conversations as a Channel | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this pageProducts used [Twilio Conversations DocumentationConversations](/docs/conversations) [Twilio Functions DocumentationServerless](/docs/serverless) Use Twilio Conversations as a Channel ===================================== Positive FeedbackNegative Feedback * * * (warning) Twilio Alpha - Developer Preview -------------------------------- AI Assistants is a [Twilio Alpha(link takes you to an external page)](https://twilioalpha.com "Twilio Alpha") project that's in **Developer Preview**. View the [current limitations](/docs/alpha/ai-assistants/pricing-and-limits "current limitations") for details about feature limits during developer preview. By connecting your AI Assistant to [Twilio Conversations](/docs/conversations "Twilio Conversations") , you can have your AI Assistant available across the variety of channels that Twilio Conversations supports. This connection also enables: * [AI Assistant handoff to a Twilio Flex agent](/docs/alpha/ai-assistants/code-samples/transition-flex "AI Assistant handoff to a Twilio Flex agent") * [Transitioning a conversation from an AI Assistant to a Twilio Studio Flow](/docs/alpha/ai-assistants/code-samples/transition-studio "Transitioning a conversation from an AI Assistant to a Twilio Studio Flow") * [The AI Assistant React SDK](/docs/alpha/ai-assistants/code-samples/react "The AI Assistant React SDK") In this guide, you will connect your AI Assistant to Twilio Conversations. Your Assistant will then listen and respond in any conversation with only one participant. * * * Prerequisites ------------- [prerequisites page anchor](#prerequisites) Positive FeedbackNegative Feedback If you don't have a Twilio Conversations service yet, start by [creating a new service(link takes you to an external page)](https://www.twilio.com/console/sms/services "creating a new service") . You will also need the [Twilio CLI](/docs/twilio-cli/quickstart "Twilio CLI") and [Serverless Toolkit](/docs/labs/serverless-toolkit "Serverless Toolkit") installed on your machine for this guide. * * * Deploy Conversations webhook code --------------------------------- [deploy-conversations-webhook-code page anchor](#deploy-conversations-webhook-code) Positive FeedbackNegative Feedback To trigger your AI Assistant based on incoming messages to your Twilio Conversations service, you will need to configure [Twilio Conversation webhooks](/docs/conversations/conversations-webhooks "Twilio Conversation webhooks") . The [AI Assistants Samples GitHub repository(link takes you to an external page)](https://github.com/twilio-labs/ai-assistants-samples "AI Assistants Samples GitHub repository") contains a sample webhook service that you can deploy for your Twilio account. You only have to deploy this webhook into your Twilio account once, regardless of how many AI Assistants or Conversations services you intend to use. To deploy the webhooks, clone the [AI Assistants Samples repository(link takes you to an external page)](https://github.com/twilio-labs/ai-assistants-samples "AI Assistants Samples repository") and deploy the [Twilio Functions](/docs/serverless/functions-assets "Twilio Functions") from the repository into your Twilio account. #### Install and deploy the webhooks [install-and-deploy-the-webhooks page anchor](#install-and-deploy-the-webhooks) Copy code block 1 git clone git@github.com:twilio-labs/ai-assistants-samples.git 2 cd ai-assistants-samples 3 npm install 4 cp .env.example .env 5 \# you can ignore editing the .env if you don't intend to use other tools in the project 6 7 twilio serverless:deploy After running the commands above, your output should look similar to this: #### Example deployment output [example-deployment-output page anchor](#example-deployment-output) Copy code block 1 Deployment Details 2 Domain: ai-assistants-samples-1111-dev.twil.io 3 Service: 4 ai-assistants-samples (ZSf3510841424c854e3f3b282550211111) 5 Environment: 6 dev (ZE94900e7f2a2c330b15cf6e1c9fd11111) 7 Build SID: 8 ZB2743d62d52d42ccd55873a0bcd511111 9 Runtime: 10 node18 11 View Live Logs: 12 https://www.twilio.com/console/functions/editor/ZSf3510841424c854e3f3b282550211111/environment/ZE94900e7f2a2c330b15cf6e1c9fd11111 13 Functions: 14 \[protected\] https://ai-assistants-samples-1111-dev.twil.io/channels/conversations/messageAdded 15 \[protected\] https://ai-assistants-samples-1111-dev.twil.io/channels/messaging/incoming 16 \[protected\] https://ai-assistants-samples-1111-dev.twil.io/channels/conversations/response 17 \[protected\] https://ai-assistants-samples-1111-dev.twil.io/channels/messaging/response 18 https://ai-assistants-samples-1111-dev.twil.io/tools/flex-handover 19 https://ai-assistants-samples-1111-dev.twil.io/tools/google-maps 20 https://ai-assistants-samples-1111-dev.twil.io/tools/internet-search 21 https://ai-assistants-samples-1111-dev.twil.io/tools/studio-handover 22 Assets: Make sure you take note of the output behind `Domain`, which is your Functions URL. * * * Configure your webhook ---------------------- [configure-your-webhook page anchor](#configure-your-webhook) Positive FeedbackNegative Feedback Next, configure your deployed webhook as an `onMessageAdded` webhook on your Twilio Conversations service. You can do this either by opening your [Conversations service in the Twilio Console(link takes you to an external page)](https://twilio.com/console/conversations/services "Conversations service in the Twilio Console") and selecting **Webhooks** in the menu to define a service-wide webhook, or by running the following command using the Twilio CLI: #### Set a Conversations webhook [set-a-conversations-webhook page anchor](#set-a-conversations-webhook) Copy code block 1 twilio api:conversations:v1:services:configuration:webhooks:update \\ 2 \--post-webhook-url=https://.twil.io/channels/conversations/messageAdded?AssistantSid= 3 \--chat-service-sid\= 4 \--filter\=onMessageAdded Make sure you replace ``, ``, and `` with the respective values from the steps above. You can find your AI Assistant's SID in the [Twilio Console under your Assistant's configuration(link takes you to an external page)](https://console.twilio.com/us1/develop/ai-assistants/assistants "Twilio Console under your Assistant's configuration") . * * * Test your configuration ----------------------- [test-your-configuration page anchor](#test-your-configuration) Positive FeedbackNegative Feedback If you've already been using Twilio Conversations with an existing application, you can test this configuration right away with that application. Your AI Assistant will respond in any conversation that has only one participant in it. Once another participant joins the conversation, your Assistant will automatically stop listening. If you don't have an application yet, you can follow the instructions in the [Conversations Quickstart(link takes you to an external page)](https://www.twilio.com/docs/conversations/quickstart "Conversations Quickstart") to get started or check out the guide for using [AI Assistants with React](/docs/alpha/ai-assistants/code-samples/react "AI Assistants with React") . * * * Learn more ---------- [learn-more page anchor](#learn-more) Positive FeedbackNegative Feedback * [Learn how to add an AI Assistant to your React application](/docs/alpha/ai-assistants/code-samples/react "Learn how to add an AI Assistant to your React application") * [Learn how to have your AI Assistant transition a conversation to a Flex agent](/docs/alpha/ai-assistants/code-samples/transition-flex "Learn how to have your AI Assistant transition a conversation to a Flex agent") * [Learn how to have your AI Assistant transition a conversation to a Studio flow](/docs/alpha/ai-assistants/code-samples/transition-studio "Learn how to have your AI Assistant transition a conversation to a Studio flow") --- # Use Twilio Messaging as a Channel | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this pageProducts used [Twilio Messaging DocumentationMessaging](/docs/messaging) [Twilio WhatsApp Business Platform DocumentationWhatsApp](/docs/whatsapp) [Twilio Functions DocumentationServerless](/docs/serverless) Use Twilio Messaging as a Channel ================================= Positive FeedbackNegative Feedback * * * (warning) Twilio Alpha - Developer Preview -------------------------------- AI Assistants is a [Twilio Alpha(link takes you to an external page)](https://twilioalpha.com "Twilio Alpha") project that's in **Developer Preview**. View the [current limitations](/docs/alpha/ai-assistants/pricing-and-limits "current limitations") for details about feature limits during developer preview. This guide will show you how to trigger your AI Assistant with incoming messages from end users by connecting your Assistant with [Twilio Messaging](/docs/messaging "Twilio Messaging") . To get started, you will need the following: * A configured AI Assistant. [See the Quickstart guide to setting up an Assistant](/docs/alpha/ai-assistants/quickstart "See the Quickstart guide to setting up an Assistant") if you have not configured one yet. * A Twilio phone number or WhatsApp business number. Alternatively, you can use the [Twilio Sandbox for WhatsApp](/docs/whatsapp/sandbox "Twilio Sandbox for WhatsApp") to get started. * The [Twilio CLI](/docs/twilio-cli/quickstart "Twilio CLI") installed on your machine. * The [Serverless Toolkit](/docs/labs/serverless-toolkit "Serverless Toolkit") installed on your machine. * * * Setup ----- [setup page anchor](#setup) Positive FeedbackNegative Feedback To trigger your AI Assistant via incoming messages, you will configure an incoming message webhook on your Twilio phone number to forward messages to your AI Assistant. ### Deploy the webhook code [deploy-the-webhook-code page anchor](#deploy-the-webhook-code) Positive FeedbackNegative Feedback You only have to deploy this webhook into your Twilio account once, regardless of how many AI Assistants or phone numbers you intend to use. To deploy the webhooks, clone the [AI Assistants Samples repository(link takes you to an external page)](https://github.com/twilio-labs/ai-assistants-samples "AI Assistants Samples repository") and deploy the [Twilio Functions](/docs/serverless/functions-assets "Twilio Functions") into your Twilio account. #### Install and deploy the webhooks [install-and-deploy-the-webhooks page anchor](#install-and-deploy-the-webhooks) Copy code block 1 git clone git@github.com:twilio-labs/ai-assistants-samples.git 2 cd ai-assistants-samples 3 npm install 4 cp .env.example .env 5 \# you can ignore editing the .env if you don't intend to use other tools in the project 6 7 twilio serverless:deploy After running the above commands, your output should look similar to this: #### Example deployment output [example-deployment-output page anchor](#example-deployment-output) Copy code block 1 Deployment Details 2 Domain: ai-assistants-samples-1111-dev.twil.io 3 Service: 4 ai-assistants-samples (ZSf3510841424c854e3f3b282550211111) 5 Environment: 6 dev (ZE94900e7f2a2c330b15cf6e1c9fd11111) 7 Build SID: 8 ZB2743d62d52d42ccd55873a0bcd511111 9 Runtime: 10 node18 11 View Live Logs: 12 https://www.twilio.com/console/functions/editor/ZSf3510841424c854e3f3b282550211111/environment/ZE94900e7f2a2c330b15cf6e1c9fd11111 13 Functions: 14 \[protected\] https://ai-assistants-samples-1111-dev.twil.io/channels/conversations/messageAdded 15 https://ai-assistants-samples-1111-dev.twil.io/channels/messaging/incoming 16 \[protected\] https://ai-assistants-samples-1111-dev.twil.io/channels/conversations/response 17 https://ai-assistants-samples-1111-dev.twil.io/channels/messaging/response 18 https://ai-assistants-samples-1111-dev.twil.io/tools/flex-handover 19 https://ai-assistants-samples-1111-dev.twil.io/tools/google-maps 20 https://ai-assistants-samples-1111-dev.twil.io/tools/internet-search 21 https://ai-assistants-samples-1111-dev.twil.io/tools/studio-handover 22 Assets: Make sure you take note of the output behind `Domain`; this is your Functions URL. ### Configure your webhook for SMS [configure-your-webhook-for-sms page anchor](#configure-your-webhook-for-sms) Positive FeedbackNegative Feedback If you use the Twilio Console, open your [SMS-capable phone number(link takes you to an external page)](https://www.twilio.com/console/phone-numbers/incoming "SMS-capable phone number") of choice or [Messaging Service(link takes you to an external page)](https://www.twilio.com/console/sms/services "Messaging Service") in the Twilio Console and configure the **When a message comes in webhook** to point to: `https://.twil.io/channels/messaging/incoming?AssistantSid=`. You can find your Assistant's SID in the Twilio Console under your Assistant's configuration. Alternatively, you can use the Twilio CLI to configure the webhook by running the following command: #### Set an Incoming Message webhook [set-an-incoming-message-webhook page anchor](#set-an-incoming-message-webhook) Copy code block 1 twilio phone\_number \\ 2 \--sms-url=https://.twil.io/channels/messaging/incoming?AssistantSid= Make sure you replace `` and `` with the respective values from the steps above. You can find your [Assistant's SID in the AI Assistants section of the Twilio Console(link takes you to an external page)](https://console.twilio.com/us1/develop/ai-assistants/assistants "Assistant's SID in the AI Assistants section of the Twilio Console") . ### Configure your webhook for the Sandbox for WhatsApp [configure-your-webhook-for-the-sandbox-for-whatsapp page anchor](#configure-your-webhook-for-the-sandbox-for-whatsapp) Positive FeedbackNegative Feedback If you are using the WhatsApp Sandbox for this guide, configure your **When a message comes in** webhook in the [WhatsApp Sandbox Settings(link takes you to an external page)](https://console.twilio.com/us1/develop/sms/try-it-out/whatsapp-learn?frameUrl=%2Fconsole%2Fsms%2Fwhatsapp%2Flearn%3Fx-target-region%3Dus1 "WhatsApp Sandbox Settings") to point to `https://.twil.io/channels/messaging/incoming?AssistantSid=` Make sure you replace `` and `` with the respective values from the steps above. ### Test your configuration [test-your-configuration page anchor](#test-your-configuration) Positive FeedbackNegative Feedback Send a message to your Twilio phone number or WhatsApp sandbox, and you should receive a response from your AI Assistant. * * * Learn more ---------- [learn-more page anchor](#learn-more) Positive FeedbackNegative Feedback * [Learn how to connect your AI Assistant to Twilio Conversations](/docs/alpha/ai-assistants/code-samples/channel-conversations "Learn how to connect your AI Assistant to Twilio Conversations") --- # AI Assistant Code Samples | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page AI Assistant Code Samples ========================= Positive FeedbackNegative Feedback * * * (warning) Twilio Alpha - Developer Preview -------------------------------- AI Assistants is a [Twilio Alpha(link takes you to an external page)](https://twilioalpha.com "Twilio Alpha") project that's in **Developer Preview**. View the [current limitations](/docs/alpha/ai-assistants/pricing-and-limits "current limitations") for details about feature limits during developer preview. Channels -------- Connect your AI Assistant to your preferred channels [Twilio Conversations](/docs/alpha/ai-assistants/code-samples/channel-conversations) [SMS & WhatsApp](/docs/alpha/ai-assistants/code-samples/channel-messaging) [Website with React](/docs/alpha/ai-assistants/code-samples/react) Example Tools ------------- Give your AI Assistant the ability to perform actions [Transition to Studio Flow](/docs/alpha/ai-assistants/code-samples/transition-studio) [Handoff to Flex Agent](/docs/alpha/ai-assistants/code-samples/transition-flex) For more code samples check out our [AI Assistants Samples repository on GitHub(link takes you to an external page)](https://github.com/twilio-labs/ai-assistants-samples "AI Assistants Samples repository on GitHub") . * * * Public APIs ----------- [public-apis page anchor](#public-apis) Positive FeedbackNegative Feedback Since AI Assistants can trigger any API as Tools, there are lots of Public APIs available to get started with Tools as well. Check out [GitHub(link takes you to an external page)](https://github.com/public-apis/public-apis?tab=readme-ov-file "GitHub") for a comprehensive list of public APIs that you can leverage for your Assistant. --- # Connect your AI Assistant to Twilio Conversations with React | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this pageProducts used [Twilio Conversations DocumentationConversations](/docs/conversations) Connect your AI Assistant to Twilio Conversations with React ============================================================ Positive FeedbackNegative Feedback * * * (warning) Twilio Alpha - Developer Preview -------------------------------- AI Assistants is a [Twilio Alpha(link takes you to an external page)](https://twilioalpha.com "Twilio Alpha") project that's in **Developer Preview**. View the [current limitations](/docs/alpha/ai-assistants/pricing-and-limits "current limitations") for details about feature limits during developer preview. While you can use any of [Twilio's Conversations SDKs(link takes you to an external page)](https://www.twilio.com/docs/conversations/sdk-overview "Twilio's Conversations SDKs") with AI Assistants, there is a dedicated React SDK that provides additional convenience and functionality on top of Twilio Conversations specifically for your AI Assistant use case. The added functionality includes React hooks and UI components powered by [Twilio Paste(link takes you to an external page)](https://paste.twilio.design "Twilio Paste") . This document outlines the steps required to connect your AI Assistant to Twilio Conversations using the React SDK and build a chat interface from the built-in React components. * * * Setup ----- [setup page anchor](#setup) Positive FeedbackNegative Feedback ### Configure Twilio Conversations [configure-twilio-conversations page anchor](#configure-twilio-conversations) Positive FeedbackNegative Feedback The AI Assistants React SDK is built on top of the [Twilio Conversations SDK(link takes you to an external page)](https://www.twilio.com/docs/conversations/sdk-overview "Twilio Conversations SDK") for all messaging communication. To use the SDK, you must first [configure a Twilio Conversations service for your AI Assistant](/docs/alpha/ai-assistants/code-samples/channel-conversations "configure a Twilio Conversations service for your AI Assistant") . ### Generate access tokens [generate-access-tokens page anchor](#generate-access-tokens) Positive FeedbackNegative Feedback Next, [generate client-side access tokens for Twilio Conversations](/docs/conversations/create-tokens "generate client-side access tokens for Twilio Conversations") . When you generate the tokens, the `identity` used to generate the token will be used for any [Customer Memory](/docs/alpha/ai-assistants "Customer Memory") capabilities that you have enabled. ### Install the SDK [install-the-sdk page anchor](#install-the-sdk) Positive FeedbackNegative Feedback The command below uses `npm` to install the Alpha React and Conversations SDKs. Copy code block npm install @twilio-alpha/react @twilio/conversations * * * Use built-in UI components -------------------------- [use-built-in-ui-components page anchor](#use-built-in-ui-components) Positive FeedbackNegative Feedback The React SDK comes with the built-in ability to render a full chat UI by using the `` component. To use the component, you will need both a valid Twilio Conversations access token, which you generated in the steps above, and the SID of your Assistant, which you can find in the [Assistants section of the Twilio Console(link takes you to an external page)](https://console.twilio.com/us1/develop/ai-assistants/assistants "Assistants section of the Twilio Console") . Make sure you replace `` and `` with the respective values. Copy code block 1 import { AssistantChat } from "@twilio-alpha/assistants-react"; 2 3 export function App() { 4 return ; 5 } (warning) Warning ------- The access token is **not** your Twilio Auth Token. It's instead a [Twilio Conversations access token](/docs/conversations/create-tokens "Twilio Conversations access token") . You should generate these on your backend and have your React code fetch the token from your endpoint. * * * Bring your own UI ----------------- [bring-your-own-ui page anchor](#bring-your-own-ui) Positive FeedbackNegative Feedback If you prefer to use your own UI components with an AI Assistant, you can use the `useAssistant` hook instead. It returns both a `messages` array that contains all the messages as well as a `sendMessage` function to send a new message to your Assistant. Below is an example of using the `useAssistant` hook to build a chat UI using only native HTML components. Copy code block 1 import { useAssistant } from "@twilio-alpha/assistants-react"; 2 3 export function App() { 4 const { messages, sendMessage } \= useAssistant("", { 5 assistantSid: "", 6 }); 7 8 function send(evt) { 9 evt.preventDefault(); 10 sendMessage(evt.target.message.value); 11 } 12 13 return ( 14 <> 15 16 {messages.map((message) \=> { 17 return ( 18
  • 19 {message.author}: {message.body} 20 21 ); 22 })} 23 24
    25 26 27 28 29 ); 30 } * * * Reuse existing sessions ----------------------- [reuse-existing-sessions page anchor](#reuse-existing-sessions) Positive FeedbackNegative Feedback By default, every time the `` component and `useAssistant` hook are used, it will create a new Twilio conversation (aka a session). If you want to reuse the existing session between page refreshes, you can use the `conversationSid` property and the `onConversationSetup` handler to persist the session (for example, via [`localStorage`(link takes you to an external page)](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) ). This gives you full control of how you want to manage the session. If you do not provide a `conversationSid`, the component will automatically create one. Copy code block 1 import { useEffect, useState } from "react"; 2 3 export function App() { 4 const \[conversationSid, setConversationSid\] \= useState(); 5 6 useEffect(() \=> { 7 // fetches an existing conversation SID from the local storage if it exists 8 setConversationSid(localStorage.getItem("CONVERSATIONS\_SID") || undefined); 9 }, \[\]); 10 11 function saveConversationSid(sid: string) { 12 localStorage.setItem("CONVERSATIONS\_SID", sid); 13 } 14 15 return ( 16 "} 18 conversationSid\={conversationSid} 19 onConversationSetup\={saveConversationSid} 20 assistantSid\="" 21 /> 22 ); 23 } * * * Use UI Tools to have your Assistant interact with the UI -------------------------------------------------------- [use-ui-tools-to-have-your-assistant-interact-with-the-ui page anchor](#use-ui-tools-to-have-your-assistant-interact-with-the-ui) Positive FeedbackNegative Feedback There are situations where you might want your AI Assistant to not only perform actions in backend systems using APIs, but also interact with the website where the user is chatting with the Assistant. In this case, you can use **UI Tools**. You can use this to have the AI Assistant perform these actions, among others: * fill out a form on the page * show a disclaimer * render a richer UI for output from the Assistant (warning) Warning ------- The current solution is limited and only an initial proof of concept. Note that when the AI Assistant triggers a UI Tool, it does not know whether the Tool action succeeded. To expose UI Tools using the AI Assistants React SDK, pass an object with function handlers into your `` component or your `useAssistant` hook using the `toolHandlers` property, as in the example below. Copy code block 1 import { AssistantChat } from "@twilio-alpha/assistants-react"; 2 3 function fillForm(data) { 4 // data will contain the data that the AI Assistant used to trigger the tool 5 console.log(data); 6 } 7 8 export function App() { 9 return ; 10 } For your AI Assistant to call this Tool, you will have to [configure the Tool within your Assistant's configuration in the Console](/docs/alpha/ai-assistants/tools "configure the Tool within your Assistant's configuration in the Console") . For the `fillForm` example above, the configuration might look similar to this: | Field | Example Configuration | Notes | | --- | --- | --- | | Name | Fill sales request form | Use a name that's descriptive to you and the UI the same way as for any other tool. This will not have to match the name of your function. That name gets configured in the URL. | | Description | Use this to prepopulate a talk to sales form on behalf of the customer. After you trigger this tool, ask the customer to cross check the request and submit it. | Use this description to tell the AI Assistant when to use the tool. | | Input | { // anything you want to send to the UI tool} | The Assistant will pass any data described here to the UI. | | Method | `POST` | | | URL | `https://.twil.io/tools/ui-tools?toolName=` | This URL assumes you've deployed the [AI Assistants Samples code(link takes you to an external page)](https://github.com/twilio-labs/ai-assistants-samples "AI Assistants Samples code")
    into your Twilio account using the instructions in the project.

    The `toolName` value is the name of the function you passed into `toolHandlers`. In this example, it would be `fillForm` | * * * Learn more ---------- [learn-more page anchor](#learn-more) Positive FeedbackNegative Feedback You've now connected your AI Assistant to Twilio Conversations and explored the built-in UI from the React SDK, as well as seen how to bring your own UI and have your Assistant interact with the UI. View the links below to learn more about working with your AI Assistant: * [View a Next.js example application(link takes you to an external page)](https://github.com/twilio-labs/ai-assistants-js/blob/main/examples/next-js-example/src/app/page.tsx "View a Next.js example application") * [Learn how to have your AI Assistant transition a conversation to a Flex agent](/docs/alpha/ai-assistants/code-samples/transition-flex "Learn how to have your AI Assistant transition a conversation to a Flex agent") * [Learn how to have your AI Assistant transition a conversation to a Studio flow](/docs/alpha/ai-assistants/code-samples/transition-studio "Learn how to have your AI Assistant transition a conversation to a Studio flow") --- # Transition to Twilio Flex | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this pageProducts used [Twilio Conversations DocumentationConversations](/docs/conversations) [Twilio Flex DocumentationFlex](/docs/flex) [Twilio TaskRouter DocumentationTaskRouter](/docs/taskrouter) Transition to Twilio Flex ========================= Positive FeedbackNegative Feedback * * * (warning) Twilio Alpha - Developer Preview -------------------------------- AI Assistants is a [Twilio Alpha(link takes you to an external page)](https://twilioalpha.com "Twilio Alpha") project that's in **Developer Preview**. View the [current limitations](/docs/alpha/ai-assistants/pricing-and-limits "current limitations") for details about feature limits during developer preview. Transitions are crucial for keeping humans in the loop and escalating conversations with your AI Assistant when necessary. Currently, these transitions can be configured by giving your AI Assistant a Tool. In the future, Assistants will support native transitions. In this guide, you will learn how to transition a conversation with your AI Assistant to a [Flex](/docs/flex "Flex") agent. * * * Prerequisites ------------- [prerequisites page anchor](#prerequisites) Positive FeedbackNegative Feedback To begin, you will need the following: * A [Twilio Flex](/docs/flex "Twilio Flex") instance. * An AI Assistant in the same Twilio account as the Flex instance. * A webhook connecting your Assistant with Twilio Conversations (see the guide [Use Twilio Conversations as a Channel](/docs/alpha/ai-assistants/code-samples/channel-conversations "Use Twilio Conversations as a Channel") for the steps). * A [TaskRouter Workspace SID and Workflow SID](/docs/taskrouter "TaskRouter Workspace SID and Workflow SID") to hand off the Conversation to the right Workflow. * * * Configure your AI Assistant tool for handover --------------------------------------------- [configure-your-ai-assistant-tool-for-handover page anchor](#configure-your-ai-assistant-tool-for-handover) Positive FeedbackNegative Feedback After you've connected your AI Assistant to Twilio Conversations, your AI Assistant will listen to any message that has only one participant (your customer) in the conversation. To hand off the conversation to a human agent, the AI Assistant has to call a Tool that uses the [Flex Interactions API](/docs/flex/developer/conversations/interactions-api "Flex Interactions API") to hand off to a Flex agent. You can do this either by using a Twilio Function that was already deployed into your Twilio account as part of the Conversations setup above, or by creating your own HTTP endpoint. Either way, once a second participant joins the conversation, your AI Assistant will automatically stop listening. ### Use Twilio Functions for your Handover Tool [use-twilio-functions-for-your-handover-tool page anchor](#use-twilio-functions-for-your-handover-tool) Positive FeedbackNegative Feedback If you followed the [AI Assistants with Twilio Conversations](/docs/alpha/ai-assistants/code-samples/channel-conversations "AI Assistants with Twilio Conversations") guide, one of the [Twilio Functions](/docs/serverless/functions-assets "Twilio Functions") that you deployed as part of this was a Flex Handover tool. To make sure you hand off the conversation to the right Flex agents, configure environment variables for your Twilio Functions that specify the TaskRouter Workspace SID and TaskRouter Workflow SID for the handoff. In the `ai-assistants-samples` project that you cloned and deployed, run the following commands: Copy code block 1 twilio serverless:env:set \--key=FLEX\_WORKFLOW\_SID --value= 2 twilio serverless:env:set \--key=FLEX\_WORKSPACE\_SID --value= Make sure to replace `` and `` with the respective values. To use this webhook as a Tool, you will need your Functions domain from the AI Assistants Samples deployment. If you can't find your Functions domain, head to the [Twilio Console(link takes you to an external page)](https://console.twilio.com/us1/develop/functions/services "Twilio Console") and click on **Service Details** next to your `ai-assistants-samples` Service. You can find the domain in the **Environments** section. Once you have both your Flow SID and your Functions domain, you can go into your [AI Assistant in the Twilio Console(link takes you to an external page)](https://console.twilio.com/us1/develop/ai-assistants/assistants "AI Assistant in the Twilio Console") and create a new Tool with the following configuration: | Field | Example Configuration | Notes | | --- | --- | --- | | Name | Flex Agent Handover | You can modify this if you have multiple handovers. | | Description | You MUST use this if you don't know how to fulfill the request to let another customer service agent handle the conversation. | Use this description to tell the AI Assistant when to use the tool. | | Input | {} | | | Method | `POST` | | | URL | `https://.twil.io/tools/flex-handover` | Make sure to replace `` with your own value. | ### Use your own backend to host your Handover Tool [use-your-own-backend-to-host-your-handover-tool page anchor](#use-your-own-backend-to-host-your-handover-tool) Positive FeedbackNegative Feedback Alternatively to using Twilio Functions for your Tool, you can host an HTTP endpoint yourself and use the [Flex Interactions API](/docs/flex/developer/conversations/interactions-api "Flex Interactions API") to route the conversation to a Flex Agent. Here is an example of calling the API using the Twilio Python helper library: Copy code block 1 interaction \= twilio\_client.flex\_api.v1.interaction.create( 2 channel\={ 3 'type': 'chat', \# can be chat or SMS 4 'initiated\_by': 'customer', 5 'properties': { 6 'media\_channel\_sid': conversation\_sid \# Stored in the \`X-Session-Id\` request header 7 } 8 }, 9 routing\={ 10 'properties': { 11 'workspace\_sid': taskrouter\_workspace\_sid, \# your taskrouter workspace sid 12 'workflow\_sid': taskrouter\_workflow\_sid, \# your taskrouter workflow sid 13 'attributes': { 14 'from': 'Customer Name' \# the name of the customer (you can use the \`X-Identity\` header to look up the customer's identity) 15 } 16 } 17 } 18 ) * * * Learn more ---------- [learn-more page anchor](#learn-more) Positive FeedbackNegative Feedback Now you've configured your AI Assistant to hand off a conversation to a Flex agent if it cannot fulfill a user's request. * [Learn how to add an AI Assistant to your React application](/docs/alpha/ai-assistants/code-samples/react "Learn how to add an AI Assistant to your React application") * [Learn how to have your AI Assistant transition a conversation to a Studio flow](/docs/alpha/ai-assistants/code-samples/transition-studio "Learn how to have your AI Assistant transition a conversation to a Studio flow") --- # Transition to Twilio Studio | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this pageProducts used [Twilio Conversations DocumentationConversations](/docs/conversations) [Twilio Studio DocumentationStudio](/docs/studio) Transition to Twilio Studio =========================== Positive FeedbackNegative Feedback * * * (warning) Twilio Alpha - Developer Preview -------------------------------- AI Assistants is a [Twilio Alpha(link takes you to an external page)](https://twilioalpha.com "Twilio Alpha") project that's in **Developer Preview**. View the [current limitations](/docs/alpha/ai-assistants/pricing-and-limits "current limitations") for details about feature limits during developer preview. There might be situations in which you no longer want your AI Assistant to handle a conversation and instead want it to rely on a more deterministic path using a [Twilio Studio Flow](/docs/studio "Twilio Studio Flow") . In this guide, you will learn how to have your AI Assistant transition a conversation to Studio. * * * Prerequisites ------------- [prerequisites page anchor](#prerequisites) Positive FeedbackNegative Feedback This Assistant handoff requires your conversation to flow through [Twilio Conversations](/docs/conversations "Twilio Conversations") . Follow the guide for using [AI Assistants with Twilio Conversations](/docs/alpha/ai-assistants/code-samples/channel-conversations "AI Assistants with Twilio Conversations") before moving on here. * * * Set up your Studio Flow ----------------------- [set-up-your-studio-flow page anchor](#set-up-your-studio-flow) Positive FeedbackNegative Feedback You will need a [Studio Flow that is configured for the **Incoming Conversation** trigger(link takes you to an external page)](https://www.twilio.com/docs/studio/tutorials/using-conversations-with-studio) . From here, you can use any Studio Widget that is compatible with Conversations. ![Beginning of a Studio flow where the Incoming Conversation trigger flows into a welcome widget](/_next/image?url=https%3A%2F%2Fdocs-resources.prod.twilio.com%2F04e7eef714be8fb04002909ac933c2ea9c9efc9fcc5f94a0aa4b3b707f1fea61.png&w=2048&q=75&dpl=dpl_ATAJdnvkBtxiXJHhvv9SRHz4BYqq)Expand image Make sure to deploy your Studio Flow and copy the Flow SID. * * * Configure your handoff Tool in your AI Assistant ------------------------------------------------ [configure-your-handoff-tool-in-your-ai-assistant page anchor](#configure-your-handoff-tool-in-your-ai-assistant) Positive FeedbackNegative Feedback If you followed the [AI Assistants with Twilio Conversations](/docs/alpha/ai-assistants/code-samples/channel-conversations "AI Assistants with Twilio Conversations") guide, one of the [Twilio Functions](/docs/serverless/functions-assets "Twilio Functions") that you deployed was a Studio Handover tool. To use this webhook as an Assistant Tool, you will need your Functions domain from the deployment. If you can't find your Functions domain, head to the [Twilio Console(link takes you to an external page)](https://console.twilio.com/us1/develop/functions/services "Twilio Console") and click on **Service Details** next to your `ai-assistants-samples` service. You can find the domain in the **Environments** section. Once you have both your Flow SID and your Functions domain, you can go into your [AI Assistant in the Twilio Console(link takes you to an external page)](https://console.twilio.com/us1/develop/ai-assistants/assistants "AI Assistant in the Twilio Console") and create a new Tool with the following configuration: | Field | Example Configuration | Notes | | --- | --- | --- | | Name | Studio Handover | You can modify this if you have multiple handovers. | | Description | You MUST use this if a customer is asking for a refund. | Use this description to tell the AI Assistant when to use the tool. | | Input | {} | | | Method | `POST` | | | URL | `https://.twil.io/tools/studio-handover?flowSid=` | Make sure to replace `` and `` with your own values. | This Tool reroutes the conversation from your Assistant to Studio, but does not forward the last message from the Assistant to the Studio Flow. Instead, the Tool responds with `Conversation handed over`, which might prompt the Assistant to say something like "I handed this conversation over". If you want to manipulate this message, you can pass a different message into the **URL** configuration using the `successMessage` query parameter. * * * Learn more ---------- [learn-more page anchor](#learn-more) Positive FeedbackNegative Feedback You've now learned how to configure an Assistant to hand off a conversation to a Twilio Studio Flow. See more tutorials below: * [Learn how to add an AI Assistant to your React application](/docs/alpha/ai-assistants/code-samples/react "Learn how to add an AI Assistant to your React application") * [Learn how to have your AI Assistant transition a conversation to a Flex agent](/docs/alpha/ai-assistants/code-samples/transition-flex "Learn how to have your AI Assistant transition a conversation to a Flex agent") --- # Customer Memory | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page Customer Memory =============== Positive FeedbackNegative Feedback * * * Customer Memory is a feature that allows an AI Assistant to become customer-aware. By integrating with Twilio Segment, the Assistant can access and store relevant customer data, enabling it to personalize interactions based on previous engagements and customer profiles. Two key engines power this capability: * [**AI Personalization Engine**(link takes you to an external page)](https://twilioalpha.com/personalization-engine) : This engine pulls relevant customer data from Segment, allowing the Assistant to tailor its responses. * [**AI Perception Engine**(link takes you to an external page)](https://twilioalpha.com/perception-engine) : This engine captures relevant data from ongoing conversations and updates the customer profile in Segment, evolving the Assistant's understanding of the customer over time. * * * Configure Customer Memory ------------------------- [configure-customer-memory page anchor](#configure-customer-memory) Positive FeedbackNegative Feedback In the Twilio Console, navigate to the **Segment Workspace** section of [**AI Assistants Settings**(link takes you to an external page)](https://console.twilio.com/us1/develop/ai-assistants/settings) . ### If you already have a Segment workspace with Unify [if-you-already-have-a-segment-workspace-with-unify page anchor](#if-you-already-have-a-segment-workspace-with-unify) Positive FeedbackNegative Feedback 1. Name your workspace for reference from within AI Assistants. 2. Find your Space ID In Segment: From Segment, visit **Unify** -> **Unify Settings** -> **API access** and copy your "space ID" (begins with `spa_`) to the Segment Workspace Space ID field in **AI Assistants Settings**. 3. Profile access token: From the same **API access screen**, click the **Generate Token** button to generate a new Profile access token for your AI Assistants. Store the token value securely, and copy it to the **Segment Workspace Profile Access Token settings** in AI Assistants. 4. Write Key: Required to write data back to Segment. You can either use an existing source or create a new Segment source: * Create a new source: 1. From Segment, view your **Connections** -> **Sources** create a new Node.js source. 2. Click into the new source -> **Settings** -> **API Keys** and copy the 'Write Key' into the **Segment Workspace Write Key setting** in AI Assistants. 3. Connect your new source to your Unify space: Visit **Unify** -> **Unify Settings** -> **Profile sources** and click **Connect source** to add your newly created Node.js source. * Use an existing source: 1. In Segment, go to an existing source -> **Settings** -> **API Keys** and copy the **Write Key** from your new source into the **Segment Workspace Write Key setting** in AI Assistants. ### If you don't have a Segment account [if-you-dont-have-a-segment-account page anchor](#if-you-dont-have-a-segment-account) Positive FeedbackNegative Feedback 1. From **AI Assistants Settings**, create a free Segment account using your Twilio credentials. 2. Once you've created your account, the necessary values will auto populate in the Assistants Segment configuration. * * * Use Customer Memory ------------------- [use-customer-memory page anchor](#use-customer-memory) Positive FeedbackNegative Feedback Once you've configured your Segment settings, you can enable the AI Personalization Engine and AI Perception Engine for each Assistant you create in your Assistant's [base configuration](/docs/alpha/ai-assistants#base-configuration "base configuration") , (Assistant -> Settings). When your Assistant uses either customer engine, it passes the identity associated with that session to Segment. If you're using the API, the `identity` parameter of the `POST` request defines the identity. In the Simulator, you define the identity from the UI. The user identity must match the form: `type:value`, and the `type` field must correlate with an identifier on the profile within Segment. Learn more about identity resolution in the [Segment Unify documentation(link takes you to an external page)](https://segment.com/docs/unify/identity-resolution/identity-resolution-onboarding/ "Segment Unify documentation") . For example: Copy code block 1 "email:example@example.com" 2 // or 3 "phone:15554455" You can debug responses from each engine in the Simulator to understand what data your Assistant is receiving from or sending to Segment. * * * Manage Segment profile data via API ----------------------------------- [manage-segment-profile-data-via-api page anchor](#manage-segment-profile-data-via-api) Positive FeedbackNegative Feedback You can manage your Segment profile data using the [Segment Profile API(link takes you to an external page)](https://segment.com/docs/unify/profile-api/ "Segment Profile API") . --- # FAQs and Troubleshooting | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page FAQs and Troubleshooting ======================== Positive FeedbackNegative Feedback * * * (warning) Twilio Alpha - Developer Preview -------------------------------- AI Assistants is a [Twilio Alpha(link takes you to an external page)](https://twilioalpha.com "Twilio Alpha") project that's in **Developer Preview**. View the [current limitations](/docs/alpha/ai-assistants/pricing-and-limits "current limitations") for details about feature limits during developer preview. * * * FAQs ---- [faqs page anchor](#faqs) Positive FeedbackNegative Feedback ### How much does it cost to use AI Assistants? [how-much-does-it-cost-to-use-ai-assistants page anchor](#how-much-does-it-cost-to-use-ai-assistants) Positive FeedbackNegative Feedback See [Pricing](/docs/alpha/ai-assistants/pricing-and-limits#pricing "Pricing") for the most up-to-date information. ### What are you doing to improve latency? [what-are-you-doing-to-improve-latency page anchor](#what-are-you-doing-to-improve-latency) Positive FeedbackNegative Feedback We are taking an [AI Constellation](/docs/alpha/ai-assistants/ai-constellations "AI Constellation") model approach, which defines which AI models and prompt strategies your AI Assistant will use. They allow you to select from different model types to choose the appropriate LLM provider and logic that best fits your application's needs. Constellations allow your Assistant to leverage a number of available agents to best meet your application's specific needs. This approach will also improve latency. ### How do you go above the current limitations? [how-do-you-go-above-the-current-limitations page anchor](#how-do-you-go-above-the-current-limitations) Positive FeedbackNegative Feedback While AI Assistants are in developer preview, there are feature limitations and system limits in place. Learn more about current limitations in [Limitations](/docs/alpha/ai-assistants/pricing-and-limits "Limitations") . If you want to exceed these limitations, please reach out to our team at [twilioalpha@twilio.com](mailto:twilioalpha@twilio.com "twilioalpha@twilio.com") . ### Is there multilingual support? [is-there-multilingual-support page anchor](#is-there-multilingual-support) Positive FeedbackNegative Feedback AI Assistants can speak in multiple languages, however we've not tested or optimized for multilingual support yet. It is on our roadmap to test and make improvements to multilingual support. In the meantime English is the recommended language for the configuration of your Assistants. If you want your test your Assistant in other languages you can define this in the Personality Prompt: Copy code block Ensure that your responses are always in the same language the customer uses. ### How can you debug issues when interacting through the API? [how-can-you-debug-issues-when-interacting-through-the-api page anchor](#how-can-you-debug-issues-when-interacting-through-the-api) Positive FeedbackNegative Feedback All API requests will still end up in the [Conversation History](/docs/alpha/ai-assistants/api/conversation-history "Conversation History") in near real-time, so you can see what knowledge and tools were called there. Conversation history is available via API and in the Console. ### How do you integrate Twilio channels? [how-do-you-integrate-twilio-channels page anchor](#how-do-you-integrate-twilio-channels) Positive FeedbackNegative Feedback Every Assistant comes with a REST API that you can use to trigger a message. Aside from a `body` you can pass in a `session_id` of your choice (used to maintain message history) and an `identity`. Learn more in the [Channels documentation](/docs/alpha/ai-assistants/channels "Channels documentation") . You can also use [Twilio Quick Deploy](/code-exchange/ai-assistants-samples "Twilio Quick Deploy") to quickly connect your AI Assistant to various channels. ### When should you use Tools versus Knowledge? [when-should-you-use-tools-versus-knowledge page anchor](#when-should-you-use-tools-versus-knowledge) Positive FeedbackNegative Feedback Tools differ from Knowledge in that Tools accomplish specific tasks (for example, looking up the weather or finding directions to a location), whereas Knowledge entries are unstructured data sources that the AI Assistant can reference to ask additional questions (such as your company's policies or documentation). Use Tools when you're looking to take action or fetch specific data. Use Knowledge when you want to interpret an unstructured data set (that is, answering questions or referencing information). * * * Troubleshooting --------------- [troubleshooting page anchor](#troubleshooting) Positive FeedbackNegative Feedback If your AI Assistant is providing unexpected responses or isn't using Tools or Knowledge as intended, this troubleshooting guide can help you identify and resolve common issues. Follow the steps below to check and address potential problems with your Assistant's performance. ### Test in the simulator for immediate feedback [test-in-the-simulator-for-immediate-feedback page anchor](#test-in-the-simulator-for-immediate-feedback) Positive FeedbackNegative Feedback **Issue**: You need to understand how the Assistant processes requests and where it might be deviating from expected behavior. **Solution**: Use the Simulator to test various queries and review the Assistant's decision-making process. This lets you see which configuration, Tools, or Knowledge entries the Assistant uses and provides insight into potential misconfigurations. _Tip_: Take note of specific responses that seem off and check if the Assistant is defaulting to an unintended Tool or Knowledge source. Adjust descriptions or configurations as needed. ### Inspect Tool and Knowledge configurations [inspect-tool-and-knowledge-configurations page anchor](#inspect-tool-and-knowledge-configurations) Positive FeedbackNegative Feedback **Issue**: The Assistant isn't using specific Tools or Knowledge sources as expected. **Solution**: Check the configurations for each Tool and Knowledge source: * For Tools: Ensure each Tool is correctly defined with the proper attributes (name, description, input schema, HTTP method, etc.). Verify that the Assistant has access to all necessary endpoints. * For Knowledge sources: Confirm that the Knowledge entries are indexed and that the Assistant has completed processing them. If a Knowledge entry is outdated, refresh it manually or enable auto-update. _Tip_: Check that the descriptions for Tools and Knowledge sources are clear and help the Assistant determine when to use them. Ambiguous descriptions may lead to unexpected usage. For example, here's a draft Knowledge source: _Name_: Employee Handbook Ineffective description Company policies Effective description This is the employee handbook provided to every new employee at Twilio. Use this source to provide answers about company HR, Payroll, and Workforce policies including things like travel and expense policies, payroll schedules, company holidays, and how to get in touch with the People team. ### Review personality prompt and configuration settings [review-personality-prompt-and-configuration-settings page anchor](#review-personality-prompt-and-configuration-settings) Positive FeedbackNegative Feedback **Issue**: The Assistant's tone or style doesn't match your configuration, or it isn't providing responses aligned with its personality prompt. **Solution**: Open the Assistant's personality prompt configuration and ensure it reflects the desired tone, voice, and purpose. If you recently made updates to the prompt, test to confirm they were saved properly. _Tip_: Use concise and clear language in your prompt, and avoid overly complex instructions, as these can lead to ambiguous responses. For example: Ineffective prompt Help customers find items they want in the store catalog. Give recommendations. Effective prompt As a helpful retail assistant, your goal is to assist customers in finding products that match their preferences and budget. Engage in friendly, conversational dialogue, asking clarifying questions if details are missing (such as product size, color, or type). Provide thoughtful recommendations, keeping responses concise and relevant. Always confirm the customer's preferences before proceeding with suggestions, and offer 2-3 options per query. If you can't find an exact match, suggest similar alternatives and be clear about differences. ### Verify Customer Memory settings [verify-customer-memory-settings page anchor](#verify-customer-memory-settings) Positive FeedbackNegative Feedback **Issue**: The Assistant isn't remembering customer interactions or using previous data effectively. **Solution**: Confirm that Customer Memory is enabled and configured correctly. Check that the integration with Twilio Segment is active and that data is being stored and retrieved properly. _Tip_: If customer data is not updating as expected, check the AI Perception Engine settings to ensure conversation data is being captured in Segment. ### Review API call and logging details [review-api-call-and-logging-details page anchor](#review-api-call-and-logging-details) Positive FeedbackNegative Feedback **Issue**: API calls aren't producing expected results, or responses contain errors. **Solution**: Inspect recent API calls to and from your Assistant for errors or unexpected data. Review logs for any failed API calls or unusual response codes. _Tip_: Verify that authentication and access tokens are valid and correctly configured. If you're using custom endpoints, confirm they're accessible from Twilio and returning expected data. ### Contact Twilio for additional assistance [contact-twilio-for-additional-assistance page anchor](#contact-twilio-for-additional-assistance) Positive FeedbackNegative Feedback **Issue**: After following the troubleshooting steps, your Assistant still isn't functioning as expected. **Solution**: If issues persist, reach out to [twilioalpha@twilio.com](mailto:twilioalpha@twilio.com "twilioalpha@twilio.com") for assistance. Provide detailed examples of unexpected behavior, relevant logs, and any troubleshooting steps you've taken. Please provide your [Twilio Account SID(link takes you to an external page)](https://console.twilio.com/user/accounts "Twilio Account SID") , and the specific [AI Assistant ID(link takes you to an external page)](https://console.twilio.com/us1/develop/ai-assistants/assistants "AI Assistant ID") (found under "My Assistants") and session ID (found in the [Conversation History(link takes you to an external page)](https://console.twilio.com/us1/develop/ai-assistants/conversations "Conversation History") ) if the issue pertains to a specific conversation. _Tip_: Gather as much information as possible before contacting support, as this will help expedite the resolution process. --- # Knowledge | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page Knowledge ========= Positive FeedbackNegative Feedback * * * The Knowledge feature in Twilio AI Assistants allows you to provide your Assistant with access to unstructured data sources, such as knowledge bases, company policies, documentation, and more. This enables the Assistant to pull relevant information during interactions, helping to answer customer questions with greater accuracy and context. Unlike [Tools](/docs/alpha/ai-assistants/tools "Tools") , which are designed for specific tasks, Knowledge sources allow the Assistant to reference a broader range of content to provide more informed responses. * * * Configure Knowledge sources --------------------------- [configure-knowledge-sources page anchor](#configure-knowledge-sources) Positive FeedbackNegative Feedback Configuring Knowledge sources for your AI Assistant involves configuring attributes that define how the Assistant uses the source. The Knowledge you create is processed asynchronously. Once processing is complete, you'll see a **completed** status next to your Knowledge entry in the Console. The Assistant will then evaluate whether the Knowledge entry could be useful for answering a customer's question. This process is similar to how Tools are utilized, but instead of generating structured data for a Tool, the Assistant formulates a question and retrieves relevant information from the unstructured data you provided. ### Knowledge attributes [knowledge-attributes page anchor](#knowledge-attributes) Positive FeedbackNegative Feedback | Attribute name | Description | Example | | --- | --- | --- | | Name | The name of your knowledge source. It should be short and distinct and at least 5 characters. | Shakespeare's Plays | | Description | A short summary of the source data. Be clear and concise, so the Assistant knows exactly what types of information this source contains. This description is used by the Assistant to determine when to use this knowledge. | The Complete Works of William Shakespeare. Use this to answer questions about any of Shakespeare's plays and whenever you reference a specific quote from the plays. | | Data type | The form of data you'll provide the Assistant. Supported options are: `website`, `raw text`, `file upload`, `external vector database` | | | \[Website\]
    URL | A publicly-accessible URL containing helpful information for the Assistant. | `https://shakespeare.mit.edu/` | | \[Website\]
    Page depth | Specifies the number of link levels deep the Assistant should crawl and import content from a website, with each level representing one additional click away from the starting page. The Assistant will crawl the site up to 3 levels deep, with a 500 page maximum during the developer preview. Ensure that all pages you want to include are within the specified domain. | 2 | | \[Website\]
    Auto-Update | How often we should regularly re-import a live website. | Never | | \[Raw text\]
    Manual text | Upload text directly, which the Assistant can reference during interactions. | Shakespeare's Tragedies: Antony and Cleopatra, Coriolanus, Cymbeline, Hamlet, Julius Caesar, King Lear, Macbeth, Othello, Romeo and Juliet, Timon of Athens, Titus Andronicus, Troilus and Cressida | | \[File upload\]
    File | This file to import as knowledge available to the agent. We currently support the following file formats: `.csv`, `.doc`, `.docx`, `.jsonl`, `.md`, `.mdx`, `.msg`, `.pdf`, `.ppt`, `.pptx`, `.tsv`, `.txt`, `.xlsx`. Max file size is 16MB. | example.pdf | | \[External vector database\]
    Provider | Integrate with your own vector database, currently only supporting Pinecone with a dimension of 1536 and the `text-embedding-ada-002` embedding model. (More embedding models will be supported in the future) | Pinecone | | \[External vector database\]
    Index | The name of the index in your external DB. | 'works-of-shakespeare' | | Advanced Settings > Use response as final answer | When checked, responses from this Knowledge source will be used as definitive answer and the Assistant will not use any other tools to create a response. | \[unchecked\] | * * * Manage your Knowledge base -------------------------- [manage-your-knowledge-base page anchor](#manage-your-knowledge-base) Positive FeedbackNegative Feedback Regularly update and organize your Knowledge sources to ensure the Assistant has access to the most accurate and relevant information. This includes adding new entries, updating existing ones, and removing outdated content. * * * Troubleshooting --------------- [troubleshooting page anchor](#troubleshooting) Positive FeedbackNegative Feedback **If your Assistant isn't referencing Knowledge as expected** Try modifying your 'description' for the Knowledge source to be more specific about when to reference it. For example: "Use this Knowledge when the user asks ANY question about Shakespeare's plays." **If your Assistant is referencing the Knowledge source but Knowledge responds with 'I don't know'** You can 'View Details' of the indexed chunks of your Knowledge source from the additional actions menu on your list of Knowledge. This can help you determine whether your Knowledge source was indexed correctly. Additionally, from the same menu you can manually refresh your Knowledge source if it becomes outdated and wasn not set to auto-update. * * * Best practices -------------- [best-practices page anchor](#best-practices) Positive FeedbackNegative Feedback To maximize the effectiveness of the Knowledge feature in your AI Assistant, consider the following best practices: 1. **Assess and optimize content**: Regularly evaluate your existing Knowledge sources for accuracy, relevance, and coverage. Identify any gaps or outdated information that could hinder the Assistant's performance. 2. **Simplify and structure content**: Ensure that the content is clear and concise. Use headings, bullet points, and metadata to make information straightforward to navigate for both the AI Assistant and your users. 3. **Prioritize high-impact content**: Focus on updating and maintaining content that is frequently accessed or critical to customer interactions. Consider using analytics to determine which Knowledge entries are most valuable. --- # How to Track Human Feedback | Twilio [Skip to navigation](#twilio-docs-sidebar-nav) [Skip to topbar](#twilio-docs-topbar) [Twilio Logo\ \ Twilio Docs](/docs) Search Search Search On this page How to Track Human Feedback =========================== Positive FeedbackNegative Feedback * * * Keeping track of user feedback is a critical aspect of improving the quality of any AI system. With AI Assistants, there are two ways you can track feedback: * [In the Simulator](/docs/alpha/ai-assistants/guides/feedback#track-feedback-in-the-simulator "In the Simulator") : track your own feedback while developing your Assistants. * [Via the API](/docs/alpha/ai-assistants/guides/feedback#track-feedback-via-api "Via the API") : track feedback from your users once the Assistant is integrated into your application. (information) Info ---- The Feedback API currently supports **tracking** and **reading** feedback only. We recommend starting to track feedback now so it can be retroactively analyzed with upcoming analytical features. * * * Track Feedback in the Simulator ------------------------------- [track-feedback-in-the-simulator page anchor](#track-feedback-in-the-simulator) Positive FeedbackNegative Feedback As you are developing with AI Assistants, you can use the [Simulator](/docs/alpha/ai-assistants/simulator "Simulator") to test your Assistant and understand what's happening behind the scenes. When you encounter particularly good or bad responses, you can provide feedback about the response using the "thumbs up" and "thumbs down" controls below the message. ![thumbs up and down buttons below a message from an AI Assistant.](/_next/image?url=https%3A%2F%2Fdocs-resources.prod.twilio.com%2F5176009dc4accc8a782a28fbd96fc85ca1cc6b69b5868e3f552642fd79b8d20f.png&w=640&q=75&dpl=dpl_ATAJdnvkBtxiXJHhvv9SRHz4BYqq)Expand image * * * Track Feedback via API ---------------------- [track-feedback-via-api page anchor](#track-feedback-via-api) Positive FeedbackNegative Feedback When your Assistant is integrated into your own application, your customers are the best judges of the quality of its responses. You can store user feedback collected from your application using the Feedback API. Feedback is represented in a `score` from `0` (worst possible message) to `1` (best possible message). You can use this as a binary, such as `thumbs down` = `0` and `thumbs up` = `1`, or introduce your own scale. Additionally, you can include an optional `text` property with any notes attached to the feedback, such as whether an issue was resolved. | Property | Type | Example | | --- | --- | --- | | `session_id` | ID of the Assistant session where the user provided feedback. | "demo-session" | | `score` | The score of the feedback `score` from 0 (worst) to 1 (best). | 1 | | `text` | Notes to attach to the Feedback record, such as whether an issue was resolved | "problem resolved" | Track feedback for entire session[Link to code sample: Track feedback for entire session](#code-track-feedback-for-entire-session) Copy code block 1 ASSISTANT\_SID\= 2 curl \-X POST \-H 'Content-Type:application/json' \\ 3 https://assistants.twilio.com/v1/Assistants/$ASSISTANT\_SID/Feedbacks \\ 4 \-d '{"session\_id":"demo", "score": 1, "text": "problem resolved" }' \\ 5 \-u $TWILIO\_ACCOUNT\_SID:$TWILIO\_AUTH\_TOKEN ### Output Copy output 1 { 2 "assistant\_id": "aia\_asst\_11111111-aaaa-bbbb-cccc-222222222222", 3 "created\_at": "", 4 "id": null, 5 "message\_id": "", 6 "score": 1, 7 "session\_id": "example", 8 "text": "problem resolved", 9 "updated\_at": "" 10 } * * * View Feedback via API --------------------- [view-feedback-via-api page anchor](#view-feedback-via-api) Positive FeedbackNegative Feedback The following API endpoint displays all feedback received for a specific Assistant via the Simulator or the API. Feedback is not currently viewable in the Twilio Console. Get all feedback[Link to code sample: Get all feedback](#code-get-all-feedback) Copy code block 1 ASSISTANT\_SID\= 2 curl \-X GET \-H 'Content-Type:application/json' \\ 3 https://assistants.twilio.com/v1/Assistants/$ASSISTANT\_SID/Feedbacks \\ 4 \-u $TWILIO\_ACCOUNT\_SID:$TWILIO\_AUTH\_TOKEN ### Output Copy output 1 \[\ \ 2\ \ {\ \ 3\ \ "assistant\_id": "aia\_asst\_11111111-aaaa-bbbb-cccc-222222222222",\ \ 4\ \ "message\_id": "7ea35776-9b68-4b39-a2f6-d60e3d25580f",\ \ 5\ \ "score": 0,\ \ 6\ \ "session\_id": "example"\ \ 7\ \ },\ \ 8\ \ {\ \ 9\ \ "assistant\_id": "aia\_asst\_11111111-aaaa-bbbb-cccc-222222222222",\ \ 10\ \ "message\_id": "",\ \ 11\ \ "score": 1,\ \ 12\ \ "session\_id": "example",\ \ 13\ \ "text": "problem resolved"\ \ 14\ \ }\ \ 15\ \ \] ---