Skip to contentSkip to navigationSkip to topbar
On this page

Feedback Resource


This API tracks Human Feedback that you gather on AI Assistant responses.


Feedback Properties

feedback-properties page anchor
Property nameTypeRequiredDescriptionChild properties
assistant_idstringrequired
Not PII

The Assistant ID.


idstringrequired

The Feedback ID.

Pattern: ^aia_fdbk_*$

account_sidSID<AC>Optional

The SID of the Account that created the Feedback.

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

user_sidSID<US>Optional

The SID of the User created the Feedback.

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

message_idstringrequired

The Message ID.


scorenumber<float>required

The Score to provide as Feedback (0-1)

Minimum: 0Maximum: 1

session_idstringrequired

The Session ID.


textstringrequired

The text to be given as feedback.


date_updatedstring<date-time>required

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


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

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
idstringrequired

The assistant ID.

Encoding type:application/json
Schema
Property nameTypeRequiredDescriptionChild properties
message_idstringOptional

The message ID.

Pattern: ^aia_msg_*$

scorenumber<float>Optional

The score to be given(0-1).

Minimum: 0Maximum: 1

session_idstringrequired

The Session ID.


textstringOptional

The text to be given as feedback.

Track feedback on a session

track-feedback-on-a-session page anchor
Track FeedbackLink to code sample: Track Feedback
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 createFeedback() {
11
const feedback = await client.assistants.v1
12
.assistants("aia_asst_00000000-1111-2222-3333-444444444444")
13
.feedbacks.create({
14
session_id: "your-session-id",
15
score: 0.5,
16
});
17
18
console.log(feedback.assistantId);
19
}
20
21
createFeedback();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"assistant_id": "assistant_id",
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
"message_id": "message_id",
8
"score": 0.042,
9
"session_id": "session_id",
10
"text": "text",
11
"user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
12
}

Track feedback on a specific message

track-feedback-on-a-specific-message page anchor
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 createFeedback() {
11
const feedback = await client.assistants.v1
12
.assistants("aia_asst_00000000-1111-2222-3333-444444444444")
13
.feedbacks.create({
14
message_id: "aia_msg",
15
session_id: "your-session-id",
16
score: 0.5,
17
});
18
19
console.log(feedback.assistantId);
20
}
21
22
createFeedback();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"assistant_id": "assistant_id",
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
"message_id": "message_id",
8
"score": 0.042,
9
"session_id": "session_id",
10
"text": "text",
11
"user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
12
}

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

Property nameTypeRequiredPIIDescription
idstringrequired

The assistant ID.

Property nameTypeRequiredPIIDescription
PageintegerOptional

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

Minimum: 0

PageSizeintegerOptional

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

Minimum: 1Maximum: 1000

PageTokenstringOptional

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 listFeedback() {
11
const feedbacks = await client.assistants.v1
12
.assistants("id")
13
.feedbacks.list({ limit: 20 });
14
15
feedbacks.forEach((f) => console.log(f.assistantId));
16
}
17
18
listFeedback();

Output

1
{
2
"feedbacks": [
3
{
4
"assistant_id": "assistant_id",
5
"id": "aia_fdbk",
6
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"user_sid": "USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"message_id": "message_id",
9
"score": 0.042,
10
"session_id": "session_id",
11
"text": "text",
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
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.