Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Quickstart - Set Up Your First Assistant


(warning)

Twilio Alpha - Developer Preview

AI Assistants is a Twilio Alpha(link takes you to an external page) project that's in Developer Preview. To request access, please join the waitlist(link takes you to an external page).

View the current limitations for details about feature limits during developer preview.

This Quickstart will guide you through creating your first AI Assistant in the Twilio Console.

An Assistant configuration consists of the following aspects:

  • Base Configuration: This is where you give your Assistant a name and personality and additional configurations such as connections to Segment(link takes you to an external page) .
  • Tools: Tools enable your Assistant to interact with APIs to solve tasks. For security purposes, Tools are purpose-built webhooks/APIs and should not be generalized APIs.
  • Knowledge: Knowledge is a collection of unstructured data (such as knowledge bases) that you want your Assistant to be able to use to answer questions.

Learn more about these Assistant features in the AI Assistant Overview.

At the end of this Quickstart, you'll have an AI Assistant that can answer questions about recent Twilio news using the Twilio blog and about Disney characters using the Disney API.


Configure your first Assistant

configure-your-first-assistant page anchor

Navigate to the Twilio Console(link takes you to an external page) and choose to create a new Assistant. Give it a name that's memorable to you. This name is not used in any customer-facing use cases and is purely for you to identify your Assistant.

Once you've created your Assistant, the first step is to give your Assistant a personality using the Personality Prompt. If you have built with Large Language Models (LLM) before, this is similar to a System Prompt but more high-level rather than fixed steps. If you have never worked with an LLM before, think of the Personality Prompt like the context you would give an employee on day one. Learn more about the Personality Prompt in the AI Assistant overview.

For this Quickstart, use this as an example Personality Prompt:


_10
Your name is Charles, a customer service agent for Twilio. You are friendly and should always great people with "Ahoy" and prefer first names over last names to keep things casual.

Copy this into your configuration and save.


Send an initial test message

send-an-initial-test-message page anchor

Every Assistant comes with a built-in Simulator that you can use to test your Assistant. To open the Simulator, click Open Simulator at the top right of your configuration.

To create a new session in the Simulator in Console, click the + button at the top right. Start by entering the identity email:demo@example.com (you can change this later when you begin to use CustomerAI features).

Send a message like "Hello" or ask some questions like "How do I send an SMS?". You have not connected any Knowledge yet, so any responses will be powered by the Assistant's underlying LLM and might be wrong.


Right now your Assistant will have some base knowledge from the underlying model but this information might be outdated and your Assistant might end up returning inaccurate information. You can change this by adding a Knowledge source.

Go to the Knowledge tab in your Assistant configuration and add a new Knowledge entry. For this example, use Twilio's blog as the Knowledge source. Enter the following configuration details:

FieldConfiguration
NameTwilio Blog
DescriptionUse this for any information about what Twilio is working on lately
TypeWebsite
URLhttps://www.twilio.com/en-us/blog
Page Depth1

When you hit Save, your Assistant will begin crawling the URL provided at the specified page depth for any link in the same domain. This might take a moment, but once the dialog closes, your Assistant has gathered the relevant information.

Test this new source by going back into the Simulator and writing a message along the lines of "What is Twilio working on lately?". You should see your Assistant ask a question to your new Knowledge source, and once it receives the necessary information, it will craft the response.

Now your Assistant has one Knowledge entry. Next, you'll add the first Tool to your Assistant.


Knowledge entries are unstructured data sources, whereas Tools are how your Assistant can perform HTTP requests for specific tasks. You can use the Tool's description and name to give your Assistant information on when the Tool should be triggered.

You can define what the Tool's input should looks like with a TypeScript type definition interface, but it will ultimately be up to the Assistant to decide what the input will be based on the Assistant's interaction with the end user.

This example will use the disneyapi.com as the Assistant's first Tool.

Start by going into the Tools section of your Assistant and add a new Tool. Fill out the configuration using the following values:

FieldConfiguration
NameDisney Characters
DescriptionUse this tool for information about Disney characters, such as which films or video games they appear in.
Input
{
name: string; // name of the character
}
MethodGET
URLhttps://api.disneyapi.dev/character?pageSize=2

Save this configuration and go back into the Simulator. Send a message such as: "What Disney games does Moana appear in?"

You should see your Assistant make a request to the new Disney API tool to retrieve the information about your question.


Triggering your Assistant using the API

triggering-your-assistant-using-the-api page anchor

Every Assistant comes with a REST API that you can use to trigger a message, rather than using the Simulator. Aside from a request body, you can pass in a SessionId of your choice to maintain and identify the message history and an Identity for the end user.

You will need your Assistant's SID and your Twilio Account SID and Authentication Token to make this request. You can find your Assistant's SID in the Assistant section of the Twilio Console, and find your Account SID and Auth Token from the Twilio Console homepage(link takes you to an external page) under Account Info.

Send your first message to your AI Assistant using the following curl example:


_10
ASSISTANT_SID=<your-assistant-sid>
_10
TWILIO_ACCOUNT_SID=<your-account-sid>
_10
TWILIO_AUTH_TOKEN=<your-auth-token>
_10
curl -X POST -H 'Content-Type:application/json' \
_10
https://assistants.twilio.com/v1/$ASSISTANT_SID/Messages \
_10
-d '{"Identity":"user_id:example", "SessionId": "demo", "Body":"Ahoy there"}' \
_10
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN


Now you've created your first Assistant that can have conversations with users and answer questions about Twilio news and Disney characters! You can continue exploring by adding more Knowledge sources and Tools to this Assistant, and explore the rest of the Assistant documentation to learn more about what you can build.


Rate this page: