botserver/docs/src/chapter-06-gbdialog/keyword-print.md
Rodrigo Rodriguez (Pragmatismo) 06c75cb690 Looking at this diff, I can see it's a comprehensive documentation
update and code refactoring focused on:

1. Adding new documentation pages to the table of contents
2. Restructuring the bot templates documentation
3. Changing keyword syntax from underscore format to space format (e.g.,
   `SET_BOT_MEMORY` → `SET BOT MEMORY`)
4. Updating compiler and keyword registration to support the new
   space-based syntax
5. Adding new keyword modules (social media, lead scoring, templates,
   etc.)

Refactor BASIC keywords to use spaces instead of underscores

Change keyword syntax from underscore format (SET_BOT_MEMORY) to more
natural space-separated format (SET BOT MEMORY) throughout the codebase.

Key changes:
- Update Rhai custom syntax registration to use space tokens
- Simplify compiler preprocessing (fewer replacements needed)
- Update all template .bas files to use new syntax
- Expand documentation with consolidated examples and new sections
- Add new keyword modules: social_media, lead_scoring, send_template,
  core_functions, qrcode, sms, procedures, import_export, llm_macros,
  on_form_submit
2025-11-30 10:53:59 -03:00

2.7 KiB

PRINT

Debug output keyword. PRINT is an alias for TALK - both send messages to the current conversation.

Note: PRINT and TALK are equivalent. Use TALK for user-facing messages and PRINT for debug output during development. In production, prefer TALK for clarity.

Syntax

PRINT expression

Parameters

Parameter Type Description
expression Any The value to output (string, number, or any expression)

Description

PRINT outputs a message to the current conversation. It is functionally identical to TALK but conventionally used for debugging and logging purposes.

For sending messages to specific recipients on other channels, use:

  • TALK TO - Send to a specific recipient (WhatsApp, Teams, etc.)
  • SEND FILE TO - Send files to a specific recipient

Examples

Basic Debug Output

x = 10
y = 20
PRINT "Debug: x = " + x + ", y = " + y

result = x + y
PRINT "Result: " + result

Logging During Processing

WEBHOOK "process-order"

order_id = body.order_id
PRINT "Processing order: " + order_id

' Process the order
customer = FIND "customers", "id=" + body.customer_id
PRINT "Found customer: " + customer.name

' More processing...
PRINT "Order processing complete"

result_status = "ok"

Variable Inspection

data = GET "https://api.example.com/data"
PRINT "API Response: " + data

items = FIND "products", "stock < 10"
PRINT "Low stock items count: " + UBOUND(items)

Equivalent Keywords

Keyword Description
TALK Same as PRINT - send message to conversation
TALK TO Send message to specific recipient

Example: PRINT vs TALK TO

' Debug output (goes to current conversation)
PRINT "Starting order notification..."

' User-facing message to specific WhatsApp number
TALK TO "whatsapp:+5511999887766", "Your order is confirmed!"

' More debug output
PRINT "Notification sent successfully"

Best Practices

  1. Use TALK for production - More readable for user-facing messages
  2. Use PRINT for debugging - Makes it clear this is debug/log output
  3. Use TALK TO for channels - When sending to specific recipients
' Good: Clear intent
PRINT "Debug: Processing started"
TALK "Welcome! How can I help you?"
TALK TO "whatsapp:" + phone, "Your order is ready!"

' Also valid but less clear:
PRINT "Welcome! How can I help you?"  ' Works but TALK is clearer

See Also

  • TALK - Primary message output keyword
  • TALK TO - Send to specific recipients
  • SEND FILE TO - Send files to recipients