WhatsApp Sandbox Instructions in Twilio Console

Build better loan database with shared knowledge and strategies.
Post Reply
poxoja9630
Posts: 10
Joined: Sun Dec 22, 2024 5:32 am

WhatsApp Sandbox Instructions in Twilio Console

Post by poxoja9630 »

To use the Sandbox, you need to sign up by sending a message to the phone number you chose from WhatsApp. Send “join <sandbox keyword>” to your Sandbox number in WhatsApp, and you will receive a confirmation that you have joined the Sandbox. Your Sandbox keyword can be found in the console.

WhatsApp Sandbox Instructions in Twilio Console
Sending a WhatsApp message with Node.js
Now that you have a Twilio account and have enabled the WhatsApp philippines mobile number example Sandbox, you can dive into the code and send messages! Start by opening your terminal and navigating to the directory where you want your project to be active. Run the following command to initiate a file package.json for npm to install the dependencies:

Bash

Copy the code
npm init --yes
Now install the Twilio Helper Library for Node:

Bash

Image

Copy the code
npm install [email protected]
Once done, create a file named index.js in that same directory and add the code below to it (remember to replace the example phone numbers with your WhatsApp Sandbox number and your personal phone number, respectively):

Before running this code, make sure to set the environment variables TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN with their respective values ​​from your Twilio account credentials, which can be found in your Twilio console . The Twilio Node library will automatically look at these values, so you don't have to hardcode them into your file index.js ! Here's a helpful tutorial if you need help setting environment variables .

Finally, in your terminal, run the following command to run this code and send a message to yourself on WhatsApp:

Bash

Copy the code
node index.js
If you check your messages, you should see a screen similar to the following:

WhatsApp message on cell phone screen
Keep in mind that you'll need to use a pre-approved template if you want to send a message to someone more than 24 hours after their last incoming message.


What if I want to use another language?
You've just sent your first WhatsApp message with JavaScript, but how do you do it with Python or C#? We have other blog posts you can check out.
Post Reply