Skip to contentSkip to navigationSkip to topbar
On this page

Assistant Knowledge Resource


Manage Knowledge sources connected to an Assistant


Knowledge Properties

knowledge-properties page anchor
Property nameTypeRequiredDescriptionChild properties
descriptionstring

Optional

Not PII

The type of knowledge source.


idstring

Optional

The description of knowledge.

Pattern: ^aia_know_*$

account_sidSID<AC>

Optional

The SID of the Account that created the Knowledge resource.

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

knowledge_source_detailsobject

Optional

The details of the knowledge source based on the type.


namestring

Optional

The name of the knowledge source.


statusstring

Optional

The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED')


typestring

Optional

The type of knowledge source ('Web', 'Database', 'Text', 'File')


urlstring

Optional

The url of the knowledge resource.


date_updatedstring<date-time>

Optional

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


List all Knowledge sources connected to an Assistant

list-all-knowledge-sources-connected-to-an-assistant page anchor
GET https://assistants.twilio.com/v1/Assistants/{assistantId}/Knowledge

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
assistantIdstringrequired

The assistant ID.

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.

List Knowledge sources connected to an AssistantLink to code sample: List Knowledge sources connected to 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 listKnowledgeByAssistant() {
11
const assistantsKnowledges = await client.assistants.v1
12
.assistants("aia_asst_00000000-1111-2222-3333-444444444444")
13
.assistantsKnowledge.list({ limit: 20 });
14
15
assistantsKnowledges.forEach((a) => console.log(a.description));
16
}
17
18
listKnowledgeByAssistant();

Output

1
{
2
"knowledge": [
3
{
4
"description": "description",
5
"id": "aia_know",
6
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"knowledge_source_details": {},
8
"name": "name",
9
"status": "status",
10
"type": "type",
11
"url": "url",
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
}

Connect a Knowledge source to an Assistant

connect-a-knowledge-source-to-an-assistant page anchor
POST https://assistants.twilio.com/v1/Assistants/{assistantId}/Knowledge/{id}

After you've created a Knowledge source using the /v1/Knowledge endpoint, you must connect it to an Assistant to allow that Assistant to use the Knowledge.

Property nameTypeRequiredPIIDescription
assistantIdstringrequired

The assistant ID.


idstringrequired

The knowledge ID.

Connect a Knowledge source to an AssistantLink to code sample: Connect a Knowledge source to 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 createAssistantKnowledgeAttachment() {
11
const assistantsKnowledge = await client.assistants.v1
12
.assistants("aia_asst_00000000-1111-2222-3333-444444444444")
13
.assistantsKnowledge("aia_knowledge")
14
.create();
15
16
console.log(assistantsKnowledge.sid);
17
}
18
19
createAssistantKnowledgeAttachment();

Detach a Knowledge source from an Assistant

detach-a-knowledge-source-from-an-assistant page anchor
DELETE https://assistants.twilio.com/v1/Assistants/{assistantId}/Knowledge/{id}

This endpoint removes a Knowledge source from your Assistant's configuration, so it can no longer be used by that Assistant.

Property nameTypeRequiredPIIDescription
assistantIdstringrequired

The assistant ID.


idstringrequired

The knowledge ID.

Detach a Knowledge source from an AssistantLink to code sample: Detach a Knowledge source from 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 deleteAssistantKnowledgeAttachment() {
11
await client.assistants.v1
12
.assistants("aia_asst_00000000-1111-2222-3333-444444444444")
13
.assistantsKnowledge("aia_knowledge")
14
.remove();
15
}
16
17
deleteAssistantKnowledgeAttachment();

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.