How promptable/twilio-gpt-sms works
This is a TypeScript SMS chatbot starter: an incoming Twilio message reaches an Express webhook, which obtains a conversation-aware GPT reply and returns it as TwiML. The main runtime stages are webhook handling, in-memory per-phone conversation state, prompt preparation, external prompt retrieval and completion generation, and SMS response construction. The README documents Twilio setup and optional Promptable prompts; the source also shows the in-memory store and AI call sites. Deployment and build tooling are omitted. Relationships involving Twilio are documented in the README; the sampled source does not show webhook validation.
Main entry points: gpt3.ts Reply Orchestrator · messages.ts Message Handler · index.ts HTTP Server · server.ts Express App
Components 12
SMS Webhook
- HTTP Server
index.ts - Express App
server.ts - Message Handler
routes/messages.ts - Webhook Request Type
types/request.ts - Port Configuration
config.ts
Conversation Runtime
- Reply Orchestrator
src/gpt3.ts - Chat History Store
src/chatHistory.ts - Prompt Preparation
src/gpt3.ts
Other components
- SMS Sender
- Twilio Messaging
- Promptable Deployment
- OpenAI Completion
Connections 12
- SMS Sender → Twilio Messaging: sends SMS
README.md - Twilio Messaging → Message Handler: posts webhook
README.md - HTTP Server → Express App: starts
index.ts - HTTP Server → Port Configuration: reads port
index.ts - Express App → Message Handler: mounts route
server.ts - Message Handler → Webhook Request Type: types request
routes/messages.ts - Message Handler → Reply Orchestrator: requests reply
routes/messages.ts - Reply Orchestrator → Chat History Store: reads and updates
src/gpt3.ts - Reply Orchestrator → Prompt Preparation: formats prompt
src/gpt3.ts - Reply Orchestrator → Promptable Deployment: fetches deployment
src/gpt3.ts - Reply Orchestrator → OpenAI Completion: requests completion
src/gpt3.ts - Message Handler → Twilio Messaging: returns TwiML
README.md