Deploy a Word Game in 5 Minutes with Twilio Functions

June 24, 2020
Written by
Reviewed by
Diane Phan
Twilion

Deploy a Word Game in 5 Minutes with Twilio Functions

If the number of virtual social gatherings you attend regularly has increased over the past few months, you may have found yourself awkwardly ending a call when all the attendees have run out of things to talk about, or playing the same virtual party game more times than you can count, or perhaps like me you’ve just resorted to reading memes out loud to your friends. If you’re looking to inject more creativity and conversation into your calls, follow along in this post to add a new twist on an old word game to your “Virtual Happy Hour Survival Kit”. Fictionary and this SMS version, BalderText, challenge players to write convincing definitions for uncommon English words to try and trick other players.

Using Twilio Programmable SMS and Twilio Functions, this post will guide you through deploying and getting ready to play a game of BalderText in under five minutes.

Requirements

Deploy your own game

  1. Clone the repository from GitHub into a directory on your system: git clone git@github.com:eshenfield/baldertext.git
  2. Once you have the baldertext directory, run npm install inside of it to install the required deploy dependencies.
  3. Rename the included .env.example file to .env and replace the XXX placeholders with the credentials you gathered above in Requirements.
  4. Run npm run deploy to deploy your Baldertext instance using the Twilio Serverless toolkit. It should take a minute or two, and when the deploy is complete, it will list out the Deployment Details in your terminal. Copy the url listed under "Functions" (it should end in '/game') and save it for the next step.
  5. From the Twilio console, configure your phone number to respond to incoming messages with a Webhook that makes an HTTP POST request to the URL you saved in step 4.
The Twilio Console Messaging configuration for an active number
  • Text 'Join game' to your number to make sure everything is working!
  •  

Example text exchange with the BalderText game bot. I say "Join game Emily" and the bot response "You're in! respond with 'start game' when all players have joined."

How to play BalderText 

Objective

The goal of BalderText is to write a fake definition for an uncommon word that is convincing enough that the other players believe it is the real definition. Players receive points when other players choose their fake definitions and when they successfully choose the real definition. After 3 rounds, the player with the most points wins!

Scoring

Each player who chooses the real definition gets 2 points.

Each player gets 1 point for every other player who chooses their fake definition.

Gameplay

BalderText supports 2-8 players.

  1. Every player texts ‘Join game’ to your game phone number, followed by a username, ie. "Join game <username>}. When all players have joined, one player kicks off the game by texting ‘Start game’ to the game number.
  2. All players receive the same word in a text, with a prompt to generate a fake definition for the word that other players will be likely to pick. The players are prompted to respond with their made-up definition.
  3. Once everyone has submitted their fake definition, all players receive every submitted definition as well as the real definition (in random order). Each player votes on which definition they think is the real one.
  4. After scoring, the round ends and the game sends a score summary to each player before starting the next round.
  5. After 3 rounds, the game ends and the player with the most points wins.

Example text exchange with BalderText game bot for the defining and voting sections of the round.

Commands

These are the commands you can text to your deployed BalderText number:

Command

What does it do?

Join game <username>

Adds the message sender to the game with the provided username, or with their phone number if no username is provided.

Start game

Begins the first round of gameplay. No new players can join the game while it is active.

End game

Stops and removes the active game, if there is one. Players have to rejoin using the Join game command before starting a new game.

<definition>

Submits a definition for a player. Punctuation and capitalization is preserved in the player's response.

<number>

Logs the player's vote for the definition with the number submitted.

 

What next?

Now that you’ve deployed your own version of BalderText -- you can bring it out at your next virtual gathering and get your friends and family in on the game. If you feel inspired to extend or update BalderText, or to build your own virtual happy hour survival game with Twilio, contribute to the GitHub repo, tell us about it here in the comments, or send me an email at eshenfield [at] twilio [dot] com. And check out the links below for more information about the tools I used to build BalderText. We can’t wait to see how you play!

 

Emily Shenfield is a Developer Educator at Twilio. She focuses on creating engaging demos of Twilio tools to inspire other developers to use Twilio in new and innovative ways. She is a homebody and is secretly really jazzed to be able to see all of her friends without leaving the comfort of  her couch. You can reach her at eshenfield [at] twilio.com.