REST Channels
TheRestInput and CallbackInput channels can be used for custom integrations.
They provide a URL where you can post messages and either receive response messages
directly, or asynchronously via a webhook.
RestInput
The REST channel will provide you with a REST endpoint where you can post user messages and receive the assistant’s messages in response. Add the REST channel to your credentials.yml:http://<host>:<port>/webhooks/rest/webhook, replacing
the host and port with the appropriate values from your running Rasa server.
Request and Response Format
After making therest input channel available, you can POST messages to
http://<host>:<port>/webhooks/rest/webhook, with the following format:
Message Metadata
The REST channel supports sending additional metadata along with messages. This metadata can be accessed through thesession_started_metadata slot and can contain any custom fields you want to pass to your assistant.
To include metadata in your request, add a metadata field to your JSON payload:
session_started_metadata slot at the beginning of the conversation and can be accessed by your actions or flows. A custom action_session_start can be used to store this information to slots for later use in the conversation.
Cancel Background A2A Tasks
If your assistant uses external sub agents over A2A and an operation is running in the background, you can cancel it manually for a specific sender by calling:POST http://<host>:<port>/cancel_background_tasks/<sender_id>
Example:
CallbackInput
New in Rasa Pro 3.17The Callback channel now supports message streaming. Learn more in the Streaming section.
credentials.yml:
http://<host>:<port>/webhooks/callback/webhook, replacing
the host and port with the appropriate values from your running Rasa server.
Request and Response Format
After making thecallback input available, you can POST messages to
http://<host>:<port>/webhooks/callback/webhook with the following format:
success. Once Rasa is ready to send a
message to the user, it will call the url specified in your credentials.yml with a separate POST request for each bot response:
POST requests to the callback URL.
Streaming
The callback channel supports streaming generative responses. To enable it, addstream=true as a query parameter when posting to the webhook:
stream_id:
stream_start — sent once at the beginning of a streamed response:
stream_delta — sent for each incremental text chunk, with a zero-based index:
stream_end — sent once when all chunks have been delivered:
stream_end, Rasa posts the assembled complete message. This message includes the same stream_id so the client can correlate it with the preceding chunks, a streamed: true flag, and a stream_delta_count with the total number of chunks that were sent:
stream=true query parameter), the chunk events are suppressed and only the complete message is posted to the callback URL.
SocketIO Channel
The SocketIO channel uses websockets and is real-time. To use the SocketIO channel, add the credentials to yourcredentials.yml:
http://<host>:<port>/socket.io, replacing
the host and port with the appropriate values from your running Rasa server.
The Socket.IO transport path defaults to /socket.io and can be overridden with socketio_path:
Running
socketio alongside the inspector channelYou can declare both socketio: and inspector: in the same credentials.yml. Each channel needs its own Socket.IO transport path. Rasa keeps the socketio channel on /socket.io and puts the inspector channel on /inspector.io. If you give two Socket.IO channels the same socketio_path, Rasa fails to start with a RasaException that names both channels. Set a distinct socketio_path on all but one of them to resolve it.session persistenceBy default, the SocketIO channel uses the socket id as
sender_id, which causes
the session to restart at every page reload. session_persistence can be
set to true to avoid that. In that case, the frontend is responsible
for generating a session id and sending it to the Rasa server by
emitting the event session_request with {session_id: [session_id]}
immediately after the connect event.The example Webchat
implements this session creation mechanism (version >= 0.5.0).SocketIO client / server compatibilityThe version of the SocketIO client connecting to Rasa must be compatible with the versions of
the python-socketio and
python-engineio packages used by
Rasa. Please refer to the
pyproject.toml
file relative to your version of Rasa and the official python-socketio compatibility table.JWT Authentication
The SocketIO channel can be optionally configured to perform JWT authentication on connect by defining thejwt_key and optional jwt_method in the credentials.yml file.
token:
Chat Widget
Once you’ve set up your SocketIO channel, you can use the official Rasa Chat Widget on any webpage. Use the example HTML below and paste the URL of your Rasa instance into theserver-url attribute: