ツールキットはエージェントに追加できる関数のコレクションです。
ここでは、SNS 対応ツール Discord, Email, Gmail, Slack, X (Twitter) 等の使い方を説明します。
Agno : ユーザガイド : コンセプト : ツール – ツールキット : SNS (Discord, Email, Gmail, Slack, X 等)
作成 : クラスキャット・セールスインフォメーション
作成日時 : 08/02/2025
バージョン : Agno 1.7.5
* 本記事は docs.agno.com の以下のページを独自に翻訳した上で、補足説明を加えてまとめ直しています :
- User Guide : Concepts : Tools – Toolkits : Social : Discord
- User Guide : Concepts : Tools – Toolkits : Social : Email
- User Guide : Concepts : Tools – Toolkits : Social : Gmail
- User Guide : Concepts : Tools – Toolkits : Social : Slack
- User Guide : Concepts : Tools – Toolkits : Social : X (Twitter)
* サンプルコードの動作確認はしておりますが、必要な場合には適宜、追加改変しています。
* ご自由にリンクを張って頂いてかまいませんが、sales-info@classcat.com までご一報いただけると嬉しいです。
Agno ユーザガイド : コンセプト : ツール – ツールキット : SNS : Discord
DiscordTools はエージェントが、Discord でメッセージを送信し、メッセージ履歴を読み、チャネルを管理し、そしてメッセージを削除することを可能にします。
前提条件
後述の例は、ここ で取得できる Discord ボット・トークンが必要です。
export DISCORD_BOT_TOKEN=***
例
cookbook/tools/discord.py
from agno.agent import Agent
from agno.tools.discord import DiscordTools
agent = Agent(
tools=[DiscordTools()],
show_tool_calls=True,
markdown=True,
)
agent.print_response("Send 'Hello World!' to channel 1234567890", markdown=True)
Agno ユーザガイド : コンセプト : ツール – ツールキット : SNS : Email
EmailTools はエージェントが電子メールをユーザに送信することを可能にします。エージェントは、指定した subject と body でユーザにメールを送信できます。
例
cookbook/tools/email_tools.py
from agno.agent import Agent
from agno.tools.email import EmailTools
receiver_email = ""
sender_email = ""
sender_name = ""
sender_passkey = ""
agent = Agent(
tools=[
EmailTools(
receiver_email=receiver_email,
sender_email=sender_email,
sender_name=sender_name,
sender_passkey=sender_passkey,
)
]
)
agent.print_response("send an email to ")
Agno ユーザガイド : コンセプト : ツール – ツールキット : SNS : Gmail
Gmail はエージェントが Gmail とやり取りし、電子メールの読み取り、検索、送信、そして管理を可能にします。
前提条件
Gmail ツールキットは Google API クライアント・ライブラリと適切な認証セットアップを必要とします。必要な依存関係をインストールしてください :
pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib
Google Cloud クレデンシャル (認証情報) のセットアップも必要です :
- Google Cloud コンソール にアクセスします。
- プロジェクトを作成するか、既存のプロジェクトを選択します。
- Gmail API を有効にします。
- OAuth 2.0 クレデンシャルを作成します。
- 環境変数をセットアップします :
export GOOGLE_CLIENT_ID=your_client_id_here export GOOGLE_CLIENT_SECRET=your_client_secret_here export GOOGLE_PROJECT_ID=your_project_id_here export GOOGLE_REDIRECT_URI=http://localhost # Default value
例
cookbook/tools/gmail_tools.py
from agno.agent import Agent
from agno.tools.gmail import GmailTools
agent = Agent(tools=[GmailTools()], show_tool_calls=True)
agent.print_response("Show me my latest 5 unread emails", markdown=True)
Agno ユーザガイド : コンセプト : ツール – ツールキット : SNS : Slack
前提条件
後述の例は slack-sdk ライブラリを必要とします。
pip install openai slack-sdk
Slack トークンを ここ から取得します。
export SLACK_TOKEN=***
例
次のエージェントは、Slack を使用してメッセージをチャネルに送信し、すべてのチャネルを一覧表示し、そして特定のチャネルのメッセージ履歴を取得できます。
cookbook/tools/slack_tools.py
import os
from agno.agent import Agent
from agno.tools.slack import SlackTools
slack_tools = SlackTools()
agent = Agent(tools=[slack_tools], show_tool_calls=True)
# Example 1: Send a message to a Slack channel
agent.print_response("Send a message 'Hello from Agno!' to the channel #general", markdown=True)
# Example 2: List all channels in the Slack workspace
agent.print_response("List all channels in our Slack workspace", markdown=True)
# Example 3: Get the message history of a specific channel by channel ID
agent.print_response("Get the last 10 messages from the channel 1231241", markdown=True)
Agno ユーザガイド : コンセプト : ツール – ツールキット : SNS : X (Twitter)
XTools はエージェントが X とやり取りして、ツイートの投稿、メッセージ送信、検索の機能を提供できるようにします。
前提条件
必要なライブラリをインストールします :
pip install tweepy
セットアップ
- X 開発者アカウントを作成します。
- developer.x.com にアクセスして開発者アクセスを申請します。
- 開発者ポータルで新しいプロジェクトとアプリケーションを作成します。
- API クレデンシャルを作成します。
- アプリケーションの “Keys and tokens” セクションに移動します。
- これらのクレデンシャルを生成してコピーします :
- API キー & Secret
- Bearer トークン
- アクセストークン & Secret
- 環境を設定します。
export X_CONSUMER_KEY=your_api_key export X_CONSUMER_SECRET=your_api_secret export X_ACCESS_TOKEN=your_access_token export X_ACCESS_TOKEN_SECRET=your_access_token_secret export X_BEARER_TOKEN=your_bearer_token
例
from agno.agent import Agent
from agno.tools.x import XTools
# Initialize the X toolkit
x_tools = XTools(
wait_on_rate_limit=True # Retry when rate limits are reached
)
# Create an agent equipped with X toolkit
agent = Agent(
instructions=[
"Use X tools to interact as the authorized user",
"Generate appropriate content when asked to create posts",
"Only post content when explicitly instructed",
"Respect X's usage policies and rate limits",
],
tools=[x_tools],
show_tool_calls=True,
)
# Search for posts
agent.print_response("Search for recent posts about AI agents", markdown=True)
# Create and post a tweet
agent.print_response("Create a post about AI ethics", markdown=True)
# Get user timeline
agent.print_response("Get my timeline", markdown=True)
# Reply to a post
agent.print_response(
"Can you reply to this [post ID] post as a general message as to how great this project is: https://x.com/AgnoAgi",
markdown=True,
)
# Get information about a user
agent.print_response("Can you retrieve information about this user https://x.com/AgnoAgi ", markdown=True)
# Send a direct message
agent.print_response(
"Send direct message to the user @AgnoAgi telling them I want to learn more about them and a link to their community.",
markdown=True,
)
# Get user profile
agent.print_response("Get my X profile", markdown=True)
以上