Robofy API
HomeChangelog
HomeChangelog
Visit Website
Sign In
Create an account
  1. Chat
  • Start Guide
    • Overview
    • Architecture
    • Authentication
    • Changelog
  • Robofy API
    • Chat
      • Generate Client Token (Handshake)
        POST
      • Send Message (Streaming)
        POST
      • Send Message (Non Streaming)
        POST
      • Send WhatsApp Message
        POST
    • Chatbot / Agent
      • List Agents
      • Create Agent
      • Retrieve Agent
      • Update Agent
      • Delete Agent
      • Delink Asset
      • List Linked Assets
      • Delete Widget Tab
    • Account
      • Retrieve Account Details
      • Update Account Details
      • Retrieve Account Limit
    • Prompt & Persona
      • Update System Prompt
      • Retrieve Agent Settings
      • Update Persona
      • Retrieve Persona
    • Inbox
      • List Sessions
      • List Session Messages
    • Project
      • Create Project
      • List Projects
      • Update Project
      • Retreive Project
    • Leads
      • List Leads
    • Content
      • Add Website
      • Get Crawl Status
      • Add Text Content
      • Add File
    • Stats
      • Stats
    • License
      • Create License
      • List License
      • Update License
      • Retrieve License
      • Delete License
      • Update License Limit
    • Partner
      • Onboard
    • Schemas
      • Account
      • AccountDetailDto
      • Address
      • AgentCredentialInsertResponseDto
      • AgentCredentialRequestDto
      • AgentCredentialResponseDto
      • AgentDataPoint
      • AgentLeadCapture
      • AgentLeadReportDto
      • AgentLinkageDto
      • AgentMcpServerDto
      • AgentMcpServerInsertResponseDto
      • AgentMcpServerRequestDto
      • AgentMcpServerUpdateRequestDto
      • AgentPromptVersionDto
      • AgentSessionListDto
      • AgentSessionListItemDto
      • AgentStatsDto
      • AgentThemeDto
      • AgentThemeListDto
      • AgentToolLinkageInsertResponseDto
      • AgentToolLinkageRequestDto
      • AgentWhatappIntrgrationResponse
      • AgentWhatsAppLinkageDto
      • Button
      • CarouselCard
      • CategoryStats
      • ChatBotDetailsDto
      • ChatBotDetailsRequest
      • ChatBotDetailsUpdateRequest
      • ChatbotAISettingsDto
      • ChatbotAISettingsRequest
      • ChatbotAdvanceSettingsDto
      • ChatbotAdvanceSettingsRequest
      • ChatbotAppearanceSettingsDto
      • ChatbotAppearanceSettingsRequest
      • ChatbotAssetDelinkDto
      • ChatbotAssetLinkageDataDto
      • ChatbotAssetLinkageDelinkRequest
      • ChatbotAssetLinkageDetailsDto
      • ChatbotAssetLinkageDto
      • ChatbotAssetLinkageRequest
      • ChatbotTextLinkageRequest
      • ClientData
      • CommonResponse
      • Component
      • Contact
      • ContactName
      • CrawlStatusDto
      • CrawlWebsiteRequest
      • CreateOrUpdateProjectRequest
      • CreatePhoneNumberRequest
      • CreateTemplateRequest
      • CreateWebhookConfigRequest
      • DeLinkWhatsAppRequest
      • Email
      • Error
      • ErrorResponse
      • Example
      • FailureStats
      • FailureStatsDataPoint
      • FormField
      • GoogleSheetDto
      • GoogleSheetIntegrationRequest
      • InboxChatDto
      • InboxDto
      • InboxMessage
      • InboxSession
      • IntelligentMetricsDto
      • Interactive
      • InteractiveAction
      • InteractiveBody
      • InteractiveButton
      • InteractiveFooter
      • InteractiveHeader
      • InteractiveMedia
      • InteractiveProductItem
      • InteractiveProductSection
      • InteractiveReply
      • InteractiveRow
      • InteractiveSection
      • LeadCaptureForm
      • LeadData
      • LeadDataField
      • LeadFormData
      • LeadReport
      • LicenseCreateRequest
      • LicenseDto
      • LicenseLimitRequest
      • LicenseUpdateRequest
      • LimitedTimeOffer
      • LinkWhatsAppRequest
      • LinkedCredentialDto
      • LinkedMcpServerDto
      • Location
      • Media
      • MessageMetaData
      • MessageRequest
      • MessageResponse
      • MessageStats
      • MessageStatsDataPoint
      • MessageTemplate
      • NamedParameter
      • OrgLimitDto
      • Organization
      • PaginatedWebhookLogsResponse
      • Part
      • PartnerClientSession
      • PartnerClientSessionDto
      • Phone
      • PhoneNumberRequest
      • PhoneVerifyCodeRequest
      • PhoneVerifyRequest
      • PlatformStats
      • ProjectDetailDto
      • ProjectWABADetail
      • Reaction
      • ReadTypingIndicatorRequest
      • RecentInsightDto
      • Response
      • SessionInsightItemDto
      • SessionInsightsDto
      • SessionMetaDto
      • SessionMetricsDto
      • SessionSummaryDetailDto
      • StartUrl
      • SubcribedAppsRequest
      • SupportedApp
      • TemplateAction
      • TemplateButtons
      • TemplateCarousel
      • TemplateComponent
      • TemplateCurrency
      • TemplateDateTime
      • TemplateLimitedTimeOffer
      • TemplateMedia
      • TemplateParameter
      • TemplateProductItem
      • TemplateSection
      • TemplateTapTargetConfiguration
      • Text
      • ThemeMetaDto
      • TypingIndicator
      • UpdateOnboardStatusRequest
      • UpdateOnboardStatusResponseDto
      • UploadMedia
      • Url
      • WABADetail
      • WABADto
      • Webhook
      • WebhookConfigDto
      • WebhookConfiguration
      • WebhookLogDto
      • WebsiteDto
      • WhatsAppBusinessApiData
      • WhatsAppBusinessProfile
      • WidgetIntegration
  1. Chat

