AI Assistants is a Twilio Alpha project that's in Developer Preview.
View the current limitations for details about feature limits during developer preview.
By connecting your AI Assistant to Twilio Conversations, you can have your AI Assistant available across the variety of channels that Twilio Conversations supports.
This connection also enables:
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.
If you don't have a Twilio Conversations service yet, start by creating a new service.
You will also need the Twilio CLI and Serverless Toolkit installed on your machine for this guide.
To trigger your AI Assistant based on incoming messages to your Twilio Conversations service, you will need to configure Twilio Conversation webhooks. The 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 and deploy the Twilio Functions from the repository into your Twilio account.
1git clone git@github.com:twilio-labs/ai-assistants-samples.git2cd ai-assistants-samples3npm install4cp .env.example .env5# you can ignore editing the .env if you don't intend to use other tools in the project67twilio serverless:deploy
After running the commands above, your output should look similar to this:
1Deployment Details2Domain: ai-assistants-samples-1111-dev.twil.io3Service:4ai-assistants-samples (ZSf3510841424c854e3f3b282550211111)5Environment:6dev (ZE94900e7f2a2c330b15cf6e1c9fd11111)7Build SID:8ZB2743d62d52d42ccd55873a0bcd5111119Runtime:10node1811View Live Logs:12https://www.twilio.com/console/functions/editor/ZSf3510841424c854e3f3b282550211111/environment/ZE94900e7f2a2c330b15cf6e1c9fd1111113Functions:14[protected] https://ai-assistants-samples-1111-dev.twil.io/channels/conversations/messageAdded15[protected] https://ai-assistants-samples-1111-dev.twil.io/channels/messaging/incoming16[protected] https://ai-assistants-samples-1111-dev.twil.io/channels/conversations/response17[protected] https://ai-assistants-samples-1111-dev.twil.io/channels/messaging/response18https://ai-assistants-samples-1111-dev.twil.io/tools/flex-handover19https://ai-assistants-samples-1111-dev.twil.io/tools/google-maps20https://ai-assistants-samples-1111-dev.twil.io/tools/internet-search21https://ai-assistants-samples-1111-dev.twil.io/tools/studio-handover22Assets:
Make sure you take note of the output behind Domain
, which is your Functions URL.
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 and selecting Webhooks in the menu to define a service-wide webhook, or by running the following command using the Twilio CLI:
1twilio api:conversations:v1:services:configuration:webhooks:update \2--post-webhook-url=https://<your-functions-domain>.twil.io/channels/conversations/messageAdded?AssistantSid=<your-assistant-sid>3--chat-service-sid=<your-conversations-service-sid>4--filter=onMessageAdded
Make sure you replace <your-functions-domain>
, <your-assistant-sid>
, and <your-conversations-service-sid>
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.
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 to get started or check out the guide for using AI Assistants with React.