Multi-Agent Collaboration via Telegram Group Topics
Preface
Previously we implemented using multi-Agent agents in a Telegram group (1)
In the previous post we implemented sending Telegram messages and reading Telegram messages (2)
So I thought, what if in a Telegram group, we use Telegram messages to pass information between different Agents, achieving a multi-Agent collaboration approach?
Approach
We need a tgbot (apply from @botfather) to implement solution (1),
We need a userbot (apply for api_id, api_hash from my.telegram.org) to implement solution (2).
We need a Telegram account that is controlled by this userbot.
Combined with the multi-Agent team collaboration approach we have experimented with, the final solution is as follows:
Deploy Openclaw
Complete the installation of Openclaw
Complete the openclaw onboard deployment
During the deployment process, set the model and the telegram bot token
The above process is omitted.
Openclaw learns the telethon skill
Refer to this previous tutorial this article omits it
Set up the Telegram group
Create a new Telegram group,
Turn on the topic feature.
Add your Telegram bot to the group,
Set your Telegram bot as a group admin.
The above process is omitted.
Query some ID data
Search for @getidsbot (userid 186675376) bot
Send /start to know the userid of your own account
6607181826
Add @getidsbot (userid 186675376) to your group, then you can know the group id
-1003548837972
Create topics and agents and bind message routing
In openclaw tui or webui, send the following instructions in natural language
(The blue parts are up to you)
Please establish the binding relationship between different topics in a telegram group and different agents in the openclaw system you are in
The information you need is as follows:
telegram group id = -1003548837972
The topic feature has been turned on in this group
You are already an admin of this group, and you have the permission to manage topics
There is a user in this group with userid = 6607181826
The work you need to do is as follows:
1.a Create a new topic in the telegram group, name = topic-watch
1.b Create a new agent in the openclaw system, name = agent-watch
Note that this is a new agent, the current agent main must be kept1.c Establish the binding relationship between the topic in 1.a and the agent in 1.b
In the same way, establish topics and agents and binding relationships for design, code, test
Finally
Set the permission for user 6607181826 to use commands like /new
Set that this user does not need to @ tgbot to speak in this telegram group and its topics
Wait for a while, openclaw will complete it.
Refer to the previous tutorial, check the completed effect.
Form the agents into a working team
In openclaw tui or webui, send the following instructions in natural language
(The blue parts are up to you, the green parts should correspond to the previous step)
Form an agent collaboration team, using the existing multiple agents.
Note that these agents already exist, do not create new agents.
Set up the agents' configuration files, and the collaboration relationship between the agents
In order for agents to check the task progress, note to modify the parameters of the openclaw.json file
tools.sessions.visibility = all
The agents that make up the team are:
agent-watch, agent-design, agent-code, agent-test
Note, this does not include the current agent main
Agent No. 1
Name = agent-watch
Identity = You are the task dispatcher, assign tasks to each agent in the team, and track the task progress of each agent
When you receive a "new task", send it immediately to agent-design for analysis, and break the overall task down into small tasks. Note that you should not analyze it yourself.
Then assign the decomposed small tasks to the appropriate agents for execution.
Maintain a `taskname.md` file, recording the task list and completion progress
When an agent in the team asks a question, you forward the question to agent-design for thinking, and then forward the answer to the agent that asked the question. Note that you only pass information, do not modify the information.
Knowledge = Know the full information (including identity and knowledge) of other agents in the team
Know the sessions of other agents in the team, and can read them directly
Agent No. 2
Name = agent-design
Identity = Receive tasks from other agents, notify the task initiator upon completion, and submit results
Specifically, you are the designer, analystYou break down large tasks into small tasks suitable for execution by members of this team.
You do not ask users for supplementary information, always give the optimal solution in the current state, find ways to push the task forward
You do not ask users for supplementary information, always give the optimal solution in the current state, find ways to push the task forward
Knowledge = The results after the task is completed need to be saved in a non-workspace directory before being delivered
Know the full information (including identity and knowledge) of other agents in the team
Know the sessions of other agents in the team, and can read them directly
Agent No. 3
Name = agent-code
Identity = Receive tasks from other agents, notify the task initiator upon completion, and submit results
Specifically, you are a programmer
Knowledge = The results after the task is completed need to be saved in a non-workspace directory before being delivered
Agent No. 4
Name = agent-test
Identity = Receive tasks from other agents, notify the task initiator upon completion, and submit results
Specifically, you are a tester, accept the test object and test standards, and deliver the test report
Knowledge = The results after the task is completed need to be saved in a non-workspace directory before being delivered
Public knowledge:
The agents in this team are all existing agents, and have been configured to work based on telegram group topics, so do not use sessions_spawn, do not use sessions_send.
The agents in this team can query the telegram group id and the id of their corresponding topic from the openclaw.json file
The agents in this team use the telethon-session skill to send messages to each other
The receiving agent actively reports by itself, and the sending agent can check regularly.
The format of messages sent between agents includes:
FROM:
TO:
CONTENT:
For example
FROM: agent-watch
TO: agent-design
CONTENT:
Overall task: Develop a page that generates random passwords
Core function reference: https://crazypeace.github.io/xkcd-password-generator/
Visual style reference: https://onojyun.com/
Please perform task decomposition, and output a list of subtasks that can be directly assigned to agent-code / agent-test.
Try a development task
New task: Develop a page that generates random passwords
Core function reference: https://crazypeace.github.io/xkcd-password-generator/
Visual style reference: https://onojyun.com/
========
Postscript
The process of this tutorial is relatively long. To be honest, whether each step is successful depends on whether the prompt is written well, and also on the intelligence level of the model you use.
So I suggest that after each major step is completed and verified, package and back up the .openclaw directory.
In case the new operation is unsuccessful, you can restore from the previous package, and then find ways to improve the prompt (for example, you let IT learn the relevant documents as context before sending instructions. For example, you /reset to clear the context, and then send instructions. For example, you add some precautions or adjust the order to emphasize certain content in the original prompt) or use a different model.
There are also situations where most of the work is completed, but there are small problems, you can continue to correct through dialogue on this basis. (Those who are familiar with the code can also modify openclaw by themselves, sometimes it is just that individual configuration items or directory names do not meet the requirements)
Package and back up
cd ~ && tar czf openclaw-"$(date +"%Y-%m-%d-%H-%M-%S")".tar.gz --exclude='*.log' --exclude='cache' --exclude='node_modules/.cache' .openclaw
Unpack and restore
rm -rf ~/.openclaw && tar xzf ~/filename -C ~/
Then restart the gateway
openclaw gateway restart
If your practice does not work well, you can refer to my Agent configuration files.
To be honest, these configuration files were also manually fine-tuned by me.
From my experiment video this time, you can see that it was not very smooth, there were many stuck points, requiring manual assistance. However, these manual operations do not require thinking. The "intelligent" work of AI has been completed.
Some of the stuck points I think are caused by the unstable token supply provided by the free public welfare station, and there may also be the issue of the model's "intelligence" level. Moreover, if you want to further optimize, it can be achieved through the scheduled task of agent-watch to continuously push forward.
In terms of the multi-Agent collaboration process, some Agents' behaviors are problematic, but in fact the descriptions I wrote in the Agents' .md files are the same.
Another point, as can be seen from the video, the advantage of using telegram as the inter-agent communication framework is that users can easily observe, monitor, and repair.
This experiment is based on a DediRock 2G memory VPS
========