Hum is a private messaging platform where users communicate with AI agents through an iOS app. To connect your agent, you implement a single webhook endpoint. When a user messages your agent, Hum calls your endpoint and delivers your reply — just like a Telegram bot.
In the Hum iOS app: Agents → + → enter name, handle, and webhook URL → Create
Hum will POST messages to your webhook URL. Return a reply.
Python:
from fastapi import FastAPI, HTTPException, Request
import hashlib, hmac, json
app = FastAPI()
WEBHOOK_SECRET = "your-secret" # The secret you set when configuring the agent
@app.post("/hum/webhook")
async def handle(request: Request):
raw = await request.body()
# Check the signature over the raw bytes, and refuse a request without one.
expected = "sha256=" + hmac.new(WEBHOOK_SECRET.encode(), raw, hashlib.sha256).hexdigest()
received = request.headers.get("x-hum-signature", "")
if not hmac.compare_digest(received.encode(), expected.encode()):
raise HTTPException(status_code=401)
body = json.loads(raw)
user_message = body["source_message"]["text"]
# Your agent logic here
reply = f"You said: {user_message}"
return {"reply_text": reply}
Node.js:
const express = require('express');
const crypto = require('crypto');
const app = express();
// Keep the raw bytes: the signature covers exactly what Hum sent.
app.use(express.raw({ type: 'application/json', limit: '1mb' }));
const WEBHOOK_SECRET = 'your-secret';
app.post('/hum/webhook', (req, res) => {
const expected = Buffer.from('sha256=' + crypto
.createHmac('sha256', WEBHOOK_SECRET)
.update(req.body)
.digest('hex'));
const received = Buffer.from(req.headers['x-hum-signature'] || '');
if (received.length !== expected.length || !crypto.timingSafeEqual(received, expected)) {
return res.status(401).send('Unauthorized');
}
const body = JSON.parse(req.body);
const userMessage = body.source_message?.text || '';
res.json({ reply_text: `You said: ${userMessage}` });
});
app.listen(8443);
Send a message from the iOS app. Your agent receives it and replies.
Hum sends to your endpoint:
{
"work_item": {
"id": "uuid",
"owner_user_id": "uuid",
"agent_id": "uuid",
"conversation_id": "uuid",
"source_message_id": "uuid",
"idempotency_key": "string",
"payload": {}
},
"source_message": {
"id": "uuid",
"conversation_id": "uuid",
"owner_user_id": "uuid",
"agent_id": "uuid",
"origin": "UserClient",
"message_kind": "Text",
"text": "The user's message",
"created_at_utc": "2026-03-22T12:00:00+00:00"
},
"recent_messages": [
{
"id": "uuid",
"conversation_id": "uuid",
"owner_user_id": "uuid",
"agent_id": "uuid",
"origin": "UserClient | AgentMcp",
"message_kind": "Text | Action | System",
"text": "message text",
"created_at_utc": "2026-03-22T12:00:00+00:00"
}
]
}
You return:
{
"reply_text": "Your agent's response"
}
| Field | Description |
|---|---|
source_message.text |
The user's message — respond to this |
recent_messages |
Last ~10 messages for conversation context |
work_item.conversation_id |
Stable ID for this conversation (use for state tracking) |
work_item.idempotency_key |
Deduplicate — same key means same request, return same response |
source_message.origin |
UserClient = from the iOS app, AgentMcp = from another agent |
Use recent_messages to give your agent conversation memory:
history = []
for msg in body["recent_messages"]:
role = "user" if msg["origin"] == "UserClient" else "assistant"
history.append({"role": role, "content": msg["text"]})
history.append({"role": "user", "content": body["source_message"]["text"]})
# Pass to your LLM
response = await your_llm.complete(messages=history)
return {"reply_text": response}
When you configure a webhook_secret on your agent, every request includes:
X-Hum-Signature: sha256=<HMAC-SHA256 of the request body using your secret>
X-N8MSG-Signature: sha256=<the same value>
X-Hum-Signature is the current name. X-N8MSG-Signature is the former name and is still sent with the
same value, so an agent that already verifies it keeps working; new agents should verify X-Hum-Signature.
Always verify this in production to ensure requests come from Hum.
Your webhook endpoint must use HTTPS in production. http://localhost is allowed for development.
Each agent has API keys for authentication. Keys are shown once at issuance and stored hashed. You can view existing keys (label, date, status, preview) and issue new ones from the agent detail screen.
Webhook delivery is best-effort: Hum makes one attempt per message, in the background, right after the message is stored. There is no retry on the webhook path. The message's work item is settled from that one attempt, so the owner's app shows an honest state:
| Your response | What happens |
|---|---|
HTTP 200 + {"reply_text": "..."} |
Reply delivered to user; work item Completed, message state answered |
HTTP 200 with no reply_text |
Nothing is sent; work item Completed (you answered with silence) |
| HTTP 4xx or 5xx, timeout, or endpoint down | Work item Failed with the reason; message state failed. The message is not retried |
If your agent needs at-least-once delivery with retries and lease renewal,
use the polling connector (or poll the
work-queue API yourself): that path keeps the message in the queue and
retries it on the schedule immediate → 5 seconds → 30 seconds → Failed
after four attempts. Polling is the supported path for anything that must
not be lost.
| Type | Description |
|---|---|
Text |
Normal user message. Respond with text. |
Action |
Structured task. Has action field with type, version, payload, status. |
System |
System notification. Usually ignore. |
_bot, _ai, or _agentTwo agents under the same owner can message each other, but only after the
owner connects them:
in the app, open one of your agents and tap Connect to another agent.
Only agents you own are offered. Until then send-to-agent and the peer
lookup answer 403 agents are not connected; closing the connection has
the same effect while the history stays readable.
GET /api/v1/agent/connections lists the peers this agent may address.GET /api/v1/agent/messages/conversations/peer/{peer_agent_id} returns
the pair's conversation_id.POST /api/v1/agent/messages/send-to-agent sends into it; hop_count
starts at 1 and each reply adds one (10 hops end the chain).agent_conversation_id
set and conversation_id null. The webhook payload, the polling
connector, msg listen, the SDK work loop and the MCP server all
deliver it; your reply is sent back to the peer automatically with the
next hop count and the same root_message_id.The repo ships a command-line client, msg, that turns any script or queue
into an agent — no webhook, no endpoint, no code against the raw HTTP API.
The command-line client and the connector are installed from Hum's source repository, which is private. Ask support@n8msg.ai for access.
git clone https://github.com/Hiventiq/hum.git
cd hum
pip install -e .
export MSG_BASE_URL="https://www.n8msg.ai"
export HUM_AGENT_API_KEY="<your agent's API key>" # issued in the iOS app; legacy N8MSG_AGENT_API_KEY still works
msg validate
# ok: agent @my_agent_bot (3f2a…) status=active
# Notify the user from a script / CI pipeline — one line:
msg send <conversation_id> --text "Build 412 deployed"
# Read the conversation (oldest first), or tail it live:
msg messages <conversation_id>
msg messages <conversation_id> --follow
listen)msg listen --exec "python my_agent.py"
Each incoming message is piped to your command's stdin as JSON (same shape as the webhook payload); whatever it prints to stdout is sent back as the reply. Exit 0 completes the work item, nonzero fails it (and the queue retries).
# my_agent.py — a complete agent
import json, sys
payload = json.load(sys.stdin)
text = (payload.get("source_message") or {}).get("text") or ""
print(f"You said: {text}")
Manual work-queue control is also available: msg work lease [--wait],
msg work complete <id>, msg work fail <id> --error "...".
Python scripts can skip the CLI and use the SDK directly
(from msg_client import MsgAgentClient).
If your agent runs behind a firewall or on localhost and can't receive inbound HTTP requests, use the polling connector instead of a webhook. The connector runs on your machine, reaches out to Hum over HTTPS, picks up messages, and forwards them to your local endpoint.
git clone https://github.com/Hiventiq/hum.git
cd hum
pip install -e .
export MSG_BASE_URL="https://www.n8msg.ai"
export HUM_AGENT_API_KEY="<your agent's API key>" # legacy N8MSG_AGENT_API_KEY still works
export MSG_AGENT_RESPONDER_BACKEND=http
export MSG_AGENT_RUNTIME_BASE_URL="http://localhost:8443"
export MSG_AGENT_RUNTIME_BEARER_TOKEN="a-shared-secret"
python3 -m msg.agent_connector
The connector polls Hum every 5 seconds for new messages, forwards them to your local endpoint at MSG_AGENT_RUNTIME_BASE_URL, and sends replies back to Hum.
Your local endpoint receives the same payload format as the webhook and returns {"reply_text": "..."}.
A polling worker holds a lease on each work item it takes. If the lease runs out before the worker completes or fails the item, the queue takes the item back and hands it out again.
MSG_WORK_ITEM_LEASE_SECONDS on the server (default 300
seconds). POST /agent/runtime/validate returns it as lease_seconds.Failed. A worker that never renews can therefore hold an item for at most
4 x the lease length (20 minutes at the default) before it fails for good.
A crashed worker's item waits one lease length before another delivery.POST /agent/work/{id}/complete, /fail and /renew answer 404 unless
the caller still holds the lease. A 404 on complete means the lease was
lost: stop and do not send a reply.POST /agent/work/{id}/renew
(path in renew_path_template from validate) about every half lease.
Every renewal gives a fresh full lease. The shipped polling connector, the
msg SDK (work_loop, keep_lease_alive), msg work renew and the
n8msg_renew_work MCP tool do this or let you do it; a worker you write
yourself must.<work_item_key>:reply, however many times the item is delivered. A second
delivery that sends a different reply is refused with 409 idempotency key reuse; treat that as "already replied" and complete the item. Do not run two
pollers on one agent key unless both renew.| Webhook | Polling Connector | |
|---|---|---|
| Your agent has a public HTTPS URL | Yes | No |
| Your agent runs on localhost | No | Yes |
| Your agent is behind a firewall | No | Yes |
| Setup complexity | Just build an endpoint | Install connector + run process |
| Latency | Instant | Up to 5 seconds |
| Reliability | Best-effort, one attempt, no retry | At-least-once: lease, renew, retry up to 4 attempts |