Multiplayer Kaboom.js with Twilio Sync

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.

How to play

  • Clone the repository.
  • cd into the cloned directory.
  • Serve it via a webserver, such as npx serve ..
  • Open the page in your browser.

Setup

  1. Create a Twilio account
  2. Create a new API key, and save the secret.
  3. Create a Twilio Sync Servce
  4. Create a Twilio Function Service
  5. 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
  6. Create a new function, on the token route.
  7. Copy and paste the contents of tokenGenerator.js into your new function.
  8. Save and deploy the function.
  9. Insert that URL into line 11 of index.html, replacing FUNCTION_URL.