Skip to contentSkip to navigationSkip to topbar
On this page

Assistants Resource


Create and configure Assistants programmatically using the REST API.


Assistant Properties

assistant-properties page anchor
Property nameTypeRequiredDescriptionChild properties
accountSidSID<AC>
required
Not PII

The SID of the Account that created the Assistant resource.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

customerAiobject
required

The Personalization and Perception Engine settings.


idstring
required

The Assistant ID.

Pattern: ^aia_asst_*$

modelstring
required

The default model used by the assistant.


namestring
required

The name of the assistant.


ownerstring
required

The owner/company of the assistant.


urlstring

Optional

The url of the assistant resource.


personalityPromptstring
required

The personality prompt to be used for assistant.


dateUpdatedstring<date-time>
required

The date and time in GMT when the Assistant was last updated specified in ISO 8601(link takes you to an external page) format.


POST https://assistants.twilio.com/v1/Assistants

Request body parameters

request-body-parameters page anchor
Encoding type:application/json
Schema
Property nameTypeRequiredDescriptionChild properties
customerAiobject

Optional

The Personalization and Perception Engine settings.


namestring
required

The name of the assistant.


ownerstring

Optional

The owner/company of the assistant.


personalityPromptstring

Optional

The personality prompt to be used for assistant.


segmentCredentialobject

Optional

The Segment Credentials to be used for the assistant.

Create an AssistantLink to code sample: Create an Assistant
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();

Response

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": "Miss Christine Morgan",
9
"owner": "owner",
10
"personality_prompt": "personality_prompt",
11
"url": "https://www.example.com"
12
}

GET https://assistants.twilio.com/v1/Assistants/{id}

Property nameTypeRequiredPIIDescription
idstring
required
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();

Response

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": "https://www.example.com",
17
"embedding_model": "embedding_model",
18
"date_created": "2009-07-06T20:30:00Z",
19
"date_updated": "2009-07-06T20:30:00Z"
20
}
21
],
22
"model": "model",
23
"name": "Miss Christine Morgan",
24
"owner": "owner",
25
"personality_prompt": "personality_prompt",
26
"tools": [
27
{
28
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
29
"description": "description",
30
"enabled": false,
31
"id": "aia_tool",
32
"meta": {},
33
"name": "name",
34
"requires_auth": false,
35
"type": "type",
36
"url": "https://www.example.com",
37
"date_created": "2009-07-06T20:30:00Z",
38
"date_updated": "2009-07-06T20:30:00Z"
39
}
40
],
41
"url": "https://www.example.com"
42
}

GET https://assistants.twilio.com/v1/Assistants

Property nameTypeRequiredPIIDescription
pageinteger

Optional

The page index. This value is simply for client state.

Minimum: 0

pageSizeinteger

Optional

How many resources to return in each list page. The default is 50, and the maximum is 1000.

Minimum: 1Maximum: 1000

pageTokenstring

Optional

The page token. This is provided by the API.

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();

Response

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": "https://www.example.com",
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 https://assistants.twilio.com/v1/Assistants/{id}

Property nameTypeRequiredPIIDescription
idstring
required
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();