xAgent · Developers
Live data for your agent
Let your agent know what's happening before anyone asks: the temperature in the living room, today's appointments, whether the front door is locked. You give xConsole the address of a small web service; at the start of each conversation XIOT reads it and adds what it returns to what the agent knows.
Live data is read once, when a conversation starts. If the agent should fetch or change something while you talk, use your own tools (MCP) instead, or both.
What XIOT sends
- A
GETrequest to your address, from XIOT's servers, so it must be reachable from the internet (use HTTPS). - A
device-idheader with the xAgent's MAC address, so you can answer each device differently. - Any headers you add in xConsole, such as
Authorization.
Your service must answer within 3 seconds. A slow or failed answer is skipped and the conversation goes on without it.
What to answer
JSON with "code": 0 and your information in data: named values, a list, or a single text.
{
"code": 0,
"data": {
"Living room temperature": "24 °C",
"Front door": "Locked",
"Next appointment": "Dentist at 17:30"
}
}
The agent then knows:
- Living room temperature: 24 °C
- Front door: Locked
- Next appointment: Dentist at 17:30
A list works the same way, one line each:
{ "code": 0, "data": ["You have 3 tasks due today", "Mariam's school closes early on Thursday"] }
Any other code means “nothing this time” and is skipped.
Add it in xConsole
- Open Agents → Configure agent → Tools tab.
- In Context, press Edit source, then Add.
- Enter your address, and a header such as
Authorization: Bearer your-secretif your service needs one. - Confirm, then Save configuration. The next conversation uses it.
You can add several addresses; their lines are combined.
A small example service
Python's standard library is enough. Put it behind HTTPS (for example a reverse proxy or a tunnel) before adding it to xConsole.
import json
from http.server import BaseHTTPRequestHandler, HTTPServer
SECRET = "Bearer change-me" # the same value as the header in xConsole
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
if self.headers.get("Authorization") != SECRET:
self.send_response(401)
self.end_headers()
return
device = self.headers.get("device-id", "") # which xAgent is asking
body = {"code": 0, "data": {
"Living room temperature": "24 °C", # replace with your sensors or systems
"Front door": "Locked",
}}
data = json.dumps(body).encode()
self.send_response(200)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(data)))
self.end_headers()
self.wfile.write(data)
HTTPServer(("0.0.0.0", 8080), Handler).serve_forever()
Tips
- Keep it short. It is part of every conversation: a few lines that matter beat a full report, and shorter means faster replies.
- Name things the way people say them. “Front door: Locked” is easier for the agent to use than “door_1: 0”.
- Protect it. Use HTTPS and a secret header, and check it in your service.
- Don't send secrets. What you return is given to the AI model with the agent's instructions.