Custom tools: the signed tool-call contract
A custom tool lets an assistant use your systems in the middle of a call: find free appointment slots, check an order, open a ticket. You describe the tool, and when the assistant decides it needs it, MoreVoice sends a signed POST to your server and gives your answer to the assistant, which tells the caller.
- The caller asks something only your systems know: “יש תור פנוי ביום חמישי?”.
- The model calls your tool with arguments that match its JSON schema:
{ "date": "2026-11-05" }. If you setrequest_start_message, the assistant says it while it waits. - MoreVoice
POSTs the call to the tool’s URL, signed with your tool signing secret. - Your server checks the signature, does the work and answers with JSON.
- The model reads your answer and phrases the reply to the caller.
Define a tool
Section titled “Define a tool”Tools live on the assistant, in tools.custom. A PATCH replaces the whole list, so send every tool the assistant should keep:
# Give the assistant a tool. `tools.custom` replaces the assistant's whole list of custom tools.curl -X PATCH https://api.morevoice.ai/v1/assistants/$ASSISTANT_ID \ -H "Authorization: Bearer $MOREVOICE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "tools": { "custom": [ { "name": "find_slots", "description": "Find free appointment slots for a doctor on a date. Call it before offering any time.", "parameters": { "type": "object", "properties": { "doctor": { "type": "string", "description": "The doctor'"'"'s family name, if the caller named one" }, "date": { "type": "string", "description": "The date, YYYY-MM-DD" } }, "required": ["date"] }, "url": "https://clinic.example.com/morevoice/tools", "headers": { "Authorization": "Bearer '"$CLINIC_API_TOKEN"'" }, "timeout_seconds": 10 } ] } }'import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // reads MOREVOICE_API_KEY
// Give the assistant a tool. `tools.custom` replaces the assistant's whole list of custom tools.await mv.assistants.update(process.env.ASSISTANT_ID!, { tools: { custom: [ { name: "find_slots", description: "Find free appointment slots for a doctor on a date. Call it before offering any time.", parameters: { type: "object", properties: { doctor: { type: "string", description: "The doctor's family name, if the caller named one" }, date: { type: "string", description: "The date, YYYY-MM-DD" }, }, required: ["date"], }, url: "https://clinic.example.com/morevoice/tools", headers: { Authorization: `Bearer ${process.env.CLINIC_API_TOKEN}` }, // stored encrypted, never returned timeout_seconds: 10, }, ], },});import os
import requests
API = "https://api.morevoice.ai/v1"HEADERS = {"Authorization": f"Bearer {os.environ['MOREVOICE_API_KEY']}"}assistant_id = os.environ["ASSISTANT_ID"]
# Give the assistant a tool. `tools.custom` replaces the assistant's whole list of custom tools.response = requests.patch( f"{API}/assistants/{assistant_id}", headers=HEADERS, json={ "tools": { "custom": [ { "name": "find_slots", "description": "Find free appointment slots for a doctor on a date. Call it before offering any time.", "parameters": { "type": "object", "properties": { "doctor": {"type": "string", "description": "The doctor's family name, if the caller named one"}, "date": {"type": "string", "description": "The date, YYYY-MM-DD"}, }, "required": ["date"], }, "url": "https://clinic.example.com/morevoice/tools", # Stored encrypted, never returned. "headers": {"Authorization": f"Bearer {os.environ['CLINIC_API_TOKEN']}"}, "timeout_seconds": 10, } ] } }, timeout=30,)response.raise_for_status()| Field | What it does |
|---|---|
name |
The function name the model calls: letters, digits, _ and -, up to 64, unique per assistant. |
description |
What the tool does and when to use it. The model decides from this, so be specific: “Call it before offering any time.” |
parameters |
A JSON Schema object for the arguments. Give each property a description, and list the ones the model must always send in required. |
url |
Where MoreVoice sends the call (http or https). |
headers |
Extra request headers, such as your own Authorization. They are stored encrypted and never returned: responses list only header_names. Leave headers out of an update to keep the stored ones. |
timeout_seconds |
How long to wait for your answer: 1–60 seconds, 15 by default. |
request_start_message |
A sentence the assistant says while the tool runs, such as “רגע, אני בודקת”. |
type |
webhook (the default when there is a url), or mock, which answers mock_response without any request: handy for working on the instructions before your server exists. |
enabled |
false keeps the tool but stops offering it to the model. |
An assistant can have up to 50 custom tools.
The request your server receives
Section titled “The request your server receives”Content-Type: application/jsonUser-Agent: MoreVoice-Tools/1Authorization: Bearer <the header you stored>webhook-id: tc_5LwTfK2vXq9mR3nB8cY1aDwebhook-timestamp: 1762161262webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4=
{"tool":"find_slots","arguments":{"date":"2026-11-05","doctor":"Levi"},"call":{"id":"9b2f4c1e-…"}}| Part | Meaning |
|---|---|
tool |
The tool’s name. One URL can serve several tools. |
arguments |
What the model filled in, following your parameters schema. Check them: a model can still send something unexpected. |
call.id |
Identifies the call. It is the same for every tool call of one call, so you can group them. |
webhook-id |
Unique to this tool call (tc_…). If you must never act twice, remember the IDs you have handled. |
webhook-timestamp, webhook-signature |
The Standard Webhooks signature. Check it before anything else. |
Your own headers go out with every call, but they can’t replace the three webhook- headers.
Check the signature
Section titled “Check the signature”The signature proves the request comes from MoreVoice and nobody changed it. It is the same scheme as webhooks, with a different secret: the organisation’s tool signing secret (whsec_…). Live mode and test mode each have their own.
- Reject the request if
webhook-timestampis more than 5 minutes from your clock. - Base64-decode the secret without its
whsec_prefix. - Compute HMAC-SHA256 over
<webhook-id>.<webhook-timestamp>.<raw body>and base64-encode it. - Compare it in constant time with each
v1,<signature>inwebhook-signature(separated by spaces). One match is enough.
Read the raw body before you parse it: the signature covers the exact bytes MoreVoice sent. In Node.js, tools.nodeHandler (or tools.handler for Fetch-API runtimes) from @morevoice/sdk does all of this, checks the arguments against the schema and keeps your handler within a time limit. In Python, the standard library is enough. From the command line, the cURL tab sends your server a call signed the same way, so you can test it before MoreVoice calls it:
# Send your tool server a signed test call, signed the way MoreVoice signs it: Standard Webhooks headers over the exact# body, with the tool signing secret of the mode you test. (POST /v1/tools/test sends the same call from MoreVoice.)# MOREVOICE_TOOL_SECRET=whsec_… sh sign-tool-call.sh http://localhost:3000/morevoice/toolsset -euurl="${1:-http://localhost:3000/morevoice/tools}"body='{"tool":"find_slots","arguments":{"date":"2026-11-05"},"call":{"id":"test"}}'msg_id="tc_$(openssl rand -hex 11)"timestamp=$(date +%s)
key=$(printf '%s' "${MOREVOICE_TOOL_SECRET#whsec_}" | openssl base64 -d -A | od -An -v -tx1 | tr -d ' \n')signature=$(printf '%s.%s.%s' "$msg_id" "$timestamp" "$body" | openssl dgst -sha256 -mac HMAC -macopt "hexkey:$key" -binary | openssl base64 -A)
curl -sS "$url" \ -H "Content-Type: application/json" \ -H "webhook-id: $msg_id" \ -H "webhook-timestamp: $timestamp" \ -H "webhook-signature: v1,$signature" \ -d "$body"// A custom tool server on Node's http module. tools.nodeHandler verifies the signature before// your code runs, checks the arguments against the schema and answers in the expected shape.import { createServer } from "node:http";import { defineTool, tools } from "@morevoice/sdk";
const handle = tools.nodeHandler({ secret: process.env.MOREVOICE_TOOL_SECRET!, // whsec_…, the tool signing secret of the key's mode timeoutMs: 8_000, // answer before the tool's timeout_seconds (10) runs out handlers: { find_slots: defineTool({ parameters: { type: "object", properties: { doctor: { type: "string" }, date: { type: "string" } }, required: ["date"], }, async handler({ doctor, date }) { const slots = await freeSlots(date, doctor); // The assistant phrases its answer from this result. return { result: { date, slots: slots.slice(0, 3) } }; }, }), },});
createServer((req, res) => { if (req.method === "POST" && req.url === "/morevoice/tools") return void handle(req, res); res.writeHead(404).end();}).listen(3000);
// Your scheduling system goes here.async function freeSlots(date: string, doctor?: string): Promise<string[]> { return doctor === "Levi" ? [] : [`${date}T09:30`, `${date}T11:00`, `${date}T15:45`];}# A custom tool server with Python's standard library only (Python 3.10+).import base64import hashlibimport hmacimport jsonimport osimport timefrom http.server import BaseHTTPRequestHandler, HTTPServer
TOLERANCE_SEC = 5 * 60
def verify_signature(secret: str, headers, body: bytes, now: int | None = None) -> bool: """True when the request was signed by MoreVoice with `secret` (whsec_…) in the last 5 minutes.""" msg_id = headers.get("webhook-id") timestamp = headers.get("webhook-timestamp") signatures = headers.get("webhook-signature") if not msg_id or not timestamp or not signatures or not timestamp.isdigit(): return False now = int(time.time()) if now is None else now if abs(now - int(timestamp)) > TOLERANCE_SEC: return False key = base64.b64decode(secret.removeprefix("whsec_")) signed = f"{msg_id}.{timestamp}.".encode() + body expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode() # Two signatures while the secret rotates: either one is enough. return any( version == "v1" and hmac.compare_digest(signature, expected) for version, _, signature in (entry.partition(",") for entry in signatures.split(" ")) )
def find_slots(arguments: dict) -> dict: # Your scheduling system goes here. date = arguments["date"] slots = [] if arguments.get("doctor") == "Levi" else [f"{date}T09:30", f"{date}T11:00", f"{date}T15:45"] return {"date": date, "slots": slots[:3]}
TOOLS = {"find_slots": find_slots}
class ToolHandler(BaseHTTPRequestHandler): def do_POST(self): body = self.rfile.read(int(self.headers.get("Content-Length", 0))) if not verify_signature(os.environ["MOREVOICE_TOOL_SECRET"], self.headers, body): return self.answer(401, {"error": {"message": "Bad signature"}}) call = json.loads(body) # {"tool": "find_slots", "arguments": {...}, "call": {"id": "..."}} tool = TOOLS.get(call["tool"]) if tool is None: return self.answer(404, {"error": {"message": f"Unknown tool {call['tool']}"}}) try: # The assistant phrases its answer from this result. return self.answer(200, {"result": tool(call["arguments"])}) except Exception as err: # the assistant can apologise and go on return self.answer(200, {"error": {"message": str(err)}})
def answer(self, status: int, payload: dict): data = json.dumps(payload, ensure_ascii=False).encode() self.send_response(status) self.send_header("Content-Type", "application/json") self.send_header("Content-Length", str(len(data))) self.end_headers() self.wfile.write(data)
if __name__ == "__main__": HTTPServer(("", 3000), ToolHandler).serve_forever()To test your check, run it against the test vector: tool calls are signed the same way.
Answer the call
Section titled “Answer the call”Answer with JSON and status 200 within timeout_seconds. Everything you answer goes to the model as the tool’s result, so answer with the facts it needs and nothing else:
{ "result": { "date": "2026-11-05", "slots": ["2026-11-05T09:30", "2026-11-05T11:00"] } }- Errors. Any other status reaches the model as
{ "error": "HTTP 503", "body": <your body> }. A timeout or a network error reaches it as an error too. Either way the call goes on and the assistant can apologise or offer something else; an{ "error": { "message": "…" } }answer with status200gives it a reason it can explain. - One attempt. A tool call is not retried: the caller is waiting.
- Size. An answer larger than 1 MB fails. Keep answers small: the model reads every word.
- Speed. The caller hears silence (or your
request_start_message) while your server works. Aim for under a second or two.
Which URLs can be called
Section titled “Which URLs can be called”The URL must be reachable from the internet over http or https, on port 80, 443, or any port from 1024 up. Addresses inside a private network (localhost, 10.x, 192.168.x) are refused unless an administrator allows private network addresses for your organisation, and every redirect is checked the same way.
Test a tool
Section titled “Test a tool”POST /v1/tools/test runs a tool once, exactly as a call would: the same body (with call.id set to test), the same signature headers (a test key signs with the test-mode secret) and the same network rules. Pass the tool inline as here, or name a stored one with assistant_id and tool_name:
# Run the tool once, exactly as a call would: same body, same signature headers.curl https://api.morevoice.ai/v1/tools/test \ -H "Authorization: Bearer $MOREVOICE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "tool": { "name": "find_slots", "description": "Find free appointment slots for a doctor on a date.", "parameters": { "type": "object", "properties": { "date": { "type": "string" } }, "required": ["date"] }, "url": "https://clinic.example.com/morevoice/tools", "timeout_seconds": 10 }, "arguments": { "date": "2026-11-05" } }'import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // reads MOREVOICE_API_KEY
// Run the tool once, exactly as a call would: same body, same signature headers.const run = await mv.tools.test({ tool: { name: "find_slots", description: "Find free appointment slots for a doctor on a date.", parameters: { type: "object", properties: { date: { type: "string" } }, required: ["date"] }, url: "https://clinic.example.com/morevoice/tools", timeout_seconds: 10, }, arguments: { date: "2026-11-05" },});console.log(run.result);import os
import requests
API = "https://api.morevoice.ai/v1"HEADERS = {"Authorization": f"Bearer {os.environ['MOREVOICE_API_KEY']}"}
# Run the tool once, exactly as a call would: same body, same signature headers.response = requests.post( f"{API}/tools/test", headers=HEADERS, json={ "tool": { "name": "find_slots", "description": "Find free appointment slots for a doctor on a date.", "parameters": {"type": "object", "properties": {"date": {"type": "string"}}, "required": ["date"]}, "url": "https://clinic.example.com/morevoice/tools", "timeout_seconds": 10, }, "arguments": {"date": "2026-11-05"}, }, timeout=90,)response.raise_for_status()print(response.json()["result"]){ "object": "tool_test", "livemode": false, "tool": "find_slots", "type": "webhook", "ok": true, "duration_ms": 182, "result": { "date": "2026-11-05", "slots": ["2026-11-05T09:30", "2026-11-05T11:00", "2026-11-05T15:45"] }, "error": null}When the tool fails, ok is false and error.code says how: http_error (with the status your server answered), timeout, network, response_too_large or tool_error. A URL that can’t be called at all answers 400 with the code parameter_invalid.
Tools in flows
Section titled “Tools in flows”A custom tool is the model’s choice: the assistant calls it when the conversation needs it. When a step of your process must always call your server, at a fixed point of the call, use an API / Webhook node in a flow instead: it sends the request you define, maps fields of the answer to variables, and branches on success, error or time-out.
Develop against localhost
Section titled “Develop against localhost”The MoreVoice CLI brings your test calls’ tool calls to a server on your machine, with no public URL: morevoice listen --forward-tools http://localhost:3000/morevoice/tools posts each one to your local server, signed as in production, and sends your answer back to the call that is waiting for it. Step through your handler while you talk to the assistant. --forward-to does the same for webhook events.
The v1 tool contract
Section titled “The v1 tool contract”A tool that sets "contract": "v1" gets the whole call context with each request, and its answer can act on the call. Tools without contract, or with "legacy", keep the request and answer described above. tools.handler and tools.nodeHandler accept both, so switching a tool is a configuration change.
The request carries type: "tool.call", a tool_call_id (tc_…, also the webhook-id header, so you can drop repeats with either), the tool and its arguments, the call (its call_… ID, direction, numbers, assistant, flow, language, metadata and variables) and livemode. It is signed as above.
{ "type": "tool.call", "tool_call_id": "tc_5LwTfK2vXq9mR3nB8cY1aD", "tool": "find_slots", "arguments": { "date": "2026-11-05" }, "call": { "id": "call_8tRPaZp5hLMbrGqdJ9AmNa", "direction": "inbound", "from": "+972501234567", "to": "+97237654321", "assistant_id": "asst_4Gk2LmN9pQ4rS6tV8wX0yZ", "flow_id": null, "language": "he", "metadata": {}, "variables": {} }, "livemode": true}The answer may hold any of these fields; anything else (plain text, another JSON shape) is taken as the result, as in the legacy contract:
| Field | What MoreVoice does with it |
|---|---|
result |
Gives it to the model as the tool’s result. |
say |
Speaks this sentence (up to 1,000 characters) word for word, at once, and tells the model it was said. |
end_call |
true hangs up once the speech has played; with say, the sentence is the goodbye. |
transfer |
Hands the call to a queue (queue_id), a phone number (number) or another assistant (assistant_id), cold or warm (mode). |
error |
{ "message", "code" }: the model hears that the tool failed, and why. |
{ "result": { "booked": "2026-11-05T09:30" }, "say": "You're booked for Thursday at nine thirty. See you then!", "end_call": true}