From 192989ba92ed55d9bcc08786cff67f9e78a6c277 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Tue, 10 Sep 2024 12:28:11 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20message=20stream=20API=20i?= =?UTF-8?q?nstructions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/docs/api-reference/how-to.mdx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/apps/docs/api-reference/how-to.mdx b/apps/docs/api-reference/how-to.mdx index 5b0c2cda7..7d985db35 100644 --- a/apps/docs/api-reference/how-to.mdx +++ b/apps/docs/api-reference/how-to.mdx @@ -19,3 +19,32 @@ For published typebot execution, you need to provide the public typebot ID avail ### How to find my `workspaceId` In your workspace dashboard, head over to `Settings & Members > Workspace > Settings` and copy the workspace ID + +### How to handle stream + +If you enabled stream, whenever a AI message should be streamed, you will receive that kind of JSON response: + +```json +{ + "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: + +```sh +curl -X POST https://typebot.co/api/v2/sessions/{sessionId}/streamMessage +``` + +Where `{sessionId}` should be replaced by the session ID you got from the start chat response. + +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](./chat/continue-chat) with the streamed message as the message content.