Skip to main content

Communication Tools

Communication tools enable agents to send messages, manage conversations, and interact with popular communication platforms.

Email

send_email

Send email via SMTP.
to
string
required
Recipient email address
subject
string
required
Email subject line
body
string
required
Email body (HTML or plain text)
from_email
string
Sender email address (optional if configured)
cc
string
CC recipients (comma-separated)
bcc
string
BCC recipients (comma-separated)
Example
result = send_email(
    to="[email protected]",
    subject="Agent Report",
    body="<h1>Daily Summary</h1><p>Tasks completed: 15</p>",
    cc="[email protected]"
)

if result["success"]:
    print(f"Email sent: {result['message_id']}")

Configuration

Environment Variables
export SMTP_HOST=smtp.gmail.com
export SMTP_PORT=587
export SMTP_USER=your-email@gmail.com
export SMTP_PASSWORD=your-app-password

Gmail

gmail_list_messages

List Gmail messages using search queries.
query
string
default:"is:unread"
Gmail search query
max_results
integer
default:"100"
Maximum messages to return (1-500)
page_token
string
Token for fetching next page
account
string
Account alias for multi-account support
result = gmail_list_messages(
    query="is:unread",
    max_results=50
)

for msg in result["messages"]:
    print(f"ID: {msg['id']}, Thread: {msg['threadId']}")

Common Gmail Queries

QueryDescription
is:unreadUnread messages
from:[email protected]From specific sender
subject:reportSubject contains “report”
has:attachmentHas attachments
newer_than:7dLast 7 days
label:INBOXIn inbox
is:starredStarred messages

gmail_get_message

Get detailed message information.
message_id
string
required
Gmail message ID
format
string
default:"metadata"
“metadata”, “full”, or “minimal”
account
string
Account alias
Example
result = gmail_get_message(
    message_id="abc123",
    format="full"
)

if result["success"]:
    print(f"Subject: {result['subject']}")
    print(f"From: {result['from']}")
    print(f"Date: {result['date']}")
    print(f"Body: {result['body']}")

gmail_modify_message

Modify labels on a message (star, mark read, etc.).
message_id
string
required
Gmail message ID
add_labels
list
Labels to add
remove_labels
list
Labels to remove
result = gmail_modify_message(
    message_id="abc123",
    add_labels=["STARRED"]
)

Common Label IDs

  • STARRED - Star a message
  • UNREAD - Mark as unread (remove to mark read)
  • IMPORTANT - Mark as important
  • SPAM - Mark as spam
  • TRASH - Move to trash
  • INBOX - Add to inbox
  • SENT - Sent messages
  • DRAFT - Draft messages

gmail_trash_message

Move message to trash.
result = gmail_trash_message(message_id="abc123")

gmail_create_draft

Create a draft email.
result = gmail_create_draft(
    to="[email protected]",
    subject="Follow-up",
    html="<p>Hi, following up on our conversation...</p>"
)

print(f"Draft ID: {result['draft_id']}")
print(f"Message ID: {result['message_id']}")

gmail_batch_modify_messages

Modify labels on multiple messages at once.
message_ids = ["id1", "id2", "id3"]

result = gmail_batch_modify_messages(
    message_ids=message_ids,
    add_labels=["STARRED"],
    remove_labels=["UNREAD"]
)

print(f"Modified {result['count']} messages")

Slack

slack_send_message

