
Welcome DiscordAgent, SlackAgent, and TelegramAgent
We want to help you focus on building workflows and enhancing agents, so we’re building reference agents to get you going quicker. Say hello to three new AG2 communication agents -DiscordAgent
, SlackAgent
, and TelegramAgent
, here so that you can use an agentic application to send and retrieve messages from messaging platforms.
New agents need new tools
Underpinning these new agents are AG2 tools for sending and retrieving messages. Why is it important that these are tools? Simple, you can add the tools to your existing agents or build a mega communications agent with all the tools. Additionally, as the agents are tool-based, you can add your tools to these agents to make them even more capable. Here are our three new agents and the pair of new tools that they use (and you can use with your own agents):Agent | Send Tool | Retrieve Tool |
---|---|---|
DiscordAgent | DiscordSendTool | DiscordRetrieveTool |
SlackAgent | SlackSendTool | SlackRetrieveTool |
TelegramAgent | TelegramSendTool | TelegramRetrieveTool |
Capabilities
The send tools all have the same functionality, they take a message and post it to the configured channel/group/bot. If a message is longer than the platforms permitted message length, the tool will split the message into multiple messages. All the retrieve tools can:- Retrieve the latest X messages from a channel/group/bot.
- Retrieve messages since a given date.
- Retrieve messages since a given message ID.
- Retrieve a message given its ID.
Configuration
In this first iteration of the tools, each tool is configured for a specific channel/group/bot. This configuration is applied when you create the tool. Discord, Slack, and Telegram all have their own authentication and channel/group/bot identifiers. See this Notebook for more guidance on establishing those authentication details and identifiers. Here are examples of how to create the tools, passing in the configuration:Agent vs Tools
You could create a ConversableAgent and add the send and retrieve tools and you would almost have the same functionality as the new agents. Apart from the simplicity of creating an agent with the tools already registered, an important component of the new agents is that the platform’s messaging requirements will be appended to their system message. They cover aspects like maximum message length, preferred format (e.g. Markdown), and provide tips like using emojis.Agent | System Message guidance |
---|---|
DiscordAgent | 2,000 character limit, Markdown, bold/italic/code, use emojis |
SlackAgent | 40,000 character limit, Markdown, bold/italic/code, emojis, notification formats |
TelegramAgent | 4,096 character limit, HTML, mentions and emojis |
has_writing_instructions
to False
when creating the agent.
Another important consideration is the execution of these tools. In AG2 the tool execution is typically handled by a separate agent that will follow the agent in the conversation (unless its an agent in a swarm whereby tools are executed automatically). So, you will need to register the tools with another agent for execution. See the demo below for how to do this.
Installation
Each messaging platform requires installation of a package specifically for that platform. To use the Discord agent or tools install AG2 with thecommsagent-discord
extra:
Demo
Here’s a quick example of how to use the new agents and tools. If you’re after more examples, see this Notebook. In this demo we have a Slack channel where AG2 bugs are noted. Those bugs need to go to a Discord channel for them to be raised as a ticket and also to Telegram to inform the community about it. Finally, we should send a message back to Slack to say that we’ve actioned the steps. We’ll start with creating an equivalentDiscordAgent
using the tools so you now how to construct your own communication agent. For Slack and Telegram, we’ll use SlackAgent
and TelegramAgent
.
DiscordAgent
using tools.




Feedback
These tools are currently in ourexperimental
namespace, indicating that we have tested the functionality but their interface may change.
We’d love for you to try them but please use them with that in mind. Let us know how you go with them!