import SGPClient from 'sgp';
const client = new SGPClient({
apiKey: 'My API Key',
});
const chatThreadHistory = await client.chatThreads.messages.retrieve('thread_id');
console.log(chatThreadHistory.application_spec_id);
{
"thread": {
"id": "<string>",
"title": "<string>",
"application_variant_id": "<string>",
"thread_metadata": {},
"account_id": "<string>",
"created_by_user_id": "<string>",
"created_by_identity_type": "user",
"created_at": "2023-11-07T05:31:56Z",
"archived_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
},
"messages": [
{
"entry": {
"id": "<string>",
"input": {},
"output": {},
"aggregated": true,
"application_spec_id": "<string>",
"application_variant_id": "<string>",
"start_timestamp": "2023-11-07T05:31:56Z",
"duration_ms": 123,
"operation_status": "SUCCESS",
"operation_metadata": {},
"chat_thread_id": "<string>",
"interaction_source": "EXTERNAL_AI",
"created_at": "2023-11-07T05:31:56Z"
},
"spans": [
{
"id": "<string>",
"application_interaction_id": "<string>",
"application_variant_id": "<string>",
"node_id": "<string>",
"operation_type": "TEXT_INPUT",
"operation_status": "SUCCESS",
"operation_input": {},
"operation_output": {},
"operation_expected": {},
"operation_metadata": {},
"start_timestamp": "2023-11-07T05:31:56Z",
"end_timestamp": "2023-11-07T05:31:56Z",
"duration_ms": 123,
"trace_id": "<string>",
"parent_id": "<string>",
"group_id": "<string>",
"account_id": "<string>",
"created_by_user_id": "<string>"
}
],
"feedback": {
"id": "<string>",
"chat_thread_id": "<string>",
"application_interaction_id": "<string>",
"sentiment": "positive",
"description": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}
}
],
"application_spec_id": "<string>"
}
import SGPClient from 'sgp';
const client = new SGPClient({
apiKey: 'My API Key',
});
const chatThreadHistory = await client.chatThreads.messages.retrieve('thread_id');
console.log(chatThreadHistory.application_spec_id);
{
"thread": {
"id": "<string>",
"title": "<string>",
"application_variant_id": "<string>",
"thread_metadata": {},
"account_id": "<string>",
"created_by_user_id": "<string>",
"created_by_identity_type": "user",
"created_at": "2023-11-07T05:31:56Z",
"archived_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
},
"messages": [
{
"entry": {
"id": "<string>",
"input": {},
"output": {},
"aggregated": true,
"application_spec_id": "<string>",
"application_variant_id": "<string>",
"start_timestamp": "2023-11-07T05:31:56Z",
"duration_ms": 123,
"operation_status": "SUCCESS",
"operation_metadata": {},
"chat_thread_id": "<string>",
"interaction_source": "EXTERNAL_AI",
"created_at": "2023-11-07T05:31:56Z"
},
"spans": [
{
"id": "<string>",
"application_interaction_id": "<string>",
"application_variant_id": "<string>",
"node_id": "<string>",
"operation_type": "TEXT_INPUT",
"operation_status": "SUCCESS",
"operation_input": {},
"operation_output": {},
"operation_expected": {},
"operation_metadata": {},
"start_timestamp": "2023-11-07T05:31:56Z",
"end_timestamp": "2023-11-07T05:31:56Z",
"duration_ms": 123,
"trace_id": "<string>",
"parent_id": "<string>",
"group_id": "<string>",
"account_id": "<string>",
"created_by_user_id": "<string>"
}
],
"feedback": {
"id": "<string>",
"chat_thread_id": "<string>",
"application_interaction_id": "<string>",
"sentiment": "positive",
"description": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}
}
],
"application_spec_id": "<string>"
}
Fetch the thread by account instead of user
Fetch spans for each message
Successful Response
The response is of type object
.