Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SEND TEMPLATE Keywords

Send templated messages across multiple channels (email, WhatsApp, SMS, Telegram, push notifications).

Keywords

KeywordPurpose
SEND_TEMPLATESend template to single recipient
SEND_TEMPLATE_TOSend template to multiple recipients
CREATE_TEMPLATECreate a new message template
GET_TEMPLATERetrieve template by name

SEND_TEMPLATE

result = SEND_TEMPLATE "welcome", "user@example.com", "email"

With variables:

vars = {"name": "John", "order_id": "12345"}
result = SEND_TEMPLATE "order_confirmation", "+1234567890", "whatsapp", vars

SEND_TEMPLATE_TO

Send to multiple recipients:

recipients = ["user1@example.com", "user2@example.com", "user3@example.com"]
result = SEND_TEMPLATE_TO "newsletter", recipients, "email"

TALK "Sent: " + result.sent + ", Failed: " + result.failed

Supported Channels

ChannelRecipient Format
emailEmail address
whatsappPhone number with country code
smsPhone number with country code
telegramTelegram user ID or username
pushDevice token or user ID

CREATE_TEMPLATE

template_body = "Hello {{name}}, your order {{order_id}} has shipped!"
result = CREATE_TEMPLATE "shipping_notification", template_body, "transactional"

Template Variables

Use {{variable_name}} syntax in templates:

vars = {
    "customer_name": "Alice",
    "amount": "$99.00",
    "date": "March 15, 2024"
}
result = SEND_TEMPLATE "receipt", "alice@example.com", "email", vars

Example: Order Notification

' Send order confirmation across multiple channels
order_vars = {
    "order_id": order.id,
    "total": order.total,
    "items": order.item_count
}

SEND_TEMPLATE "order_placed", customer.email, "email", order_vars
SEND_TEMPLATE "order_placed", customer.phone, "whatsapp", order_vars

Response Object

{
    "success": true,
    "message_id": "msg_123abc",
    "channel": "email",
    "recipient": "user@example.com"
}

For batch sends:

{
    "total": 100,
    "sent": 98,
    "failed": 2,
    "errors": [...]
}

See Also