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.keyThis downloads a
private.keyfile containing your authentication details and a.nexmo-appfile that contains those together with yourAPPLICATION_ID. -
Copy
example.envto.envand fill in the blanks. TheFROM_NUMBERis your Nexmo virtual number. TheTO_NUMBERis the number that identifies your WhatsApp account. The pre-filledWHATSAPP_NUMBERis for the Sandbox account. TheAPPLICATION_IDis the one you generated in the preceding step. -
Run
ngrokto 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
quizto the WhatsApp Sandbox account and the quiz should start!