AI Assistants is a Twilio Alpha project that's in Developer Preview. To request access, please join the waitlist.
View the 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 Conversations. To get started, you will need the following:
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.
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 and deploy the Twilio Functions into your Twilio account.
_10git clone git@github.com:twilio-labs/ai-assistants-samples.git_10cd ai-assistants-samples_10npm install_10cp .env.example .env _10# you can ignore editing the .env if you don't intend to use other tools in the project_10_10twilio serverless:deploy
After running the above commands, your output should look similar to this:
_22Deployment Details_22Domain: ai-assistants-samples-1111-dev.twil.io_22Service:_22 ai-assistants-samples (ZSf3510841424c854e3f3b282550211111)_22Environment:_22 dev (ZE94900e7f2a2c330b15cf6e1c9fd11111)_22Build SID:_22 ZB2743d62d52d42ccd55873a0bcd511111_22Runtime:_22 node18_22View Live Logs:_22 https://www.twilio.com/console/functions/editor/ZSf3510841424c854e3f3b282550211111/environment/ZE94900e7f2a2c330b15cf6e1c9fd11111_22Functions:_22 [protected] https://ai-assistants-samples-1111-dev.twil.io/channels/conversations/messageAdded_22 https://ai-assistants-samples-1111-dev.twil.io/channels/messaging/incoming_22 [protected] https://ai-assistants-samples-1111-dev.twil.io/channels/conversations/response_22 https://ai-assistants-samples-1111-dev.twil.io/channels/messaging/response_22 https://ai-assistants-samples-1111-dev.twil.io/tools/flex-handover_22 https://ai-assistants-samples-1111-dev.twil.io/tools/google-maps_22 https://ai-assistants-samples-1111-dev.twil.io/tools/internet-search_22 https://ai-assistants-samples-1111-dev.twil.io/tools/studio-handover_22Assets:
Make sure you take note of the output behind Domain
; this is your Functions URL.
If you use the Twilio Console, open your SMS-capable phone number of choice or Messaging Service in the Twilio Console and configure the When a message comes in webhook to point to: https://<your-functions-domain>.twil.io/channels/messaging/incoming?AssistantSid=<your-assistant-sid>
.
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:
_10twilio phone_number <your-twilio-number> \_10 --sms-url=https://<your-functions-domain>.twil.io/channels/messaging/incoming?AssistantSid=<your-assistant-sid>
Make sure you replace <your-functions-domain>
and <your-assistant-sid>
with the respective values from the steps above. You can find your Assistant's SID in the AI Assistants section of the Twilio Console.
If you are using the WhatsApp Sandbox for this guide, configure your When a message comes in webhook in the WhatsApp Sandbox Settings to point to https://<your-functions-domain>.twil.io/channels/messaging/incoming?AssistantSid=<your-assistant-sid>
Make sure you replace <your-functions-domain>
and <your-assistant-sid>
with the respective values from the steps above.
Send a message to your Twilio phone number or WhatsApp sandbox, and you should receive a response from your AI Assistant.