The subscribeConversation
subscription allows you to listen for real-time updates to a conversation, including new messages and response streams, via a WebSocket-based subscription model.
Signature
subscribeConversation(
auth: SubscriptionAuthInput!
conversationId: String!
): [ConversationUpdateOneOf!]!
Arguments
auth
SubscriptionAuthInput!
required
The unique identifier of the conversation to subscribe to.
Response
Returns an array of ConversationUpdateOneOf
objects representing conversation updates. See ConversationUpdateOneOf for the schema.
Usage Example
A very simple example to get you started is to do the following:
subscription SubscribeConversation(
$auth: SubscriptionAuthInput!
$conversationId: String!
) {
subscribeConversation(
auth: $auth
conversationId: $conversationId
) {
assistantMessageSent {
id
body {
ops {
insert {
text
visualization {
id
title
type
highchartsOptions
}
}
}
}
sender
createdAt
}
assistantResponseDiff {
bodyDiff {
ops {
insert {
text
}
visualization {
id
title
type
highchartsOptions
}
}
}
sender
inProgress
}
assistantResponseCancelled
}
}
wscat -c wss://{ACCOUNT}.askwisdom.ai/graphql \
-H "Authorization: Bearer <jwt_token>" \
-s graphql-ws \
--execute '{
"type": "start",
"payload": {
"query": "subscription SubscribeConversation($auth: SubscriptionAuthInput!, $conversationId: String!) { subscribeConversation(auth: $auth, conversationId: $conversationId) { assistantMessageSent { id body { ops { insert { text } } } sender createdAt } assistantResponseDiff { bodyDiff { ops { insert { text } } } sender inProgress } assistantResponseCancelled } }",
"variables": {
"auth": {
"token": "<jwt_token>"
},
"conversationId": "conv_123456789"
}
}
}'
{
"data": {
"subscribeConversation": [
{
"assistantMessageSent": {
"id": "msg_987654321",
"body": {
"ops": [
{
"insert": {
"text": "Here's the analysis you requested:"
}
}
]
},
"sender": "ASSISTANT",
"createdAt": "2024-01-15T10:30:00Z"
},
"assistantResponseDiff": null,
"assistantResponseCancelled": null
}
]
}
}