Skip to content

gabeoliveira/whatsapp-bulk-send

Folders and files

NameName
Last commit message
Last commit date

Latest commit

12663e7 · Apr 27, 2023

History

2 Commits
Apr 27, 2023
Apr 27, 2023
Apr 27, 2023
Apr 27, 2023
Apr 27, 2023
Apr 27, 2023
Apr 27, 2023
Apr 27, 2023
Apr 27, 2023
Apr 27, 2023
Apr 27, 2023
Apr 27, 2023
Apr 27, 2023

Repository files navigation

Whatsapp Bulk Send Quickstart

Solution Description

This Node.js script reads a CSV file, sends a WhatsApp message to each phone number listed in the file using Twilio Programmable Messaging (using a pre-registered Content from the Content API/Editor), and then registers the message using Twilio Sync.

High Level Architecture

High Level Architecture

Requirements

Twilio Features

Functions Deployment

Running the Script

  • Node.js installed. (Minimum Version: Nodejs v12)

Setup

  1. Clone this repository
  2. In the root folder, copy the Environment Variables file sample into a production file
    • cp .env.example .env
  3. Install dependencies
    • npm install
  4. Setup .env with your Twilio Project Service SIDs and WhatsApp Phone Number
    1. API Key SID and Secret
    2. Sync Service SID
    3. Create a new Sync Service Map, navigate back to your Sync Service and copy the SID
    4. WhatsApp Phone Number
  5. Navigate to contact-helper
    • cd contact-helper
  6. Copy the Serverless Application Environment Variables file sample into a production file
    • cp .env.example .env
  7. Setup .env using the same info from the script Environment File, except for the WhatsApp Phone Number
  8. Deploy the Twilio Functions
    • twilio serverless:deploy

Running the Script

  1. In the root folder, run node load-contact-list.js [contacts list CSV path]
  2. The CSV file must contain the following columns (in any order):
    • PHONE
    • TEMPLATE
    • Template variables with numbers (1,2,3, etc)

Checking Context

The get-contact function expects two parameters:

  • phone: The sender phone number (OBS: Twilio processes WhatsApp phone numbers as whatsapp:<phone number>. Don't worry about parsing the number. The function already takes care of this)
  • originalMessageSid: The Original Message SID. In Studio, it'll be part of the trigger message, in {{trigger.message.OriginalRepliedMessageSid}}

Create New Content

To create new content you can go to the Content Editor or use the Content API directly. Keep in mind that WhatsApp must approve content to be used as outbound messages

Disclaimer

Beware that this solutions is meant only as a quickstart for bulk sending WhatsApp messages. Keep in mind thar Twilio APIs are rate limited, which means you will need to implement some sort of backoff or pacing logic to avoid 429 errors.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published