DiscordSendTool
and DiscordRetrieveTool
are easy to add.
If you haven’t had a chance to read about how AG2’s Communication Platform agents and tools work, read the overview first.
Installation
Install AG2 with the LLM model provider and Discord platform extra.Capabilities
DiscordSendTool
can:
- Construct and send a message to the configured channel. If a message is longer than the platforms permitted message length, they will split the message into multiple messages.
DiscordRetrieveTool
can:
- Retrieve the latest X messages from a channel.
- Retrieve messages since a given date.
- Retrieve messages since a given message ID.
- Retrieve a message given its ID.
Consider
DiscordAgent
if you don’t want to build your agent with these tools, it is a ready-to-go AG2 agent that already incorporates the tools and messaging instructions.Platform configuration
Each tool is configured for a specific channel. This configuration is applied when you create the tool. The tools require authentication (bot token), server (guild name), and channel details in order to send/retrieve messages. Here are some references to help you establish those details:- Creating a Bot Account, and another reference
- Adding a Bot to a server
- Bot Permissions you will need:
- General Permissions: View Channels
- Text Permissions: Send Messages, Read Message History, Use Slash Commands
- Server/Guild Name - Right-click the Server > Server Settings > Overview, see the Server Name at the top right (e.g. “My Test Server”)
- Channel name - The text after the hash (e.g. “general”)
Code example
