Skip to contentSkip to navigationSkip to topbar
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.

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 or APIs and shouldn't be general 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 core components 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:

Your name is Mick, and you are a Disney expert. You are friendly and should always greet people the first time with "Oh, boy! Hiya, pal!" 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 Twilio's AI features).

Send a message like "Hello" or ask questions like "What is the best Disney movie?" You haven't connected any Knowledge yet, so any responses are entirely generated 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 out of date 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 the Wikipedia entry on The Walt Disney Company as the Knowledge source. Enter the following configuration details:

FieldConfiguration
NameThe Walt Disney Company Wikipedia
DescriptionUse this to answer general questions about The Walt Disney Company, including things like its history, company units, leadership, financial data, legacy, and awards.
TypeWebsite
URLhttps://en.wikipedia.org/wiki/The_Walt_Disney_Company
Page Depth0

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 Status is marked Complete, your Assistant has gathered the relevant information.

Test this new source by going back into the Simulator and asking a specific question like: "How much revenue did The Walt Disney Company make in 2007?" 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 to trigger the Tool.

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

This example will use the Disney Characters API 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, make sure the toggle for your Tool is on, 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:

1
ASSISTANT_SID=<your-assistant-sid>
2
TWILIO_ACCOUNT_SID=<your-account-sid>
3
TWILIO_AUTH_TOKEN=<your-auth-token>
4
curl -X POST -H 'Content-Type:application/json' \
5
https://assistants.twilio.com/v1/Assistants/$ASSISTANT_SID/Messages \
6
-d '{"identity":"user_id:example", "session_id": "demo", "body":"Ahoy there"}' \
7
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

Now you've created your first Assistant that can have conversations with users and answer questions about The Walt Disney Company! 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.

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.