Chat Web Socket
WSS/ws/api/chat/{agent_id}/?api-key={API Key}
Overview#
Connect to the 7en chat WebSocket to enable real-time messaging with your agent. This endpoint provides a persistent connection for sending user messages and receiving agent responses, including streaming text and structured events.
Attention
Add your domain to the allowed domains list in the agent builder's Deploy dialog to allow connections from your domain. You can add multiple domains to the allowed domains list.
Parameters#
Query parameters
api-keystring
Your 7en API key. Example: 43NKLN3LKN4nlkn
Path Parameters
agent_idstring
Unique identifier of the agent. Example: "453"
Request Body#
Message object
typestring
Type of the event or object. example `set_reaction`, `history`, `feedback`
contentobjectoptional
Primary content payload.sometimes we can pass string json {"rating":1,"text":"Accurate info"}`
sessionIdobjectoptional
Session id for conversation
sourcestringoptional
Source of the event or message.
messageIdintoptional
Message Id inside conversation
messageintoptional
Feedback message
agentIdstringoptional
Identifier of the agent.
reactionstringoptional
Reaction associated with the message.
reasonstringoptional
Reason associated with a reaction or status.
Message Types#
| Type | Description |
|---|---|
feedback | Used to send feedback with stars and text. rating is stars from 1 to 5 and text is template text. Send as {\"rating\":1,\"text\":\"Accurate info\"} inside content property. See the examples below. |
set_reaction | Used to like or dislike message. See the examples below |
export | Used to export chat |
user | Message from user |
timeout | To end the chat session |
delete | To delete the chat |
session_init | To start a new chat session |
private | To start a private chat session |
Send Conversation Feedback
{
"type": "feedback",
"content": "{\"rating\":1,\"text\":\"Accurate info\"}",
"message": "very good",
"agentId": "123",
"sessionId": "dfe2ebcc-00dc-cs-852e-77898da834d2",
"timestamp": 1772623350946
}Set Message Reaction [Like / Dislike]
{
"type": "set_reaction",
"message_id": "31906",
"reaction": "like"
}{
"type": "set_reaction",
"message_id": "31906",
"reaction": "dislike",
"reason": "Not satisfied"
}Export chat to email
{
"type": "export",
"content": "[email protected]",
"agentId": "660",
"source": "website",
"timestamp": 1772625625327
}End Chat
{
"type": "timeout",
"message": "",
"agentId": "660",
"sessionId": "bb5fa3a4-70ed-4366-9554-62115da683c9",
"timestamp": 1772700820969
}Delete Chat
{
"type": "delete",
"message": "",
"agentId": "660",
"sessionId": "bb5fa3a4-70ed-4366-9554-62115da683c9",
"timestamp": 1772700890258
}Minimal request
{
"type": "user",
"content": "how to get agent",
"timestamp": "2026-02-09T13:10:32.554Z",
"source": "widget"
}Response201
{
"type": "bot_response",
"content": "Hello! I'm web. I am here to answer your questions.",
"timestamp": "2026-03-04T08:02:41.989787+00:00Z",
"session_id": "dfe2ebcc-00dc-465b-852e-77898da834d2"
}