Discord Plugin
Introduction
Crypto.com AI Agent SDK Discord plugin allows users to create interactive blockchain experiences within Discord communities. By setting up a custom bot, users can interact with the Cronos network using natural language to access wallet data, track transactions, and execute commands directly in server channels.
This guide provides step-by-step instructions to get your Discord bot up and running in no time.
A video demo is available in the Crypto.com AI Agent SDK X post.

Prerequisites
Crypto.com AI Agent SDK installed.
Python installed (version >= 3.12)
API Key for Cronos EVM Blockchain Explorer or Cronos zkEVM Blockchain Explorer
API Keys of AI provider, refer to the Dynamic AI Model Manager to see which providers are supported by the AI Agent SDK.
Required account: Discord Bot Token.
Get a Discord Bot Token
Open your browser and navigate to the Discord Developer Portal.
Click on "New Application", enter a name for your bot (e.g., CryptoHelper), and click "Create".
In the left sidebar, select "Bot", then click "Add Bot" and confirm by clicking "Yes, do it!"
Under the "Token" section, click "Click to Reveal Token" to view your bot's token.
Copy and securely store this token (e.g.,
MTM3Mjc0MjI3MzUzNTcwNTE5MA.GHuA_M.dSXMKfwfXxd1kWZ8fBPLvB7EwuWcM6StENS43g
). Never share this token publicly, as it grants control over your bot
Invite the Bot to Your Server
In the Developer Portal, navigate to the "OAuth2" section and select "URL Generator".
Under "Scopes", check the boxes for "bot" and "applications.commands".
Under "Bot Permissions", select the permissions your bot needs (e.g., "Send Messages", "Read Message History").
Copy the generated URL at the bottom of the page.
Paste the URL into your browser, select the server you want to add the bot to, and click "Continue".
Review the permissions and click "Authorize".
Complete any CAPTCHA verification if prompted.
Discord Plugin
Add Discord plugin when initializing the Agent:
import os
from crypto_com_agent_client import Agent
from dotenv import load_dotenv
load_dotenv()
# Initialize the agent with LLM and blockchain configurations
# Current chainID refers to Cronos zkEVM Testnet, optionally change it to other Cronos networks
agent = Agent.init(
llm_config={
"provider": "OpenAI",
"model": "gpt-4o-mini",
"provider-api-key": os.getenv("OPENAI_API_KEY"),
"temperature": "float-controlling-output-randomness",
},
blockchain_config={
"chainId": "240",
"explorer-api-key": os.getenv("EXPLORER_API_KEY"),
"private-key": os.getenv("PRIVATE_KEY"),
"sso-wallet-url": "your-sso-wallet-url",
},
plugins={
"instructions": "You are a humorous assistant that always includes a joke in your responses.",
"discord": {"bot_token": os.getenv("DISCORD_BOT_TOKEN")},
},
)
agent.start_discord()
Run everything
As shown in the example code, we start the Discord bot by invoking the Agent's built-in function:
agent.start_discord()
Once the bot is running, test it to ensure it’s working as expected:
Ensure your bot is running and connected to Discord.
Open Discord and navigate to the server where you've added your bot.
Interact with the bot and observe if it responds appropriately to confirm it's functioning correctly.
Troubleshooting
If you encounter issues during setup or execution, follow these tips:
Check your API keys to ensure they are correctly set in the environment variables.
Review Discord Bot API limitations to ensure compliance with rate limits and usage guidelines.
Last updated
Was this helpful?