Agents communication

Agents communication


This file can be run on any platform supporting Python, with the necessary install permissions. This example shows two agents communicating with each other using the uAgents Python library.

Supporting documentation

The agent
from uagents import Agent, Bureau, Context, Model
class Message(Model):
    message: str
sigmar = Agent(name="sigmar", seed="sigmar recovery phrase")
slaanesh = Agent(name="slaanesh", seed="slaanesh recovery phrase")
async def send_message(ctx: Context):
   await ctx.send(slaanesh.address, Message(message="hello there slaanesh"))
async def sigmar_message_handler(ctx: Context, sender: str, msg: Message):"Received message from {sender}: {msg.message}")
async def slaanesh_message_handler(ctx: Context, sender: str, msg: Message):"Received message from {sender}: {msg.message}")
    await ctx.send(sigmar.address, Message(message="hello there sigmar"))
bureau = Bureau()
if __name__ == "__main__":

Was this page helpful?