This is a Twilio webhook, hosted on vercel as a serverless function. It works together with the nurse-button-diy project. Any replies to the "nurse button has been pressed" Twilio message will trigger this webhook. It will message all designated recipients, letting everyone know that someone has acted upon the nurse button event.
The Twilio webhook is configured on the Twilio Console https://console.twilio.com
sequenceDiagram
participant Patient
participant nurse-button-diy
participant Twilio Number
participant Caregiver 1
participant Caregiver 2
Patient->>nurse-button-diy: Presses button
nurse-button-diy->>Twilio Number: Send messages
Note over Twilio Number,Caregiver 2: Message sent to all caregivers
Twilio Number->>Caregiver 1: SMS "The nurse button has been pressed"
Twilio Number->>Caregiver 2: SMS "The nurse button has been pressed"
Note over Twilio Number,Caregiver 2: A caregiver replies that they are attending to it
Caregiver 2-->>Twilio Number: SMS "On it" (or anything)
Note over Twilio Number,Caregiver 2: Update message sent to all caregivers (this webhook!)
Twilio Number->>Caregiver 1: SMS "A caregiver is attending to it"
Twilio Number->>Caregiver 2: SMS "A caregiver is attending to it"
Installs the vercel CLI.
Installs the necessary packages.
Create a .env
file at the root of the project to set the environment variables
# sid and auth token from https://console.twilio.com/
TWILIO_ACCOUNT_SID=<account_sid>
TWILIO_AUTH_TOKEN=<auth_token>
# phone numbers must be in E.164 format
TWILIO_FROM_NUMBER=+1234567890
# comma separate list of phone numbers to send the SMS to
TWILIO_TO_NUMBERS=+12345678901,+13456789012
Note: You can also set development environment variables using the vercel dashboard.
The vercel
cli is used to run the serverless functions locally. You will need to login to vercel and setup/link a vercel project. The vercel dev
command will walk you through these steps.