Broadcast Template
The broadcast template enables mass messaging to contact lists, perfect for announcements, marketing campaigns, and bulk notifications through WhatsApp and other channels.
Topic: Mass Messaging & Announcements
This template is perfect for:
- Company-wide announcements
- Marketing campaigns
- Customer notifications
- Event reminders
- Newsletter distribution
The Code
PARAM message AS STRING LIKE "Hello {name}, how are you?" DESCRIPTION "Message to broadcast, supports {name} and {mobile} variables"
PARAM listfile AS STRING LIKE "broadcast.csv" DESCRIPTION "CSV file with contacts (name, mobile columns)"
PARAM filter AS STRING LIKE "status=active" DESCRIPTION "Filter condition for contact list" OPTIONAL
DESCRIPTION "Send broadcast message to a list of contacts from CSV file"
IF NOT listfile THEN
listfile = "broadcast.csv"
END IF
IF filter THEN
list = FIND listfile, filter
ELSE
list = FIND listfile
END IF
IF UBOUND(list) = 0 THEN
TALK "No contacts found in " + listfile
RETURN 0
END IF
index = 1
sent = 0
DO WHILE index < UBOUND(list)
row = list[index]
msg = REPLACE(message, "{name}", row.name)
msg = REPLACE(msg, "{mobile}", row.mobile)
TALK TO row.mobile, msg
WAIT 5
WITH logEntry
timestamp = NOW()
user = USERNAME
from = FROM
mobile = row.mobile
name = row.name
status = "sent"
END WITH
SAVE "Log.xlsx", logEntry
sent = sent + 1
index = index + 1
LOOP
TALK "Broadcast sent to " + sent + " contacts."
RETURN sent
Sample Dialogs
These conversations show how the broadcast template works in real-world scenarios.
Dialog 1: Simple Broadcast
π’
Broadcast Bot
online
Today
Dialog 2: Filtered Broadcast
π’
Broadcast Bot
online
Dialog 3: No Contacts Found
π’
Broadcast Bot
online
Keywords Used
| Keyword | Purpose |
|---|---|
PARAM | Define input parameters with descriptions |
DESCRIPTION | Tool description for AI |
FIND | Query contacts from CSV file |
REPLACE | Substitute variables in message template |
TALK TO | Send message to specific phone number |
WAIT | Delay between messages (rate limiting) |
SAVE | Log each message to spreadsheet |
RETURN | Return count of sent messages |
How It Works
- Load Contacts:
FINDretrieves contacts from CSV with optional filter - Validate List: Checks if contacts were found
- Loop Through Contacts: Iterates through each contact
- Personalize Message:
REPLACEsubstitutes {name} and {mobile} - Send Message:
TALK TOdelivers to each phone number - Rate Limiting:
WAIT 5pauses 5 seconds between messages - Log Operation: Each send is recorded in Log.xlsx
- Report Results: Returns total messages sent
Contact List Format
Your CSV file should have these columns:
name,mobile,status,segment
John Smith,+5511999999999,active,regular
Maria Garcia,+5521888888888,active,vip
Carlos Santos,+5531777777777,inactive,regular
Ana Lima,+5541666666666,active,vip
| Column | Required | Description |
|---|---|---|
name | Yes | Contactβs display name |
mobile | Yes | Phone in international format |
status | No | For filtering (active/inactive) |
segment | No | For targeting (vip/regular) |
Customization Ideas
Add Message Templates
ADD TOOL "broadcast"
ADD TOOL "list-templates"
ADD TOOL "create-template"
' Load saved templates
templates = FIND "message_templates.csv"
TALK "Available templates:"
FOR EACH template IN templates
TALK "β’ " + template.name + ": " + LEFT(template.message, 50) + "..."
NEXT
TALK "Which template would you like to use?"
HEAR templateName
selected = FIND "message_templates.csv", "name = '" + templateName + "'"
message = selected.message
Add Scheduling
PARAM schedule_time AS STRING LIKE "2025-01-20 09:00" DESCRIPTION "When to send (optional)"
IF schedule_time THEN
SET SCHEDULE schedule_time
' Store broadcast details for later
SET BOT MEMORY "scheduled_message", message
SET BOT MEMORY "scheduled_list", listfile
SET BOT MEMORY "scheduled_filter", filter
TALK "π
Broadcast scheduled for " + schedule_time
TALK "I'll send to " + UBOUND(list) + " contacts at that time."
RETURN 0
END IF
Add Progress Updates
total = UBOUND(list)
checkpoints = [25, 50, 75, 100]
DO WHILE index <= total
' ... send message ...
' Check progress
percent = INT((index / total) * 100)
IF INARRAY(percent, checkpoints) THEN
TALK "π Progress: " + percent + "% (" + index + "/" + total + ")"
END IF
index = index + 1
LOOP
Add Opt-Out Handling
' Check if contact has opted out
optouts = FIND "optouts.csv"
DO WHILE index <= UBOUND(list)
row = list[index]
' Skip opted-out contacts
IF FIND("optouts.csv", "mobile = '" + row.mobile + "'") THEN
WITH logEntry
mobile = row.mobile
status = "skipped-optout"
END WITH
SAVE "Log.xlsx", logEntry
index = index + 1
CONTINUE
END IF
' ... send message ...
LOOP
Add Media Support
PARAM image AS STRING LIKE "promo.jpg" DESCRIPTION "Image to include (optional)"
IF image THEN
msg = msg + "\n[Image: " + image + "]"
TALK TO row.mobile, msg, image
ELSE
TALK TO row.mobile, msg
END IF
Best Practices
Message Content
- Personalize: Always use
{name}for a personal touch - Be Concise: Keep messages short and clear
- Clear CTA: Include a clear call-to-action
- Identify Yourself: Make sure recipients know whoβs messaging
Compliance
- Consent Required: Only message contacts who opted in
- Easy Opt-Out: Include unsubscribe instructions
- Respect Hours: Donβt send late at night
- Honor Limits: WhatsApp has daily messaging limits
Performance
- Rate Limiting: Keep 5+ second delays to avoid blocks
- Batch Processing: For large lists, consider batching
- Error Handling: Log and handle failed sends
- Monitor Results: Check logs for delivery issues
Logging Structure
The Log.xlsx file tracks all broadcast activity:
| Column | Description |
|---|---|
| timestamp | When message was sent |
| user | Who initiated the broadcast |
| from | Sender identifier |
| mobile | Recipient phone number |
| name | Recipient name |
| status | sent/failed/skipped |
| error | Error message if failed |
Related Templates
- announcements.bas - Company announcements system
- whatsapp.bas - WhatsApp-specific features
- store.bas - E-commerce with customer notifications