Send Message (Streaming)

POST
/v1/ai-agent/chat/stream
Send Message (Streaming) allows a client application to send a user message to an AI agent and receive an AI-generated response as a stream.
This endpoint is designed for real-time chat experiences where the response should appear progressively while the AI agent is generating it. It is commonly used for web chat widgets, support bots, messaging interfaces, customer support automation, and conversational AI applications.
The client sends the user query along with the project ID, chatbot ID, and user context. The AI agent processes the request and streams response events back to the client.

Endpoint#


Request Body#

{
  "query": "Hello",
  "pid": "3..",
  "chatbot_id": "DKDvwn...",
  "user_context": {
    "session_id": "6ff922ed-9884-4430-83c9-7ac83a7b0574",
    "platform": "web"
  }
}

Request Parameters#

FieldTypeRequiredDescription
querystringYesUser message or question sent to the chatbot.
pidstringYesProject ID associated with the chatbot.
chatbot_idstringYesUnique chatbot identifier that should process the message.
user_contextobjectYesAdditional context about the user, session, platform, or client application.
user_context.session_idstringNoUnique session identifier used to continue or group messages in the same conversation.
user_context.platformstringYesPlatform or channel where the message originated. Example: web.

Success Response#

The response is returned as a streaming response using server-sent event style chunks.
Each event is sent using the following format:
data: {...}
The stream ends with:
data: [DONE]

Example Streaming Response#

data: {"type":"start","messageId":"zUqbj2SylMki95Be"}

data: {"type":"start-step"}

data: {"type":"text-start","id":"0"}

data: {"type":"text-delta","id":"0","delta":"Hello"}

data: {"type":"text-delta","id":"0","delta":"! How can I help you today?"}

data: {"type":"text-end","id":"0"}

data: {"type":"finish-step"}

data: {"type":"finish","finishReason":"stop"}

