Skip to main content
Use Flow to receive messages and deliver a Vercel AI SDK agent’s answer as chat bubbles. The webhook example below keeps channel delivery separate from your model and tools.
TypeScript
Set FLOW_MESSAGING_KEY, FLOW_MESSAGING_WEBHOOK_SECRET and OPENAI_API_KEY, then register https://<your-app>/api/flow as a webhook endpoint for message.received. During development, with no public URL, read events from the live stream (GET /v0/stream) instead; npx @flow-engineer/messaging listen --forward-to http://localhost:3000/api/flow wraps it for this route. See Local development.

How it fits

  • reply(result) reads result.textStream, keeps the typing indicator on, and sends a bubble at each paragraph break while the model writes. See Streaming replies.
  • Tools work as usual (tools, stopWhen); only the model’s text is sent to the person, never tool calls or their results (text the model writes between tool steps is sent too). To show progress during long tool calls, wrap the work in event.conversation.responding(...).
  • The webhook answers at once and after() runs the reply, so slow models never cause a timed-out delivery.
  • One handler serves Telegram and iMessage alike; event.conversation.channel tells you which one if you want to adapt the tone.
  • 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/vercel-ai-sdk on GitHub.