sendMessage method allows you to send messages directly to users through the bot’s provider (WhatsApp, Telegram, etc.). This method is particularly useful when you need to send messages programmatically outside of the normal flow context, such as from HTTP endpoints or scheduled tasks.
Method Signature
The recipient’s identifier (phone number for WhatsApp, user ID for other platforms)
The text message to send to the user
Additional options for the message
Returns a promise that resolves with the provider’s response after sending the message
Usage Examples
Basic Text Message
Message with Media
Sending Image from Local Path
Sending Multiple Media Types
Important Notes
- The
sendMessagemethod is available on thebotobject in HTTP endpoints viahandleCtx - The method bypasses the normal flow logic and sends messages directly through the provider
- Media files can be provided as URLs or local file paths
- The actual return type depends on the provider being used (WhatsApp, Telegram, etc.)
- Messages sent with this method are not tracked in the conversation flow history
Related Methods
- dispatch - Trigger flows programmatically
- flowDynamic - Send dynamic messages within flows
See Also
- HTTP Server - Learn about creating HTTP endpoints
- Media Messages - Complete guide on sending media