This sample code was created for Local Hack Day Build! Taking part in Local Hack Day and have questions about Twilio, or this code? Drop into the #ask-twilio channel on the MLH Discord.
- Clone the repository.
cd
into the cloned directory.- Serve it via a webserver, such as
npx serve .
. - Open the page in your browser.
- Create a Twilio account
- Create a new API key, and save the secret.
- Create a Twilio Sync Servce
- Create a Twilio Function Service
- Add the environment variables to your Twilio Function Service:
- TWILIO_API_KEY: your created API key
- TWILIO_API_SECRET: your created API secret
- TWILIO_SYNC_SERVICE_SID: the SID of the created Sync service
- Create a new function, on the
token
route. - Copy and paste the contents of
tokenGenerator.js
into your new function. - Save and deploy the function.
- Insert that URL into line 11 of
index.html
, replacingFUNCTION_URL
.