Skip to main content
Send Message lets a running agent reach the user proactively on their configured channels — without waiting for the next user turn.
The user starts a long job; the agent proactively messages them on Telegram, Slack, or email when it finishes.

Quick Start

1

Give Your Agent the Tool

The agent can now call send_message at any point mid-task to push a notification to the user.
2

List Available Targets

Use action="list" first when you want the agent to pick the right channel rather than defaulting to "origin".
3

Send with a File Attachment

Append MEDIA:<path> to the message text to attach a local file. Multiple attachments are supported.
Media attachments aren’t delivered yet. The text portion is sent, the MEDIA: paths are parsed and counted, and the result detail confirms how many files were skipped. File delivery will land in a future transport update — track PraisonAI#2374 for follow-ups.

How It Works


Targets

Choose the right target form for your situation:

Attachments (MEDIA:)

Append MEDIA:<path> to the message string to attach a local file to the delivery.
File paths must not contain whitespace. The MEDIA: directive is stripped from the displayed message text before delivery.

Listing Targets

action="list" returns a JSON array of all reachable targets so the agent can pick the right one before sending.
Each entry in the array: "observed" means a channel the gateway has seen activity on but is not a configured home or alias.

When It’s Available

When no gateway is active the tool returns:
Agent instructions can check for this string and fall back gracefully.

User Interaction Flow

A user starts a long research task on Telegram, then closes their phone. The agent finishes compiling the report, calls send_message("origin", "Your report is ready MEDIA:/tmp/report.pdf"), and the user receives a Telegram push notification with the text — without ever having to ask “are you done yet?”.

Configuration Reference

send_message takes three arguments. All are optional: action="send" vs action="list" at a glance:

Common Patterns

Notify on long-task completion

Cross-channel handoff

Pick the target from the list, then send


Best Practices

Call send_message(action="list") first when the user hasn’t specified where they want to be notified. Sending to a channel the user doesn’t monitor is noise.
"origin" sends to the chat the conversation started in — usually the right choice. Only override it when you have a specific reason (e.g., sending an ops alert to a dedicated Slack channel).
Include a note like “If send_message returns a ‘No active gateway’ message, skip the notification and continue.” so the agent doesn’t retry endlessly on CLI runs.
Mobile push notifications truncate long text. Send a one-line summary; attach details as a file with MEDIA:.

Send Policy

Restrict which channels send_message is allowed to deliver to

Clarify Tool

Ask the user mid-task for clarifying input

Channels Gateway

Connect agents to Telegram, Slack, Discord, and WhatsApp

Bot Gateway

Run the gateway server

Bot Routing

Route messages by channel and platform