twilio-opencode

A lightweight express server to handle Twilio voice and messaging webhooks for prompting Opencode.
git clone https://unitehenry.com/git/twilio-opencode.git
Log | Files | Refs | README | LICENSE

commit cda857fa64f45fd289bcbc0e4fd8067d4845d526
parent 5b2797df2889c44d9a5207aacf48f1d1c832a3c1
Author: Henry Unite <unitehenry@gmail.com>
Date:   Sat, 28 Feb 2026 06:23:32 +0000

feat: handle call update error

Diffstat:
Mvoice.ts | 20+++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/voice.ts b/voice.ts @@ -43,6 +43,20 @@ function hold(res: Response): void { res.send(responseXml); } +async function updateCall(accountSid: string, callSid: string, twiml: string) : Promise<void> { + const twilioAuthToken: string | undefined = process.env.TWILIO_AUTH_TOKEN; + + const twilioClient = twilio(accountSid, twilioAuthToken); + + try { + log("INFO", "Updating twilio call", { callSid }); + + await twilioClient.calls(callSid).update({ twiml }); + } catch(error) { + log('ERROR', 'Failed to update call', { error }); + } +} + export default async (req: Request, res: Response): Promise<void> => { const app = req.app; @@ -109,9 +123,5 @@ export default async (req: Request, res: Response): Promise<void> => { log("INFO", "Creating twilio client", { accountSid }); - const twilioClient = twilio(accountSid, twilioAuthToken); - - log("INFO", "Updating twilio call", { callSid }); - - await twilioClient.calls(callSid).update({ twiml: response }); + await updateCall(accountSid, callSid, response); };