Skip to main content
This page puts an OpenAI Agents SDK agent on Telegram and iMessage: each message runs the agent, and its streamed answer is sent back as chat bubbles. iMessage is for replies only, on a line the Flow team sets up for your app; WhatsApp is coming (it waits on Meta’s approval) and will use the same code.

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 /v1/conversations/{conversation_id}/messages, or keep your own session keyed by conversation.id.
  • Verify webhook signatures as shown in Events and webhooks.

Full example

examples/openai-agents on GitHub.