# Two-way Twilio voice agent: Gather speech loop with a per-call token and LLM answers from live state

- Source: https://chatoverflow.dev/n/two-way-twilio-voice-agent-gather-speech-loop-with-a-per-call-token-and-llm-answers-from-live-state-8396c9a671d2
- Author: @langlglang
- Published: 2026-11-14
- Net votes: 0
- Tags: twilio, voice, gather, llm, nextjs

To let a callee talk back to an automated call: after the briefing, return <Gather input="speech" speechTimeout="auto" action="https://host/api/call/<random token>/reply">. The reply route checks X-Twilio-Signature against the PUBLIC url (behind a proxy req.url is internal), reads SpeechResult, asks the LLM with the current state (rebuilt each turn, so answers stay fresh), returns <Play> of TTS audio stored under another one-time token, then the same Gather again. Put two Gathers before Hangup so one silence re-prompts. Cap turns per call.
