If you are running ERPNext v15 and want real-time Slack notifications whenever stock movements occur, this step-by-step guide shows you exactly how to set up webhook-based alerts for Material Issues, Material Transfers, and Purchase Receipts. You will also learn how to avoid the common Jinja templating error that catches most people off guard during setup.

This method uses ERPNext’s built-in Webhook DocType paired with Slack Incoming Webhooks. No custom app, third-party plugin, or server script is required β€” just a few minutes of configuration inside your ERPNext instance.

How It Works

ERPNext includes a built-in Webhook DocType that fires HTTP POST requests whenever a document is created, submitted, updated, or deleted. In this setup, you configure webhooks that trigger on the on_submit event for stock-related documents. When a user submits a Stock Entry or Purchase Receipt, ERPNext renders a Jinja template into a JSON payload and sends it as a POST request to a Slack Incoming Webhook URL. Slack then displays a neatly formatted message in your chosen channel, including the stock entry type, item details, quantities, and warehouse locations.

There is one critical gotcha you need to understand before writing your Jinja templates. In ERPNext’s webhook context, the doc object behaves like a Python dictionary rather than a Frappe document object. This means that if you write doc.items in your Jinja template to access line items, Python interprets it as a call to the dictionary’s built-in .items() method β€” not as the child table field named “items.” The result is the error TypeError: 'builtin_function_or_method' object is not iterable, and your webhook silently fails. The fix is straightforward: use doc.get('items', []) instead, which safely retrieves the child table without any conflict.

You will also need two separate webhooks because Material Issue and Material Transfer are types within the Stock Entry DocType, while Purchase Receipt is an entirely separate DocType with its own data structure.

Step 1 β€” Create a Slack Incoming Webhook

  1. Go to https://api.slack.com/apps.
  2. Create a new Slack app or open an existing one.
  3. Under Features, enable Incoming Webhooks.
  4. Click Add New Webhook to Workspace and select the channel where you want stock alerts to appear.
  5. Copy the generated Webhook URL β€” you will need it in the next steps.

Security note: Treat this URL like a password. Anyone who possesses it can post messages to your Slack channel. Never commit it to version control or share it in a public forum.

Step 2 β€” Create the Stock Entry Webhook (Material Issue + Material Transfer)

In ERPNext, navigate to the search bar, type Webhook, and click New to open a blank webhook form.

Webhook Settings

FieldValue
Document TypeStock Entry
Doc Eventon_submit
Request MethodPOST
Request URLYour Slack webhook URL
EnabledChecked

Condition

Add a condition to ensure this webhook only fires for Material Issues and Material Transfers, and not for every Stock Entry type in the system:

doc.stock_entry_type in ("Material Issue", "Material Transfer")

Without this condition, you will receive Slack alerts for every stock entry type β€” manufacture entries, repack entries, material receipts, and more β€” which quickly creates notification fatigue and makes alerts meaningless.

Request Header

Add one header row so Slack correctly interprets the incoming data:

KeyValue
Content-Typeapplication/json

JSON Payload

Paste the following template into the Request Body field. Note that this template uses doc.get() throughout to avoid the doc.items dictionary conflict described earlier:

{
  "text": "πŸ“¦ *Stock Entry Submitted*\n*Type:* {{ doc.get('stock_entry_type', 'β€”') }}\n*ID:* {{ doc.get('name', 'β€”') }}\n*Company:* {{ doc.get('company', 'β€”') }}\n*Posting:* {{ doc.get('posting_date', 'β€”') }} {{ doc.get('posting_time', '') }}\n*From WH:* {{ doc.get('from_warehouse') or 'β€”' }}\n*To WH:* {{ doc.get('to_warehouse') or 'β€”' }}\n\n*Items:*\n{% for i in doc.get('items', []) %}β€’ {{ i.get('item_code', 'β€”') }} β€” Qty: {{ i.get('qty', 0) }} {{ i.get('uom', '') }} ({{ i.get('s_warehouse') or i.get('t_warehouse') or 'β€”' }})\n{% endfor %}"
}

