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 3347798170c3468352782d01f9ad1a59e0047937
parent bcf46c759145c96c2235f02e1c8dcb0abb1501d1
Author: Henry Unite <unitehenry@gmail.com>
Date:   Thu, 26 Feb 2026 08:45:46 +0000

chore: format

Diffstat:
Mapp.ts | 8++++----
Mhealth.ts | 4++--
Mmessage.ts | 6+++---
Mprompt.ts | 8++++----
Mvoice.ts | 14+++++++-------
5 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/app.ts b/app.ts @@ -1,8 +1,8 @@ -import express from 'express'; +import express from "express"; import log from "./log.ts"; -import message from './message.ts'; -import voice from './voice.ts'; -import health from './health.ts'; +import message from "./message.ts"; +import voice from "./voice.ts"; +import health from "./health.ts"; const app = express(); diff --git a/health.ts b/health.ts @@ -1,5 +1,5 @@ -import { type Request, type Response } from 'express'; +import { type Request, type Response } from "express"; export default async (req: Request, res: Response): Promise<void> => { res.sendStatus(200); -} +}; diff --git a/message.ts b/message.ts @@ -1,6 +1,6 @@ import { type Request, type Response } from "express"; -import prompt from './prompt.ts'; -import log from './log.ts'; +import prompt from "./prompt.ts"; +import log from "./log.ts"; function buildResponse(message: string): string { return `<?xml version="1.0" encoding="UTF-8"?> @@ -32,4 +32,4 @@ export default async (req: Request, res: Response): Promise<void> => { res.set("Content-Type", "text/xml"); res.send(message); -} +}; diff --git a/prompt.ts b/prompt.ts @@ -7,11 +7,11 @@ interface PromptResult { } interface PromptParams { - message: string, - sessionId?: string + message: string; + sessionId?: string; } -export default async (params : PromptParams): Promise<PromptResult> => { +export default async (params: PromptParams): Promise<PromptResult> => { const baseUrl = "http://127.0.0.1:36967"; const { message, sessionId } = params; @@ -46,4 +46,4 @@ export default async (params : PromptParams): Promise<PromptResult> => { .reduce((response: string, part) => response + " " + part.text, ""); return { sessionId: id, text }; -} +}; diff --git a/voice.ts b/voice.ts @@ -1,8 +1,8 @@ import { type Request, type Response } from "express"; -import prompt from './prompt.ts'; -import log from './log.ts'; +import prompt from "./prompt.ts"; +import log from "./log.ts"; -function buildResponse(message : string) : string { +function buildResponse(message: string): string { return `<?xml version="1.0" encoding="UTF-8"?> <Response> <Gather input="speech" action="/" method="POST"> @@ -22,9 +22,9 @@ export default async (req: Request, res: Response): Promise<void> => { const speechResult: string = req.body.SpeechResult; if (!speechResult) { - log('INFO', 'No speech result received'); + log("INFO", "No speech result received"); - const response = buildResponse('Please say something.'); + const response = buildResponse("Please say something."); res.set("Content-Type", "text/xml"); @@ -46,9 +46,9 @@ export default async (req: Request, res: Response): Promise<void> => { log("INFO", "Session cached", { callId, sessionId }); - const response = buildResponse('Please say something.'); + const response = buildResponse("Please say something."); res.set("Content-Type", "text/xml"); res.send(response); -} +};