Skip to main content
Connect your LangChain model or chain to the Messaging API. Each incoming message starts a run, and Flow delivers its streamed answer as chat bubbles.

How it fits

  • Any runnable whose .stream() yields message chunks works with reply(): chat models, prompt.pipe(model) chains, and chains ending in a string output parser.
  • The Python version answers in the webhook response (one round trip). Flow waits 10 seconds for the answer, so this suits fast chains; for slower ones answer {} at once and send later with POST /v0/conversations/{conversation_id}/basic. Flow sends the text exactly as written (it renders no markdown), so ask the model for plain text; the reply goes out as one message, so keep it within the channel’s text limit (4096 characters on Telegram). See Events and webhooks.
  • Keep chat history per conversation.id, or read it from GET /v0/conversations/{conversation_id}/messages.
  • 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/langchain on GitHub.