This is the server component of Virtual Visit, a product for making video calls simple for patients in hospitals. This project was created during the Twilio x DEV community hackathon.
This application creates a web service to manage Virtual Visits (video calls) using Twilio Programmable Video. It also uses Twilio Programmable SMS for sending Virtual Visit invitations.
- Web server using Ktor
Dockerfile
for easy development and deployment using Docker- One click deploy button for Heroku
The following steps assume you are running Linux but should be adaptable for Mac or Windows
Before we begin, we need to collect all the environment variables we need to run the application:
Environment Variable | Description |
---|---|
TWILIO_ACCOUNT_SID | Your primary Twilio account identifier - find this in the Console. |
TWILIO_AUTH_TOKEN | Used to authenticate - just like the above, you'll find this here. |
TWILIO_API_KEY | Used to grant access tokens - find this in the console. |
TWILIO_API_SECRET | Also used to grant access tokens - and also found in the console. |
TWILIO_PHONE_NUMBER | A Twilio phone number - you can get one here |
INVITE_BASE_URL | The base URL sent as part of the Virtual Visit invitation |
The easiest way to getting started with development on the project is to use Intellij IDEA.
After installation, start Intellij and create a new project from version control:
File > New > Project from Version Control...
Ensuring "Git" is selected, enter this repository URL and then click "Clone".
With the new project opened, edit your configuration to set the required environment variables:
- Run > Edit Configurations...
- Click the "Kotlin" dropdown, select the
virtualvisit
configuration, and click the Copy icon - Ensure the "Store as project file" toggle is not selected
- Select the "Environment variables" "Browse" button to update the environment variables for this configuration
- Clone this repository and
cd
into it
git clone [email protected]:waveformhealth/virtualvisit-server.git
cd virtualvisit-server
- Build the Docker image
sudo docker build -t virtualvisit-app .
- Create the env-file for Docker
Copy the env.list.dev
file to env.list
:
cp env.list.dev env.list
Now edit env.list
and add your [environment variables](#environment variables).
- Run the application
sudo docker run -m512M --cpus 2 -it --env-file ./env.list -p 8080:8080 --rm virtualvisit-app
That's it! The server can now be accessed at localhost:8080
. See the API docs to discover the APIs.
In addition to trying out this application locally, you can easily deploy it to a variety of host services as a Docker container.
You can also try out one click deployments below.
Service | |
---|---|
Heroku |
NOTE: The secret
used below refers to a code randomly generated by the server.
If specified in the examples below, this code must be provided by the client in order to access the resource.
This is only for development and testing purposes. This mechanism should be replaced before deploying to production.
POST /v1/room
curl -u secret: -X POST "https://example.com/v1/room"
Response example:
{
"sid": "RM00000000000000000000"
}
GET /v1/token
Attribute | Type | Required | Description |
---|---|---|---|
room |
string | yes | The room sid a token is being requested for |
code |
string | no (optional) | The room access code. Required if an Authentication token is not provided |
curl -u secret: -X GET "https://example.com/v1/token?room=RM00000000000000000000"
The
secret
here is optional if a valid room and room accesscode
are provided
Response example:
{
"token": "0000000000000000000000"
}
POST /v1/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 -u secret: -X POST -H "Content-Type: application/json" -d '{"room": "RM00000000000000000000", "phone": "0000000000"}' "https://example.com/v1/invitation"
Response example:
202 Accepted