Share feedback, ideas and get community help

Updated 5 months ago

Stream OpenAI

At a glance

The community member is seeking help on how to handle the stream response from the OpenAI API. They received a JSON response with the following structure:

{ "messages": [], "clientSideActions": [ { "type": "stream", "stream": true, "expectsDedicatedReply": true } ]}

The comments provide some guidance:

If the community member is using the Typebot cloud app and the OpenAI block, streaming works by default, and no further action is required.

If the community member is self-hosting on Docker, they should check the provided Discord channel for more information.

Another community member notes that this functionality is not well documented.

The final comment provides a more detailed explanation. If streaming is enabled, the community member will receive the JSON response they described. To handle the streaming, they need to send a request to the https://typebot.co/api/v2/sessions/{sessionId}/streamMessage endpoint, which will provide Server-Sent events with the streamed message. Once the streaming is complete, the community member can continue the chat flow by sending a request with the streamed message as the message content.

There is no explicitly marked answer in the comments, but

Useful resources
There is no information on how to handle the stream response from OpenAI via the API. Can you shed some light on it? I am completely stuck because I received the following response:

{
"messages": [],
"clientSideActions": [
{
"type": "stream",
"stream": true,
"expectsDedicatedReply": true
}
]
}

What should i do next?
W
B
4 comments
If you are on typebot cloud app and are using the openai block, streaming works by default, nothing to be done
Indeed, this is not documented.
If you enabled stream, whenever a AI message should be streamed, you will receive that kind of JSON response:

Plain Text
{
  "messages": [],
  "clientSideActions": [
    {
      "type": "stream",
      "stream": true,
      "expectsDedicatedReply": true
    }
  ]
}


The bot is ready to accept the message streaming. You now need to send the following query:

Plain Text
curl -X POST https://typebot.co/api/v2/sessions/{sessionId}/streamMessage


This endpoint will send Server-Sent events with all the information to display the streamed message.

Once it is done, you can contine the flow by sending a continue chat request with the streamed message as the message content
Add a reply
Sign up and join the conversation on Discord