Step 3 β€” Create a Separate Webhook for Purchase Receipt

Purchase Receipt is a distinct DocType in ERPNext β€” it is not a subtype of Stock Entry. You cannot handle it by adding another condition to the Stock Entry webhook. A second, dedicated webhook is required.

Webhook Settings

FieldValue
Document TypePurchase Receipt
Doc Eventon_submit
Request MethodPOST
Request URLYour Slack webhook URL
EnabledChecked

Add the same Content-Type: application/json header as before. No condition is necessary unless you want to filter alerts by a specific supplier, company, or warehouse.

JSON Payload

{
  "text": "🧾 *Purchase Receipt Submitted*\n*ID:* {{ doc.get('name', 'β€”') }}\n*Supplier:* {{ doc.get('supplier', 'β€”') }}\n*Company:* {{ doc.get('company', 'β€”') }}\n*Posting:* {{ doc.get('posting_date', 'β€”') }} {{ doc.get('posting_time', '') }}\n\n*Items Received:*\n{% for i in doc.get('items', []) %}β€’ {{ i.get('item_code', 'β€”') }} β€” Qty: {{ i.get('qty', 0) }} {{ i.get('uom', '') }} ({{ i.get('warehouse') or 'β€”' }})\n{% endfor %}"
}

Step 4 β€” Test the Webhooks

Run a quick test for each document type to confirm that Slack messages are delivered correctly and contain the expected information:

  1. Create and submit a Material Transfer Stock Entry. Check your Slack channel for the alert and verify the item details are correct.
  2. Create and submit a Material Issue Stock Entry. Confirm the alert appears and the source warehouse is populated.
  3. Create and submit a Purchase Receipt. Confirm it triggers the second webhook and displays the supplier and received items.

Troubleshooting

If no messages appear in Slack, check the ERPNext backend logs for errors. Look specifically for Jinja rendering errors or HTTP request failures. If you are running ERPNext in Docker, use one of the following commands:

docker compose logs -f backend

Or from inside the bench container:

bench --site yoursite tail

The most common causes of failure are an incorrect or expired Slack webhook URL, a malformed JSON payload (such as unescaped newlines or missing brackets), and Jinja template errors caused by using doc.items instead of doc.get('items', []).

Optional β€” Add a Clickable Link to the ERP Record

You can make your Slack alerts even more actionable by including a direct link to the submitted document. Add the following line inside the text field of your JSON payload, replacing erp.yourdomain.com with your actual ERPNext domain:

For Stock Entries:

https://erp.yourdomain.com/app/stock-entry/{{ doc.get('name') }}

For Purchase Receipts:

https://erp.yourdomain.com/app/purchase-receipt/{{ doc.get('name') }}

Slack automatically converts plain URLs into clickable hyperlinks, so no additional Slack Block Kit formatting is needed. Team members can jump directly from the Slack alert to the relevant ERPNext record with a single click.

Summary

You now have automatic, real-time Slack alerts for Material Issues, Material Transfers, and Purchase Receipts β€” all triggered on submission and formatted with item-level detail. Here are the key points to remember as you manage and expand these webhooks:

  • Always use doc.get('field') instead of doc.field in ERPNext webhook Jinja templates. This prevents the doc.items conflict with Python’s built-in dictionary method and eliminates the most common webhook error.
  • Material Issue and Material Transfer are subtypes within the Stock Entry DocType β€” use a condition filter to target only those types and avoid notification noise.
  • Purchase Receipt is a separate DocType entirely and requires its own dedicated webhook configuration.
  • Treat your Slack webhook URL as a sensitive credential β€” store it securely and never expose it in public repositories or documentation.
  • Add clickable ERPNext record links to your Slack messages to help your team act on alerts quickly without searching for the document manually.