Skip to content
WhatsApp

Build a WhatsApp Order Agent for a Grocery Shop

Harbor Street Market, Portland, Maine: live prices and stock, orders after yes, order status

The test chat of the Order assistant with a real AI reply

This guide builds a complete WhatsApp agent with SaleFlowPoint's custom chatbot (Mode 3) for Harbor Street Market, an invented grocery in Portland, Maine. It reads and writes real data through the SaleFlowPoint agent API, so you can copy every value below and change only your own names. Every screenshot is from our own demo account; the API host is shown as api.example-shop.com, so put your own SaleFlowPoint address there.

What you need first

  • A SaleFlowPoint company with the WhatsApp module (the trial works)
  • A WhatsApp API key: WhatsApp, then API mode, Create key (we named it Agent demo). It is shown once.
  • Your branch id: Settings, then Branches (the agent uses one branch for stock and orders)
  • For a live agent, a connected WhatsApp number. Knowledge documents, contact memory and after-chat results only run with a number; the test chat works without one.

Step 1: the connection (the login)

  • WhatsApp, then Connections, Add a connection
  • Name: SaleFlowPoint agent API
  • Login type: Bearer token
  • API host: api.example-shop.com (your own host)
  • Token: the API key from API mode (saved encrypted and never shown again)
  • Press Save connection
The Connections page with the saved SaleFlowPoint agent API bearer connection and the Add a connection form
The connection only ever sends its token to its own host.

Step 2: the URLs

WhatsApp, then URLs, Add a URL. Add these 4 URLs exactly. Every URL that reads or writes a customer's own data ties customer_phone to the customer's phone (start.customer_phone): the AI can never put another number, so a customer only ever sees and changes their own bookings or orders.

The URL library with each URL, its method and address
The finished URL library.

URL: search_products (GET)

  • Name: search_products
  • When to use: When needed during the chat
  • What it does: Searches the shop's products by a word. Gives item_id, name (with size), price (display text, e.g. 2.79) in US dollars (minor units: cents, 279 = 2.79 US dollars), stock_count (null = always available) and in_stock.
  • Method: GET
  • Connection: SaleFlowPoint agent API
  • Address: https://api.example-shop.com/api/v1/agent-api/products
  • Ask the customer yes before calling it: not ticked
  • Fields to keep: empty (keep everything)
  • Timeout: 15 seconds; retries: 1
  • Waiting text: Checking our shelves...
  • Inputs:
  • search - filled by: The AI fills it from the chat; goes in: Query; required: yes; what it is: One word of what the customer wants, e.g. milk
  • branch_id - filled by: A fixed value; goes in: Query; value: {your branch id} (Settings, Branches); required: yes

URL: place_order (POST)

  • Name: place_order
  • When to use: When needed during the chat
  • What it does: Places the order (up to 5 items). Gives the order id, status, total (items only), delivery_fee and total_with_delivery (what the customer pays).
  • Method: POST
  • Connection: SaleFlowPoint agent API
  • Address: https://api.example-shop.com/api/v1/agent-api/orders
  • Ask the customer yes before calling it: ticked
  • Fields to keep: empty (keep everything)
  • Timeout: 15 seconds; retries: 0
  • Inputs:
  • customer_phone - filled by: The customer's phone (locked; the AI can never change it); goes in: Body; phone format: With +; this is start.customer_phone, never typed by the AI; required: yes
  • customer_name - filled by: The AI fills it from the chat; goes in: Body; required: yes; what it is: Customer's full name
  • branch_id - filled by: A fixed value; goes in: Body; value: {your branch id} (Settings, Branches); required: yes
  • fulfilment - filled by: The AI fills it from the chat; goes in: Body; required: yes; what it is: delivery or pickup
  • address - filled by: The AI fills it from the chat; goes in: Body; required: no; what it is: Full delivery address with postcode
  • notes - filled by: The AI fills it from the chat; goes in: Body; required: no; what it is: Delivery time wish
  • item1 - filled by: The AI fills it from the chat; goes in: Body; place in the body: items[0].item_id; required: yes; what it is: item_id of item 1 from search_products
  • qty1 - filled by: The AI fills it from the chat; goes in: Body; place in the body: items[0].quantity; type: Number; required: yes; what it is: Whole quantity of item 1
  • item2 - filled by: The AI fills it from the chat; goes in: Body; place in the body: items[1].item_id; required: no; what it is: item_id of item 2 from search_products
  • qty2 - filled by: The AI fills it from the chat; goes in: Body; place in the body: items[1].quantity; type: Number; required: no; what it is: Whole quantity of item 2
  • item3 - filled by: The AI fills it from the chat; goes in: Body; place in the body: items[2].item_id; required: no; what it is: item_id of item 3 from search_products
  • qty3 - filled by: The AI fills it from the chat; goes in: Body; place in the body: items[2].quantity; type: Number; required: no; what it is: Whole quantity of item 3
  • item4 - filled by: The AI fills it from the chat; goes in: Body; place in the body: items[3].item_id; required: no; what it is: item_id of item 4 from search_products
  • qty4 - filled by: The AI fills it from the chat; goes in: Body; place in the body: items[3].quantity; type: Number; required: no; what it is: Whole quantity of item 4
  • item5 - filled by: The AI fills it from the chat; goes in: Body; place in the body: items[4].item_id; required: no; what it is: item_id of item 5 from search_products
  • qty5 - filled by: The AI fills it from the chat; goes in: Body; place in the body: items[4].quantity; type: Number; required: no; what it is: Whole quantity of item 5