data: {"type":"data-session","data":"6ff922ed-9884-4430-83c9-7ac83a7b0574"}

data: {"type":"data-finish-reason","data":{"finishReason":"stop","rawFinishReason":"STOP"}}

data: [DONE]

Stream Event Types#

Event TypeDescription
startIndicates that the streaming response has started. Usually includes the generated message ID.
start-stepIndicates that the agent has started a processing step.
tool-input-startIndicates that the agent is preparing to call an available tool.
tool-input-deltaStreams partial tool input as it is being generated.
tool-input-availableIndicates that the complete tool input is available.
tool-output-availableIndicates that the tool has returned output.
finish-stepIndicates that a processing step has completed.
text-startIndicates that the assistant text response has started.
text-deltaStreams a partial text token or text chunk from the assistant response.
text-endIndicates that the assistant text response has completed.
finishIndicates that the AI generation has completed.
data-sessionReturns the conversation session ID associated with the response.
data-finish-reasonReturns the final completion reason for the response.
[DONE]Indicates the end of the stream.

Important Stream Fields#

text-delta#

The text-delta event contains the AI-generated answer in small chunks.
{
  "type": "text-delta",
  "id": "0",
  "delta": "Hello! How can I help you today?"
}
FieldTypeDescription
typestringEvent type. For streamed text chunks, the value is text-delta.
idstringIdentifier for the streamed text block.
deltastringPartial text content generated by the AI agent.

data-session#

The data-session event returns the conversation session ID.
{
  "type": "data-session",
  "data": "6ff922ed-9884-4430-83c9-7ac83a7b0574"
}
FieldTypeDescription
typestringEvent type.
datastringSession ID associated with the conversation.

data-finish-reason#

The data-finish-reason event returns the completion reason.
{
  "type": "data-finish-reason",
  "data": {
    "finishReason": "stop",
    "rawFinishReason": "STOP"
  }
}
FieldTypeDescription
typestringEvent type.
data.finishReasonstringNormalized reason why the response finished.
data.rawFinishReasonstringRaw finish reason returned by the underlying AI provider.

Error Responses#

400 Bad Request#

Returned when the request body is invalid or required fields are missing.
{
  "message": "Bad Request",
  "error": {
    "code": "BAD_REQUEST",
    "detail": "Invalid request body or missing required fields."
  }
}

401 Unauthorized#

Returned when the request does not include a valid bearer token.
{
  "message": "Unauthorized",
  "error": {
    "code": "UNAUTHORIZED",
    "detail": "Authentication token is missing or invalid."
  }
}

Notes#

Use this endpoint when you want the response to appear progressively in the client UI.
For a standard request where the full AI response is returned at once, use the non-streaming message API.
The client should listen for text-delta events and append each delta value to the visible chat response.
The stream is complete when the client receives data: [DONE].
Pass the same session_id in user_context to continue an existing conversation.
The final session ID is returned in the data-session event.
The response may include tool-related events when the chatbot uses configured tools or integrations during response generation.

Request

Authorization
Provide your bearer token in the
Authorization
header when making requests to protected resources.
Example:
Authorization: Bearer ********************
Body Params application/jsonRequired

Examples

Responses

🟢200Success
application/json
Bodyapplication/json

🟠400Bad Request
🟠401Unauthorized
Request Request Example
Shell
JavaScript
Java
Swift
curl --location 'https://agents.robofy.ai/v1/ai-agent/chat/stream' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
    "query": "Hello",
    "pid": "3..",
    "chatbot_id": "DKDvwn...",
    "user_context": {
        "session_id": "6ff922ed-9884-4430-83c9-7ac83a7b0574",
        "platfrom": "web"
    }
}'
Response Response Example
200 - Example 1
{
  "type": "text-delta",
  "id": "0",
  "delta": "Hello! How can I help you today?"
}
Modified at 2026-05-04 11:20:52
Previous
Generate Client Token (Handshake)
Next
Send Message (Non Streaming)
Built with