> This is a page from the ElevenLabs documentation. For an index of the documentation, fetch https://elevenlabs.io/docs/llms.txt.

# ERPNext

With the [webhook tools](/docs/reception-ai/integrations/webhooks) below, your receptionist can recognize callers who are already ERPNext leads, register new callers as leads with their name, phone number, and a note on what they need, and leave a comment on existing leads, so your sales team can call them back. ERPNext and the Frappe framework accept a static API key and secret and JSON request bodies, so this works on Frappe Cloud and self-hosted sites.

## Before you start

### Create an API user

In ERPNext, create a user for Reception.ai, for example `reception@yourcompany.com`, and give it only the **Sales User** role. API requests run with this user's permissions, so don't use an administrator.

### Generate the keys

Open the user, select the **Settings** tab, expand **API Access**, and select **Generate Keys**. Copy the **API Secret** from the popup right away: ERPNext only shows it once. The **API Key** stays visible in the same section.

Every tool below sends a request header named `Authorization` with the value `token API_KEY:API_SECRET`, with your key and secret joined by a colon. Set its **Type** to **Secret**.

> **Warning**
>
> The key and secret can read and change everything the **Sales User** role allows. Keep them out of
> shared documents, and select **Generate Keys** again to replace them if they leak.

### Find your site address

Your tools' URLs start with the address you open in your browser to use ERPNext. The tables below use `https://YOUR-SITE.example.com`; replace it with your own.

## Create the tools

For each tool, go to **Integrations**, select **Add integration**, choose **Webhook Tool**, and set **Assign to agents** to **Receptionist**. Set **Value** to **Fixed value** for every parameter marked "Always" below.

### Find a lead

| Field                | Value                                                                                                                                                                                                                                                                                |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Name**             | `find_erpnext_lead`                                                                                                                                                                                                                                                                  |
| **Description**      | "Find the caller among our leads by phone number. Use it at the start of a call to check whether they've contacted us before."                                                                                                                                                       |
| **Method**           | GET                                                                                                                                                                                                                                                                                  |
| **URL**              | `https://YOUR-SITE.example.com/api/resource/Lead`                                                                                                                                                                                                                                    |
| **Request Headers**  | `Authorization`: `token API_KEY:API_SECRET`                                                                                                                                                                                                                                          |
| **Query Parameters** | `or_filters` (string, required): "A filter on the last seven digits of the caller's number, exactly like `[["mobile_no","like","%5550123%"],["phone","like","%5550123%"]]`."  `fields` (string): Always `["name","lead_name","status"]`.  `limit_page_length` (integer): Always `5`. |

### Register a new lead

| Field               | Value                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Name**            | `create_erpnext_lead`                                                                                                                                                                                                                                                                                                                                                                                                         |
| **Description**     | "Register the caller as a new lead when `find_erpnext_lead` didn't find them."                                                                                                                                                                                                                                                                                                                                                |
| **Method**          | POST                                                                                                                                                                                                                                                                                                                                                                                                                          |
| **URL**             | `https://YOUR-SITE.example.com/api/resource/Lead`                                                                                                                                                                                                                                                                                                                                                                             |
| **Request Headers** | `Authorization`: `token API_KEY:API_SECRET`                                                                                                                                                                                                                                                                                                                                                                                   |
| **Body Parameters** | `first_name` (string, required): "The caller's first name."  `last_name` (string): "The caller's last name."  `mobile_no` (string, required): "The caller's phone number in international format, for example +14155550123."  `email_id` (string): "The caller's email address, if they gave one."  `lead_owner` (string): Always the email address of the salesperson who calls new leads back.  `notes` (array): see below. |

To set where leads came from, add `source` (string) as a fixed value that matches one of your **Lead Source** records exactly. On ERPNext 16 and later, the field is `utm_source` instead, and it must match a **UTM Source** record.

`notes` fills the lead's **Notes** tab. Give it the description "Send exactly one item, with what the caller needs." Under **Each item**, choose `object`, then select **Add field** for each of these:

* `note` (string, required): "What the caller needs, and when they'd like a call back."
* `added_by` (string): Always the API user's email address.

### Log the call details

| Field               | Value                                                                                                                                                                                                                                                                                                                                                             |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Name**            | `add_erpnext_lead_comment`                                                                                                                                                                                                                                                                                                                                        |
| **Description**     | "Leave a comment on the caller's lead with what they need. Use it when `find_erpnext_lead` found the caller, with the lead's name, such as CRM-LEAD-2026-00012."                                                                                                                                                                                                  |
| **Method**          | POST                                                                                                                                                                                                                                                                                                                                                              |
| **URL**             | `https://YOUR-SITE.example.com/api/method/frappe.desk.form.utils.add_comment`                                                                                                                                                                                                                                                                                     |
| **Request Headers** | `Authorization`: `token API_KEY:API_SECRET`                                                                                                                                                                                                                                                                                                                       |
| **Body Parameters** | `reference_doctype` (string): Always `Lead`.  `reference_name` (string, required): "The lead's name, from `find_erpnext_lead` or `create_erpnext_lead`."  `content` (string, required): "What the caller needs, and when they'd like a call back."  `comment_email` (string): Always the API user's email address.  `comment_by` (string): Always `Reception.ai`. |

Select **Enable** on each tool, then [test your receptionist](/docs/reception-ai/receptionist/testing) as a new caller who asks to be called back. The lead appears in your **Lead** list, owned by your salesperson, with your receptionist's comment.

> **Tip**
>
> Add a [procedure](/docs/reception-ai/receptionist/rules-and-procedures) for callers: find the
> lead, then either register them with a note if they aren't found, or log the call details on the
> lead that was found. Add a rule that your receptionist never reads lead records back to callers.

> **Warning**
>
> Your receptionist writes the search filter from the conversation, so a caller could try to get it
> to search for other people's leads. The tool only returns up to five names and statuses, but keep
> the rule above in place. If **Sales User** gives more access than you want, such as customers and
> quotations, create a custom role that can only read, create, and comment on leads.

## Limitations

* The search looks for the last seven digits of the number. Numbers stored with spaces or dashes inside those digits aren't found, and two callers can share the same last seven digits.
* This setup only covers leads. Your receptionist doesn't search contacts or customers, or create opportunities.

## Troubleshooting

| Problem                              | What to check                                                                                                                                                        |
| ------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 401 or 403 from ERPNext              | The header value must be `token`, a space, then the key and secret joined by a colon. Check the user is enabled and has **Sales User**.                              |
| Known callers aren't found           | Store numbers without spaces or dashes, and check the number is in the lead's **Mobile No** or **Phone** field.                                                      |
| Error about the lead owner or source | `lead_owner` must be an enabled user's email address, and `source` must match a **Lead Source** exactly (`utm_source` and a **UTM Source** on ERPNext 16 and later). |
| Error about the phone number         | ERPNext checks phone numbers. Tell your receptionist to send digits with an optional leading `+` only.                                                               |
| Error about `added_by`               | `added_by` in `notes` must be an enabled user's email address, such as the API user's.                                                                               |
| The comment isn't added              | `reference_name` must be the name of an existing lead, such as `CRM-LEAD-2026-00012`. Check the find or create tool ran first.                                       |