generalbots/botbook/src/04-basic-scripting/keyword-send-template.md
Rodrigo Rodriguez (Pragmatismo) 037db5c381 feat: Major workspace reorganization and documentation update
- Add comprehensive documentation in botbook/ with 12 chapters
- Add botapp/ Tauri desktop application
- Add botdevice/ IoT device support
- Add botlib/ shared library crate
- Add botmodels/ Python ML models service
- Add botplugin/ browser extension
- Add botserver/ reorganized server code
- Add bottemplates/ bot templates
- Add bottest/ integration tests
- Add botui/ web UI server
- Add CI/CD workflows in .forgejo/workflows/
- Add AGENTS.md and PROD.md documentation
- Add dependency management scripts (DEPENDENCIES.sh/ps1)
- Remove legacy src/ structure and migrations
- Clean up temporary and backup files
2026-04-19 08:14:25 -03:00

2.3 KiB

SEND TEMPLATE Keywords

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

Keywords

Keyword Purpose
SEND_TEMPLATE Send template to single recipient
SEND_TEMPLATE_TO Send template to multiple recipients
CREATE_TEMPLATE Create a new message template
GET_TEMPLATE Retrieve 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

Channel Recipient Format
email Email address
whatsapp Phone number with country code
sms Phone number with country code
telegram Telegram user ID or username
push Device 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