Send a message to a Slack channel.
channel
string
required
Channel ID or name (e.g., ‘C0123456789’ or ‘#general’)
text
string
required
Message text (supports Slack markdown)
thread_ts
string
Thread timestamp to reply in a thread
account
string
Account alias for multi-workspace support
Example
result = slack_send_message(
    channel="#general",
    text="Hello from the agent! :wave:"
)

if result["success"]:
    print(f"Message sent: {result['ts']}")

slack_list_channels

List channels in the workspace.
result = slack_list_channels(
    types="public_channel,private_channel",
    limit=100
)

for channel in result["channels"]:
    print(f"{channel['name']}: {channel['num_members']} members")

slack_get_channel_history

Get recent messages from a channel.
result = slack_get_channel_history(
    channel="C0123456789",
    limit=20
)

for msg in result["messages"]:
    print(f"{msg['user']}: {msg['text']}")

slack_add_reaction

Add emoji reaction to a message.
result = slack_add_reaction(
    channel="C0123456789",
    timestamp="1234567890.123456",
    emoji="thumbsup"
)

slack_create_channel

Create a new channel.
result = slack_create_channel(
    name="project-alpha",
    is_private=False
)

print(f"Channel created: {result['channel']['id']}")

slack_schedule_message

Schedule a message for future delivery.
import time

# Send in 1 hour
post_at = int(time.time()) + 3600

result = slack_schedule_message(
    channel="#general",
    text="Scheduled reminder",
    post_at=post_at
)

Configuration

Environment Variables
export SLACK_BOT_TOKEN=xoxb-your-bot-token
export SLACK_USER_TOKEN=xoxp-your-user-token  # For search API
Get tokens from:
  1. Create app at api.slack.com/apps
  2. Add OAuth scopes (channels:read, chat:write, etc.)
  3. Install to workspace
  4. Copy Bot/User OAuth tokens

Discord

discord_send_message

Send a message to a Discord channel.
channel_id
string
required
Discord channel ID
content
string
required
Message content (max 2000 characters)
tts
boolean
default:"false"
Enable text-to-speech
Example
result = discord_send_message(
    channel_id="123456789",
    content="Hello from the agent!"
)

if result["success"]:
    print(f"Message ID: {result['id']}")

discord_get_messages

Get recent messages from a channel.
channel_id
string
required
Discord channel ID
limit
integer
default:"50"
Number of messages (1-100)
before
string
Get messages before this message ID
after
string
Get messages after this message ID
result = discord_get_messages(
    channel_id="123456789",
    limit=50
)

for msg in result["messages"]:
    print(f"{msg['author']['username']}: {msg['content']}")

discord_list_channels

List channels in a Discord server.
result = discord_list_channels(
    guild_id="123456789",
    text_only=True
)

for channel in result["channels"]:
    print(f"#{channel['name']} ({channel['type']})")

discord_list_guilds

List Discord servers the bot is in.
result = discord_list_guilds()

for guild in result["guilds"]:
    print(f"{guild['name']} (ID: {guild['id']})")

Configuration

Environment Variables
export DISCORD_BOT_TOKEN=your-bot-token
Get token from:
  1. Create app at discord.com/developers/applications
  2. Go to Bot section
  3. Copy token
  4. Invite bot to server with appropriate permissions

Telegram

telegram_send_message

Send a message via Telegram Bot API.
result = telegram_send_message(
    chat_id="123456789",
    text="Hello from the agent!",
    parse_mode="Markdown"
)

telegram_send_document

Send a document file.
result = telegram_send_document(
    chat_id="123456789",
    document=file_path,
    caption="Here's the report"
)

Configuration

export TELEGRAM_BOT_TOKEN=your-bot-token
Create bot with @BotFather on Telegram.

Best Practices

All communication platforms have rate limits:
  • Gmail: 100 emails/day (free), quota varies
  • Slack: Tier-based limits, use batch operations
  • Discord: 5 requests/second per channel
Implement exponential backoff:
result = slack_send_message(...)
if "error" in result and "rate limit" in result["error"].lower():
    time.sleep(retry_after)
Each platform has different markdown support:
  • Slack: mrkdwn syntax
  • Discord: Standard markdown
  • Gmail: HTML or plain text
  • Telegram: Markdown or HTML
Use batch operations when available:
# Efficient: Batch modify
gmail_batch_modify_messages(
    message_ids=["id1", "id2", "id3"],
    add_labels=["STARRED"]
)

# Inefficient: Loop
for msg_id in message_ids:
    gmail_modify_message(msg_id, add_labels=["STARRED"])
Always handle network and auth errors:
result = send_email(...)
if "error" in result:
    if "auth" in result["error"].lower():
        # Re-authenticate
    elif "timeout" in result["error"].lower():
        # Retry
    else:
        # Log and alert

Next Steps

Productivity Tools

Calendars and CRM systems

Cloud APIs

Google services and GitHub

Build docs developers (and LLMs) love