To let an AI phone agent answer "where is my order?" for a custom-built store, you build one read-only endpoint that returns an order's status, and register it on the agent as a custom HTTP function. During a call the agent calls your endpoint with the order number, optionally with the caller's phone number filled in by the platform, and reads your JSON back to the customer. Magento and BigCommerce work the same way, against their own order APIs.
This guide is for the developer doing the work: the endpoint contract, code in three languages, how the function is configured, caller verification, and outcome webhooks for outbound calls.
The architecture
Caller ──► AI voice agent ──(HTTPS, mid-call)──► GET /voice/order-status ──► your order DB
▲ │
└── spoken answer ◄── JSON { status, items, eta, tracking }The agent decides when to call your function from the function's description ("look up an order when the customer asks where it is"), fills in the parameters from the conversation, and gets your response. Your token lives in the Edesy credential vault and is injected at request time; it never appears in the prompt or the model's context.
The endpoint contract
Keep the response small: the agent only needs what it will say.
GET /voice/order-status?order_id=4473&phone=%2B919876543210
Authorization: Bearer <token>{
"found": true,
"status": "shipped",
"items": ["Round bottle applicator (pack of 2)"],
"expected_delivery": "2026-12-04",
"courier": "Delhivery",
"tracking_url": "https://track.example.com/AWB123"
}- Return
{"found": false}for no match, not a 404. The agent handles it as "please check the number". - Use plain status words (
packed,shipped,out_for_delivery,delivered) or explain your codes in the agent's prompt. - Don't return addresses, emails or payment details. The agent doesn't need them.
Code: Node.js, PHP and Python
// Node.js (Express)
app.get("/voice/order-status", async (req, res) => {
if (req.get("Authorization") !== `Bearer ${process.env.VOICE_TOKEN}`) return res.sendStatus(401);
const order = await db.orders.findOne({ number: req.query.order_id, phone: req.query.phone });
if (!order) return res.json({ found: false });
res.json({ found: true, status: order.status, items: order.items.map(i => i.name),
expected_delivery: order.eta, courier: order.courier, tracking_url: order.trackingUrl });
});<?php // PHP
if (($_SERVER['HTTP_AUTHORIZATION'] ?? '') !== 'Bearer ' . getenv('VOICE_TOKEN')) { http_response_code(401); exit; }
$order = find_order($_GET['order_id'] ?? '', $_GET['phone'] ?? '');
header('Content-Type: application/json');
echo json_encode($order ? ['found' => true, 'status' => $order['status'],
'items' => array_column($order['items'], 'name'), 'expected_delivery' => $order['eta'],
'courier' => $order['courier'], 'tracking_url' => $order['tracking_url']] : ['found' => false]);# Python (FastAPI)
@app.get("/voice/order-status")
def order_status(order_id: str, phone: str = "", authorization: str = Header("")):
if authorization != f"Bearer {os.environ['VOICE_TOKEN']}":
raise HTTPException(401)
order = find_order(order_id, phone)
return ({"found": True, "status": order.status, "items": [i.name for i in order.items],
"expected_delivery": order.eta, "courier": order.courier,
"tracking_url": order.tracking_url} if order else {"found": False})Register the function on the agent
In the Edesy dashboard: your agent → Tools → Custom Functions.
- Function Name:
get_order_status - Description: "Look up an order when the customer asks where their order is. Needs the order number."
- URL:
https://api.yourstore.com/voice/order-status?order_id={{order_id}}&phone={{call.phone_number}} - Headers:
Authorization: Bearer {{vault.order_api}}(save the token under Credentials first) - Parameter:
order_id(string, required) - Response mapping (optional): pick fields by path, such as
{"status": "status", "eta": "expected_delivery"}. Array items use an index, such asitems.0.
Use Test with a real order. The full field-by-field reference is in Connect any online store.
Verify the caller
Sequential order numbers are guessable, so don't answer for any number a caller says:
{{call.phone_number}}is filled in by the platform with the number that's calling. Filter orders by it, and a caller can only hear about their own orders.- If customers often call from a different phone, ask for the order number and the phone or email on the order, and match both server-side.
- Every request also carries an
X-Call-Idheader, so you can log which call made which lookup.
Magento and BigCommerce
You don't have to write an endpoint. Point the function straight at the platform's order API:
- Magento / Adobe Commerce: search by the order number customers see,
GET https://<store>/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=increment_id&searchCriteria[filter_groups][0][filters][0][value]={{order_number}}, with an integration access token. (GET /rest/V1/orders/{id}takes Magento's internal entity ID, not the order number.) - BigCommerce:
GET https://api.bigcommerce.com/stores/<hash>/v2/orders/{{order_id}}with an API account token inX-Auth-Token.
Use read-only tokens and response mapping to trim the large platform payloads down to a few fields. A thin endpoint of your own in front of the platform API is often cleaner, and lets you add the caller check above.
Outbound: call customers on order events
The same agent can call customers when an order ships or a delivery fails. Your backend starts the call and gets the result back:
curl -X POST https://voice-agent.edesy.in/api/v1/calls \
-H "Authorization: Bearer vp_live_YOUR_KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: order-4473-shipped" \
-d '{"agentId": 123, "phoneNumber": "+919876543210",
"variables": {"order_id": "4473", "expected_delivery": "Thursday"}}'Save the returned conversationId against the order, and subscribe to the signed call.analyzed webhook (Settings → Integrations → Webhooks) to receive the disposition, summary and collected data. Details: order events and outcomes. If you've built webhook-driven calls before, our outbound IVR API examples follow the same pattern.
FAQ
How does an AI phone agent read orders from a custom store? Through a custom HTTP function that calls your endpoint during the call and reads back the JSON you return.
What should the endpoint return? Only what the agent will say: found, status, items, expected delivery, courier and tracking link.
How do I stop callers hearing other people's orders?
Filter by {{call.phone_number}}, the caller's own number, or require the order number and phone to match.
Does this work with Magento or BigCommerce? Yes, against their order APIs with read-only tokens in the credential vault.
Can the agent call customers when an order ships?
Yes: POST /api/v1/calls on the event, plus the call.analyzed webhook for the result.
Start free
Create a voice agent, register your endpoint as a custom function, and test it with a real order. Want a second pair of eyes on the setup? Tell us about your store.