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 717a5da4f50e329e2f18eea6a3d6afd708ec5442
parent 85d305cd332205953c5c7b77b20f4a91a3887e2c
Author: Henry Unite <henry@getpoint.io>
Date:   Thu, 26 Feb 2026 09:34:34 -0800

feat: validate twilio webhook

Diffstat:
Mapp.ts | 9++++++---
Mscripts/install.sh | 1+
2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/app.ts b/app.ts @@ -1,4 +1,5 @@ import express from "express"; +import twilio from "twilio"; import log from "./log.ts"; import message from "./message.ts"; import voice from "./voice.ts"; @@ -6,11 +7,13 @@ import health from "./health.ts"; const app = express(); -app.use(express.urlencoded()); +const validate = !!process.env.TWILIO_AUTH_TOKEN; -app.post("/voice", voice); +app.use(express.urlencoded({ extended: false })); -app.post("/message", message); +app.post("/voice", twilio.webhook({ validate }), voice); + +app.post("/message", twilio.webhook({ validate }), message); app.get("/health", health); diff --git a/scripts/install.sh b/scripts/install.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash npm install typescript \ express \ + twilio \ @types/express \ @opencode-ai/sdk