Skip to content

waveformhealth/virtualvisit-twilio-serverless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

virtualvisit-twilio-serverless

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.

API

Create a room

POST /room
curl -i -X POST "http://localhost:3000/room"

Response example:

{
  "sid": "RM00000000000000000000"
}

Request a token

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"
}

Send an invitation

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

Environment Variables

  1. API_KEY: Used to grant access tokens - find this in the console
  2. API_SECRET: Also used to grant access tokens - and also found in the console
  3. INVITE_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
  4. PHONE_NUMBER: A Twilio phone number - you can get one here

Local Testing

  1. Install and setup the Twilio CLI
  2. Clone this repo
  3. Create a .env file at the root of the project with the environment variables listed above set. Addtionally add your Twilio ACCOUNT_SID and AUTH_TOKEN
  4. From the project directory, run: twilio serverless:start

Deployment

Warning: This service uses Twilio resources and should not be deployed in a production environment without a proper authorization system in place.

Setup

In the Twilio Functions Configuration dashboard:

  1. Ensure "Enable ACCOUNT_SID and AUTH_TOKEN" is enabled
  2. Create and add the environment variables listed above to your Twilio Environment Variables

Deploy

  1. Install and setup the Twilio CLI
  2. Clone this repo
  3. 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.

Cleanup

Once you've tested your APIs and no longer using them they should be deleted. This can be done using the Twilio CLI:

  1. Run twilio serverless:list and copy the SID of the virtualvisit-twilio-serverless project
  2. Run twilio api:serverless:v1:services:remove --sid <SID> using the SID from the previous step to remove the resource

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published