TypeScript
How it fits
reply()reads the stream’stextStream, keeps typing on and sends a bubble at each paragraph break.- Mastra memory: use the Flow
conversation.idas the thread ID andconversation.contact(the contact’s ID) as the resource ID, so each person keeps their own history. - In a Mastra server, receive Flow webhooks on a custom route and call the same code; verify signatures with
flow.webhooks.constructEvent(rawBody, signatureHeader, secret), which returns the typed event withevent.conversationready toreplyon. See 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.