💬Chat with Chatbot
Send a question to a chatbot and receive a response. By default, the endpoint returns JSON. If you set stream: true, it returns a server-sent event (SSE) stream that can be consumed from a server with fetch(). This endpoint also returns a chatlogId for maintaining conversation context and a list of sources used for the answer (max 5), ordered by relevance.
Endpoint
POST https://app.wonderchat.io/api/v1/chatRequest Parameters
chatbotId
string
✅ Yes
The ID of the chatbot you want to chat with
question
string
✅ Yes
The question you wish to ask your chatbot
chatlogId
string
❌ No
The ID of your current chat session for conversation continuity
context
string
❌ No
Additional custom context about the chat session (e.g., user information)
contextUrl
string
❌ No
URL of the page the user is on to provide additional context
images
array
❌ No
Array of images to include (max 5). Each entry must be an http(s) URL or a base64 data URL (data:image/...)
stream
boolean
❌ No
Set to true to receive the answer as an SSE stream instead of JSON
Example Request (JSON Response)
curl --location --request POST 'https://app.wonderchat.io/api/v1/chat' \
--header 'Content-Type: application/json' \
--data-raw '{
"chatbotId": "YOUR_CHATBOT_ID",
"question": "Hello there!",
"chatlogId": "YOUR_CHATLOG_ID",
"context": "You are speaking with John, a 28 year old salesperson from Canada. English is not his native language, so please refrain from using complicated words.",
"contextUrl": "https://yourwebsite.com/john-info",
"stream": false
}'JSON Response Format
Response Fields
id
string
Unique identifier for this message
response
string
The chatbot's response to your question
chatlogId
string
Unique identifier for this chat session
sources
array
List of sources used to generate the response (max 5)
sources[].url
string
URL of the source document
sources[].title
string
Title of the source document
Streaming
When stream is set to true, the response content type is text/event-stream.
Streaming Request
Streaming Event Types
metadata
{"chatlogId": "..."}
Initial metadata with chatlog ID
chunk
{"delta": "partial response text"}
Partial response text
done
{"id": "...", "response": "...", "chatlogId": "...", "sources": [...]}
Final payload with full response
error
{"error": "message"}
Error message if something failed
Example Stream
Server Consumption Example (Node.js)
Use fetch() and read the response body as a stream. EventSource is not suitable here because this endpoint uses POST.
Use Cases
Customer Support: Integrate chatbot responses into your support system
Website Chat: Power your website's chat widget
Mobile Apps: Add conversational AI to your mobile applications
Workflow Automation: Chain chatbot responses with other automated processes
Real-time Streaming: Display responses progressively for better UX
Last updated
Was this helpful?