Skip to main content
Run your OpenAI Agents SDK agent for each incoming message and pass its stream to Flow’s reply(). The messaging integration is the same on each connected channel.

How it fits

  • In TypeScript, run(agent, input, { stream: true }) returns a streamed result; reply() reads its text stream and sends bubbles while the agent runs.
  • In Python, answer the webhook with {} at once and send the agent’s final_output afterwards. Text longer than the channel’s limit (4096 characters on Telegram) is refused, so split long answers at paragraph breaks (the bubble rule) and send each part with its own Idempotency-Key.
  • Give the agent the conversation’s history from GET /v0/conversations/{conversation_id}/messages, or keep your own session keyed by conversation.id.
  • Verify webhook signatures as shown in Events and webhooks.
  • To see each turn’s model and tool calls and get every reply graded, send this agent’s traces to Flow Observe: Traces from agent frameworks.

Full example

examples/openai-agents on GitHub.