URL: my_orders (GET)

  • Name: my_orders
  • When to use: At chat start
  • What it does: This customer's orders (by WhatsApp number): id, reference, status, total (items only) and total_with_delivery.
  • Method: GET
  • Connection: SaleFlowPoint agent API
  • Address: https://api.example-shop.com/api/v1/agent-api/orders
  • Ask the customer yes before calling it: not ticked
  • Fields to keep: empty (keep everything)
  • Timeout: 15 seconds; retries: 1
  • Inputs:
  • customer_phone - filled by: The customer's phone (locked; the AI can never change it); goes in: Query; phone format: With +; this is start.customer_phone, never typed by the AI; required: yes

URL: order_status (GET)

  • Name: order_status
  • When to use: When needed during the chat
  • What it does: One order of this customer by id or SO- reference.
  • Method: GET
  • Connection: SaleFlowPoint agent API
  • Address: https://api.example-shop.com/api/v1/agent-api/orders/{{ref}}
  • Ask the customer yes before calling it: not ticked
  • Fields to keep: empty (keep everything)
  • Timeout: 15 seconds; retries: 1
  • Inputs:
  • ref - filled by: The AI fills it from the chat; goes in: Path; required: yes; what it is: Order id or SO- reference
  • customer_phone - filled by: The customer's phone (locked; the AI can never change it); goes in: Query; phone format: With +; this is start.customer_phone, never typed by the AI; required: yes
The top of a URL form: name, when to use, what it does, method, connection and address
The top of the form.
The inputs of a URL: the customer's phone, the AI-filled fields and the fixed branch id
Inputs: who fills each one and where it goes.
The lower part of the URL form with fields to keep, ask the customer yes, timeout, retries and waiting text
Ask the customer yes is ticked on every write.

Step 3: the agent's instructions

  • WhatsApp, then Agents, Create agent; name: Order assistant
  • A chat ends after 30 minutes without a message
Description (paste it whole)
You are the WhatsApp ordering assistant of Harbor Street Market, a grocery in Portland, Maine.
You find products with live prices and stock, suggest similar items when something is out, take orders for delivery or pickup, and answer "where is my order".
Prices are in dollars from search_products only; never add up totals yourself, copy totals only from place_order. In place_order's reply, total is the items only and total_with_delivery is what the customer pays.
Before the order is placed, list the item prices and the delivery fee but give no total, and never copy a total from an earlier order in my_orders.
If stock_count is lower than wanted, say how many are left and suggest a similar item.
To order: confirm items and quantities, the customer's name, delivery or pickup, and for delivery the address and a preferred delivery time.
Show one short summary and call place_order in the same reply; the system asks the customer to reply yes.
There is no online payment link: payment is on delivery or at pickup.
For order questions use my_orders / order_status: draft = received, the shop will confirm it.
Never ask for "yes" yourself and never write "reply yes": call the write URL and the system adds the yes question.
A yes in any language or wording (for example "sounds good", "vale", "haan", a thumbs up) is understood by the system, which then runs the request you prepared; do not call that URL again yourself.
Never say anything is booked, moved, cancelled or ordered unless that URL's reply in this chat gives its id.
Today's date is in your instructions: work out "tomorrow" or a weekday from it.
Shop facts (answer only from these): Harbor Street Market, a grocery in Portland, Maine, with two shops (Harbor Street and Munjoy Hill).
Delivery on the Portland peninsula 4.99 US dollars, minimum order 15, US dollars same day for orders before 2 PM; or pickup at Harbor Street.
Payment on delivery or at pickup (no online payment link).
Returns: tell us within 48 hours for a refund or replacement on fresh items.
Greeting (first reply)
Hi, this is Harbor Street Market. I can check prices and stock, take an order for delivery or pickup, or find your order.
When your system does not answer
Sorry, our system is busy right now. A member of the team will reply shortly.
When a question is out of scope
I can help with our products, orders and deliveries. For anything else the team will reply.
The agent workspace with the Instructions section
The Instructions section.

