This is a project that I worked on during Vonage OneHack 2020. It's a simple trivia game that downloads questions from the Open Trivia Database API and presents them to the user. It uses the Vonage Sandbox WhatsApp account.
It could do with some work - the error checking isn't fit for purpose and you might want to implement categories, difficulty levels, etc. See here for details.
-
Clone this repo to your local machine.
-
In your working directory, create a Nexmo application:
nexmo app:create "WA Trivia App" --capabilities=messages --messages-inbound-url=https://example.com/webhooks/inbound-message --messages-status-url=https://example.com/webhooks/message-status --keyfile=private.key
This downloads a
private.key
file containing your authentication details and a.nexmo-app
file that contains those together with yourAPPLICATION_ID
. -
Copy
example.env
to.env
and fill in the blanks. TheFROM_NUMBER
is your Nexmo virtual number. TheTO_NUMBER
is the number that identifies your WhatsApp account. The pre-filledWHATSAPP_NUMBER
is for the Sandbox account. TheAPPLICATION_ID
is the one you generated in the preceding step. -
Run
ngrok
to get some temporary tunnel URLs:ngrok http 5000
-
Visit the Messages Sandbox and follow the instructions to whitelist your
TO_NUMBER
. -
Enter the following URLs in the "Webhooks" section:
- Inbound:
NGROK_URL/webhooks/inbound
- Status:
NGROK_URL/webhooks/status
- Inbound:
-
With ngrok running, launch your app:
npm start
-
Send the word
quiz
to the WhatsApp Sandbox account and the quiz should start!