Sofia AI
Invoke Sofia AI
Call the Sofia AI sales assistant with a customer message and receive a streaming AI-generated response 🦾
POST
Invoke Sofia AI
Sofia AI is built on the Agent Graph infrastructure. Invoking it uses the standard Agent Graph invoke endpoint — the only Sofia-specific value you supply is the
Your Sofia
agentId (your agent_descriptor_id) that Connectly provides during onboarding.
To set up Sofia AI for production, contact your Connectly Account Manager. They will configure your knowledge base and product catalog, then provide your
agent_descriptor_id, business_id, and api_key.Endpoint
Authentication
Use the Sofia-specific API key provided by Connectly — not your general Connectly API key. Pass it in thex-api-key header (lowercase).
api_key is scoped to inference only and is safe to use in client-side JavaScript — it cannot send WhatsApp messages or access campaign data.
Session lifecycle
Every Sofia AI conversation follows the standard Agent Graph three-step lifecycle:Init
Call POST /agent_graph/init with your
businessId and clientKey to receive a sessionId.Invoke
Call this endpoint with the
sessionId and your inputEvents to send a customer message and receive the agent’s reply.Close
Call POST /agent_graph/close with the
sessionId when the conversation ends.Request body
The
business_id provided by Connectly for your Sofia AI integration.A unique identifier for the customer. Use a stable ID from your system so you can correlate sessions with users.
The session ID returned by the init endpoint.
Your
agent_descriptor_id — provided by Connectly during onboarding. Identifies the Sofia agent configuration to use.The events to send to the agent. For a standard text interaction, include a single
messageEvent with the customer’s text.For the full list of supported event types — button responses, list replies, form submissions, store events — see Invoke (stream).Response
The response is an NDJSON stream — one JSON object per line, each representing one agent response event.Full example (Python)
Related
NDJSON streaming
How to correctly parse the streaming response body.
Invoke (stream) reference
Full parameter docs including all input and response event types.
