APIs to power Virtual Visit, built using Twilio Functions.
NOTE: this is a demo project and should not be deployed to a production environment as is.
POST /room
curl -i -X POST "http://localhost:3000/room"
Response example:
{
"sid": "RM00000000000000000000"
}
GET /token
Attribute | Type | Required | Description |
---|---|---|---|
room |
string | yes | The room sid a token is being requested for |
curl -i -X GET "http://localhost:3000/token?room=RM00000000000000000000"
Response example:
{
"token": "0000000000000000000000"
}
POST /invitation
Attribute | Type | Required | Description |
---|---|---|---|
room |
string | yes | The room sid to include in the invitation |
phone |
string | yes | The phone number to send the invitation to via SMS |
curl -i -X POST -H "Content-Type: application/json" -d '{"room": "RM00000000000000000000", "phone": "0000000000"}' "http://localhost:3000/invitation"
Response example:
200 OK
API_KEY
: Used to grant access tokens - find this in the consoleAPI_SECRET
: Also used to grant access tokens - and also found in the consoleINVITE_BASE_URL
: The base URL sent as part of the Virtual Visit invitation. This is the URL where your web app will be hosted. For local testing, set this to your computer's local IP (e.g.http://192.168.0.1
) which can be retrieved by running:hostname -I
PHONE_NUMBER
: A Twilio phone number - you can get one here
- Install and setup the Twilio CLI
- Clone this repo
- Create a .env file at the root of the project with the environment variables listed above set. Addtionally add your Twilio
ACCOUNT_SID
andAUTH_TOKEN
- From the project directory, run:
twilio serverless:start
Warning: This service uses Twilio resources and should not be deployed in a production environment without a proper authorization system in place.
In the Twilio Functions Configuration dashboard:
- Ensure "Enable ACCOUNT_SID and AUTH_TOKEN" is enabled
- Create and add the environment variables listed above to your Twilio Environment Variables
- Install and setup the Twilio CLI
- Clone this repo
- From the project directory, run:
twilio serverless:deploy
Your functions will be deployed to the Twilio Runtime.
Make note of your function URLs from the Deployment Details.
Once you've tested your APIs and no longer using them they should be deleted. This can be done using the Twilio CLI:
- Run
twilio serverless:list
and copy theSID
of thevirtualvisit-twilio-serverless
project - Run
twilio api:serverless:v1:services:remove --sid <SID>
using theSID
from the previous step to remove the resource