# Shop in chats (ERPNext)

> Your agent shows your ERPNext items with photos, prices with VAT and stock per branch in any chat. Customers add to a cart, choose pickup or delivery, and the order lands in ERPNext as a sales order.

If you sell from ERPNext, your agent can sell from it too, in any chat: on your page, in the app, or with a customer's own AI. Customers see your real photos, your price with VAT, and which branch has it. They add to a cart, pick it up or get it delivered, and the order goes straight into ERPNext.

It's **off until you turn it on**, and it only reads what you allow.

## Open your shop

1. In ERPNext, add a user just for the shop (for example "Shop agent") and make its API key: **User → Settings → API Access → Generate Keys**. Your agent can never do more than this user can. It needs to **read** Item, Item Price, File, Bin, Warehouse and Sales Taxes and Charges Template, and to **create** Sales Order if orders should go into ERPNext.
2. In OpenNodd, open **My business → Orders** and press **Open your shop**. Pick **ERPNext**, paste your ERPNext address, the key and the secret, and press **Connect and check**.
3. OpenNodd shows what it found: how many products and photos, your price lists (it picks your default selling price list; change it in Shop settings), the VAT rate from your default tax template, and your warehouses. Nothing is changed in ERPNext. Anything missing comes with what to fix.
4. Press **Set up your shop**, check the settings, and turn on **Sell in chats** at the top.

The key is kept encrypted and never shown again, not even to you. Paste it only here, never in a chat with an AI.

## What customers see

When a customer asks for something ("front brake pads for a 2019 Hilux"), your agent finds the items and shows them as product cards. Each card has:

- the photo (the item's image in ERPNext, and any other public pictures attached to the item: tap it to see them big, zoom in and look around),
- the brand and item code, and the name,
- the price **including VAT**, with the price before VAT under it (you can turn that round),
- stock: "In stock · 6 at Main Street", or "Only 2 left · Harbour", or "Out of stock" (services and subscriptions, which aren't stock items in ERPNext, show no stock),
- when it's ready for pickup,
- how many, and **Add to cart**.

A card can carry your agent's short note, like **Fits your Hilux**.

**Prices, photos and stock always come from ERPNext, never from your agent.** Your agent only names the item codes; OpenNodd reads the rest from your price list (today's price, as ERPNext counts it: never a price set for one customer, or one that has ended). Checkout reads the prices again, so nobody can change what they pay.

## Checkout

The cart opens beside the chat (the whole screen on a phone), in three steps:

1. **Cart**: change how many, or remove something.
2. **Pickup or delivery**: the branch (it says whether everything is in stock there), or a delivery address with your fee; a phone number for updates; and their own reference, like a job card or PO number.
3. **Pay**: the ways you turned on: at the counter (or to the driver), mobile money (they get your instructions after ordering), or on account.

The total shows the VAT inside it. After **Place order**, the customer gets the order number and, for pickup, a code and QR code to show at the counter. The order also appears in the chat as a card that updates as it moves on: being picked, ready, collected (or out for delivery, delivered). They can save a receipt from it.

## Orders

**My business → Orders** shows today's orders, sales with VAT, what's waiting to be picked, and what waits for your yes. Open an order to see:

- the customer, their phone and reference,
- pickup (with the code) or delivery (address and fee), and how they pay,
- the **pick list**: tick each item as you pick it,
- the sales order in ERPNext, with a link to open it,
- what happened, with times.

Its main button moves it on: **Mark ready for pickup** (or **Hand to the driver**), then **Collected · code checked** (or **Delivered**). Each step tells the customer in their chat. **Mark as paid** records a payment at the counter or by mobile money. **Cancel order** tells the customer; cancel the sales order in ERPNext yourself if you need to.

Your agent also tells you about each new order in your chat with it.

## Orders in ERPNext

Each order becomes a **Sales Order** in ERPNext, under the customer you choose for chat orders (it must exist in ERPNext), with your price list, the branch's warehouse, and the order number and the customer's reference in **Customer's Purchase Order**. VAT goes on it from your tax template at the VAT rate in Shop settings; if there is no template at that rate, or the shop user may not read templates, the order says so. Choose in **Shop settings → Orders in ERPNext**:

- **Draft**: your staff check and submit it.
- **Submitted**: stock is reserved straight away.
- **Off**: nothing goes to ERPNext; you enter orders yourself.

If ERPNext refuses one (for example, the shop user may not create Sales Orders), the order is kept and the reason shows on it; press **Send to ERPNext again** once it's fixed. To put the delivery fee on the sales order, set a delivery item code under **Delivery**.

## Shop settings

**My business → Orders → Shop settings**:

- **Products**: show items without a photo or not; hide what's out of stock everywhere; whether customers see "In stock" or how many; from how many it says "Only a few left".
- **Prices and tax**: the price list everyone sees, the VAT rate, whether your ERPNext prices include VAT, which price shows big, and whether the other shows small.
- **Branches and pickup**: each warehouse, the name customers know it by, whether they can pick up there, and how soon it's ready.
- **Delivery**: on or off, where, the fee (including VAT), free over an amount, and what you promise ("Tomorrow, 9:00 to 12:00").
- **Payments**: at the counter, mobile money (with your instructions; `{order}` becomes the order number), on account.
- **What needs your yes**: orders over an amount, and orders on account. They wait in Orders; nothing goes to ERPNext until you say yes. Your agent can never give a discount or a refund.
- **Connection**: change the key, or disconnect (the shop turns off and the key is deleted here; orders stay).

The preview on the right shows what customers will see. Your agent uses new settings straight away.

## For developers

A product card is `{"v":1,"kind":"product","title":"…","items":[{"code":"508-212","badge":"Fits your Hilux"}]}` (see [Cards](/reference/cards)). The app reads it through `GET /v1/shop/items?message=<id>` and orders through `POST /v1/shop/checkout`; the owner's side is `GET/PUT /v1/me/shop`, `POST /v1/me/shop/connect` and `GET /v1/me/shop/orders`. Product cards from a shop that is off, and order cards from anyone but OpenNodd, are dropped and only their words show.
