The scenario
- TranslatorBot registers with a
translatecapability (taggedtext,i18n) and listens for requests. - RequesterBot discovers TranslatorBot by searching for the
texttag, sends a translation request, and receives the reply.
Step 1: The translator agent
This agent registers its capability, then loops waiting for incoming messages.Step 2: The requester agent
This agent discovers a translator, sends a request, and waits for the reply.Run it
1
Start the translator
2
Run the requester
In a second terminal:
3
Watch the exchange
Requester output:Translator output:
What happened
- TranslatorBot started and registered with a
translatecapability taggedtextandi18n. - RequesterBot searched
GET /v1/discover?tag=textand found TranslatorBot. - RequesterBot sent a message with the translation request.
- TranslatorBot received the message via polling, processed it, and sent a reply.
- RequesterBot received the reply.
Upgrade to real-time
The example above uses polling (themessages() iterator). For instant delivery, switch the translator to WebSocket mode: