POST

Create Message Stream


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Creates a message and streams the assistant's response back in real time.

Use this method to send a site visitor's question and receive the assistant's answer as a stream of frames, so you can display the answer as it's generated instead of waiting for the complete response.

This method must be called using the site visitor or site member identity (SDK | REST) to identify the site visitor sending the message. The conversation is resolved automatically from the visitor's identity, so you don't need to provide a conversation ID.

Set the message's messageType to QUESTION and provide the question text in body.mainText.

Each frame in the response stream contains one of the following:

  • inputMessage: The message you sent, persisted with its server-assigned id, conversationId, and creation timestamp. Sent as the first frame.
  • answerChunk: A part of the assistant's answer text, streamed as it's generated. Each chunk is additive, so concatenate the chunks in the order received to build the full answer. Sent zero or more times.
  • answerMessage: The complete, persisted assistant answer. Sent as the final frame before the stream completes.

The message and the assistant's answer are persisted regardless of whether the stream completes. If the connection drops or times out, retrieve both by calling List Messages.

If the conversation has reached its quota, the answer is a message with messageType OUT_OF_QUOTA. Behavior outside the assistant's active hours depends on the site's widget settings.

Permissions
Innovation Lab User
Learn more about app permissions.
Endpoint
POST
https://www.wixapis.com/wix-assistant-widget/v1/messages/stream

Errors

This method doesn't return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?