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

README.md (1817B)


      1 # Twilio Opencode
      2 
      3 A lightweight express server to handle twilio voice and messaging webhooks for prompting opencode.
      4 
      5 ## Usage
      6 
      7 1. [Start an opencode server](https://opencode.ai/docs/server/)
      8 2. [Start the twilio opencode server](#start-server)
      9 3. [Configure twilio](#configure-twilio)
     10 
     11 ### Start server
     12 
     13 ```bash
     14 docker run twilio-opencode \
     15     -e OPENCODE_BASE_URL="http://127.0.0.1:4096" \
     16     -p 3000:3000
     17 ```
     18 
     19 ### Configure twilio
     20 
     21 Use the `/configure` endpoint to programatically update twilio phone number settings.
     22 
     23 ```bash
     24 TWILIO_ACCOUNT_SID="ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
     25 TWILIO_PHONE_NUMBER_SID="PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
     26 TWILIO_AUTH_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
     27 curl -X POST \
     28   "http://localhost:3000/configure" \
     29   -d "twilioAccountSid=$TWILIO_ACCOUNT_SID&twilioPhoneNumberSid=$TWILIO_PHONE_NUMBER_SID&twilioAuthToken=$TWILIO_AUTH_TOKEN"
     30 ```
     31 
     32 ## Environment variables
     33 
     34 | Variable | Description | Default |
     35 |----------|-------------|---------|
     36 | `OPENCODE_BASE_URL` | Base URL for the opencode client to connect to. | None |
     37 | `PORT` | Port on which the express server listens. | 3000 |
     38 | `FROM_WHITELIST` | Comma-separated list of whitelisted phone numbers for incoming requests. (Ex: `+1234567891,+13456789201`) If not set, all numbers will be able to prompt opencode. | None |
     39 | `TWILIO_AUTH_TOKEN` | Twilio Auth Token for webhook validation. If not set, webhooks will not be validated. | None |
     40 
     41 ## Local proxy
     42 
     43 There is a `ngrok` script to make local development easy.
     44 
     45 ```bash
     46 TWILIO_ACCOUNT_SID="ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
     47 TWILIO_PHONE_NUMBER_SID="PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
     48 TWILIO_AUTH_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
     49 OPENCODE_BASE_URL="http://127.0.0.1:4096" \
     50 scripts/ngrok.sh
     51 ```
     52 
     53 ## Build an image
     54 
     55 ```bash
     56 scripts/build.sh
     57 ```