Skip to contentSkip to navigationSkip to topbar
On this page

Assistants Resource


Create and configure Assistants programatically using the REST API.


Assistant Properties

assistant-properties page anchor
Property nameTypeRequiredDescriptionChild properties
account_sidSID<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

customer_aiobjectrequired

The Personalization and Perception Engine settings.


idstringrequired

The Assistant ID.

Pattern: ^aia_asst_*$

modelstringrequired

The default model used by the assistant.


namestringrequired

The name of the assistant.


ownerstringrequired

The owner/company of the assistant.


urlstring

Optional

The url of the assistant resource.


personality_promptstringrequired

The personality prompt to be used for assistant.


date_updatedstring<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
customer_aiobject

Optional

The Personalization and Perception Engine settings.


namestringrequired

The name of the assistant.


ownerstring

Optional

The owner/company of the assistant.


personality_promptstring

Optional

The personality prompt to be used for assistant.


segment_credentialobject

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

Output

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": "name",
9
"owner": "owner",
10
"personality_prompt": "personality_prompt",
11
"url": "url"
12
}

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

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

Output

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

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

Output

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": "url",
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
idstringrequired
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();

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.