Then open URLs it may call and tick: search_products, place_order, my_orders, order_status. Press Save.

URLs it may call with each URL ticked
The agent can only call the URLs ticked here.

Step 4: details, tasks and after-chat results

  • Details to collect:
  • delivery_address - type text; required: no; Remember ticked; what it is: Delivery address
  • delivery_time - type text; required: no; what it is: Preferred delivery time
  • favourite_items - type text; required: no; Remember ticked; what it is: Items the customer buys often
Details to collect with each detail
Details the AI picks up from the chat.
  • Tasks (outcomes):
  • order_placed - when it is done: An order was placed after the customer said yes
Tasks (outcomes) of the agent
A task counts as done only after its write succeeded.
  • After the chat (on the right, After the chat, Add a field):
  • summary - type text; what it is: One-line summary
The After the chat fold with its fields
After-chat fields are filled when a live chat ends.

Step 5: webhooks for your team

  • WhatsApp, then Webhooks, Add webhook:
  • When: a task is done; task name: order_placed; address: https://webhook.site/{your-id}; send: always
  • Copy the signing secret while it is shown (once), then attach the webhook in the agent under Webhooks.
  • In the test chat a webhook is only listed as would be sent; live chats really post it.

Step 6: build and test

Press Build agent. Read each AI-check warning, tick it if it is fine, and build again. Then press Test chat, enter the phone of a test customer, and untick Dry run only when you want the writes to really happen.

Test chat (real AI, our dev account)
Customer: Hi, how much is milk and do you have it?
[my_orders at chat start, search_products 200]
Agent: We have Whole milk, 1 gallon for 4.29 US dollars (97 in stock) and 2% milk, half gallon for 2.79 US dollars (95 in stock). Would you like to add either of these to an order?
Customer: 2 of the whole milk and a sourdough loaf please, delivery to 42 Fore Street, Portland ME 04101, around 5 PM. I'm Jordan Lee
Agent: Here is your order summary:
- 2x Whole milk, 1 gallon: 4.29 US dollars each
- 1x Sourdough loaf: 6.49 US dollars
- Delivery fee: 4.99 US dollars
- Delivery to: 42 Fore Street, Portland ME 04101 (around 5 PM)
- Name: Jordan Lee   [the system asks the customer to reply yes]
Customer: yes
[place_order 201 - task order_placed]
Agent: Your order has been placed successfully!
Status: draft (received, the shop will confirm it)
Items total: 15.07 US dollars
Delivery fee: 4.99 US dollars
Total with delivery: 20.06 US dollars
Payment will be on delivery. Thank you, Jordan!
Test chat (real AI, our dev account)
Customer: Where is my order?
[my_orders 200, order_status 200]
Agent: Your order status is draft, which means it has been received and the shop will confirm it shortly.
The test chat with a real AI reply and the trace of URL calls
The grey lines are the trace: each URL call with its status.

What we saw in testing

  • Prices and stock counts come only from search_products; the agent never adds up totals itself. The order's reply gives total (the items only) and total_with_delivery, and the agent quotes the total with delivery.
  • A pickup order of one loaf was refused by the shop's minimum order of 15 dollars (answer 409), and the agent handed the chat to the team. Put your minimum order in the description.

Step 7: connect a number and choose Custom chatbot

  • WhatsApp, then Numbers. Tick that your number is on WhatsApp Business (or on no WhatsApp at all), then Connect with QR code (keep the WhatsApp Business app) or Connect a new number, and finish Meta's sign-up.
  • The number then shows on Numbers (in our demo the invented +1 207-555-0142). Press Change mode on it.
  • On How should this number work?, choose Custom chatbot with your APIs (the other two are API service and Chatbot with products and services), read What changes when you switch, and press Switch to Custom chatbot.
  • During the WhatsApp trial the custom chatbot costs nothing; after that the number is paid at the Custom chatbot price.
WhatsApp Numbers with one connected number in Chatbot mode and the Connect another number section
Numbers: each number has its own mode. Change mode opens the mode picker.
How should this number work? with API service, Chatbot with products and services, and Custom chatbot with your APIs chosen
Choose Custom chatbot with your APIs. The switch works once an agent for this number is built and live.

Step 8: go live

In the agent, choose that number under WhatsApp number and press Activate version. New chats use that version at once, and Pause stops every chat.

Start free today

One shop and one till free, with no time limit and no card to sign up.

Loading SaleFlowPoint…