The Chatbot has the option to display messages in Streaming mode. When Streaming mode is enabled, the Chatbot will display each response in a sequence of small groups of words (called chunks), instead of displaying the entire response at once.
When the POST /conversation/message endpoint
is called and its x-inbenta-streaming
header is set to 'true', the API will respond in a streaming format. In this format, events are returned as they are generated.
If the x-inbenta-streaming
header is set to 'false', then the API will return its normal response. See API Routes for more details.
This article details the event type objects that are returned when the POST /conversation/message
endpoint is called and streaming is enabled.
Events are returned in the following format:
{"type": string, "data": mixed}
There are four event types which can be returned:
extendedContentsAnswerTitle
streamedMessage
fullResponse
endResponse
extendedContentsAnswerTitle
and streamedMessage
are only returned when a response uses Generative AI content. fullResponse
and endResponse
are always returned.
This event type is returned at the beginning of a response, only when the API is returning generative AI content.
The extendedContentsAnswerTitle
type object is returned once. Within, the data.message
property includes the "Initial text" as defined in the Generative AI Federated Bot Source. Since Initial text is optional, this property may be empty.
{ "type": "extendedContentsAnswerTitle", "data": {"message":"Initial message for AI response,","uuid":"6669917a98f7f"} }
This event type is returned at the beginning of a response after the initial text, and only when the API is returning generative AI content.
streamedMessage
type objects each have a data.message
property which contains a chunk of words. Together, these chunks make up the whole answer.
{"type": "streamedMessage", "data": {"message":"Generative AI message begins...","uuid":"6669917a98f7f"}} {"type": "streamedMessage", "data": {"message":"...message continues...","uuid":"6669917a98f7f"}} ... {"type": "streamedMessage", "data": {"message":"...message ends.","uuid":"6669917a98f7f"}}
This event type is always returned. The fullResponse
object contains the normal response that is returned when the POST /conversation/message
endpoint is called. This response is wrapped inside the data
attribute.
{ "type": "fullResponse", "data": { "answers": [ { "type": "extendedContentsAnswer", "message": "AI message.", "messageList": [ "AI message." ], "options": null, "parameters": null, "flags": [], "attributes": null, "source": { "type": "chatbot", "name": "Chatbot" }, "additionalData": [], "logId": null, "subAnswers": [ { "type": "answer", "message": "AI message text...", "messageList": [ "AI message text..." ], "options": null, "parameters": { "contents": { "title": "AI message.", "attributes": [], "trackingCode": { "clickCode": "CLICK_CODE" } } }, "flags": [], "attributes": { "ANSWER_TEXT": "Full AI response", "title": "AI message." }, "source": { "type": "generative_ai", "name": "Gen AI" }, "intent": { "type": "External", "score": 1 }, "additionalData": [], "logId": "141,439857806097013787", "context": [] } ], "uuid": "6669917a98f7f" } ] } }
This event type is always returned at the end of the response. This object's data attribute is empty.
{ "type": "endResponse", "data": null }