User guide
Use Inbox Ops for inbound messages that should become operational work. Configure the receiving domain first, then follow a test message through processing.
Set up the email-to-ERP agent so your team can forward customer email threads and have Open Mercato automatically extract orders, quotes, contacts, and reply drafts.
Info · Resend-specific receiving flow
The Communications Hub system email transport can use Resend or Amazon SES for outbound transactional email, but Inbox Ops receiving still uses Resend webhooks to fetch inbound email content. Setting SYSTEM_EMAIL_PROVIDER=ses for outbound transactional emails does not replace the Resend webhook setup described here.
[email protected])Tip · Running on localhost?
If you are setting this up on your dev machine, jump straight to the Local Development Setup section – it walks through the full Resend + ngrok flow end to end.
Resend needs to receive emails on your behalf. Choose one of two options:
Every Resend account gets a free managed receiving domain automatically:
<id>.resend.app (e.g. eldaaelkia.resend.app)anything@<id>.resend.app will be received by ResendNo DNS setup, no MX records – it works immediately.
Use a dedicated subdomain for a branded inbox address:
inbox.yourcompany.cominbox.yourcompany.com. MX 10 inbound.resend.com.
Tip
Use a dedicated subdomain like inbox. or inbound. – don't use your main domain to avoid interfering with regular email delivery.
https://your-app.yourcompany.com/api/inbox_ops/webhook/inbound
Info · Development
For local development, use a tunnel URL (e.g. https://abc123.ngrok-free.app/api/inbox_ops/webhook/inbound)
whsec_Add these to your .env file:
# Resend API key (required — used to fetch full email content from Resend)
RESEND_API_KEY="<resend-api-key>"
# Webhook signing secret from Step 2 (starts with whsec_)
RESEND_WEBHOOK_SIGNING_SECRET="<resend-webhook-signing-secret>"
# Your Resend receiving domain from Step 1 (just the domain, no email prefix)
INBOX_OPS_DOMAIN=eldaaelkia.resend.app
The extraction engine needs an AI model to parse emails. Configure whichever provider you prefer:
# Provider: anthropic, openai, or google
OPENCODE_PROVIDER=anthropic
# Set the API key for your chosen provider
ANTHROPIC_API_KEY="<anthropic-api-key>"
# OPENAI_API_KEY="$OPENAI_API_KEY"
# GOOGLE_GENERATIVE_AI_API_KEY="$GOOGLE_GENERATIVE_AI_API_KEY"
# Override the default LLM model for extraction
# INBOX_OPS_LLM_MODEL=
# LLM timeout in ms (default: 90000 = 90 seconds)
# INBOX_OPS_LLM_TIMEOUT_MS=90000
# Confidence threshold: proposals below this go to "needs review" (default: 0.5)
# INBOX_OPS_CONFIDENCE_THRESHOLD=0.5
# Max email text sent to LLM in bytes (default: 204800 = 200KB)
# INBOX_OPS_MAX_TEXT_SIZE=204800
# Price mismatch tolerance as decimal fraction (default: 0.05 = 5%)
# INBOX_OPS_PRICE_MISMATCH_THRESHOLD=0.05
Restart the dev server after updating env vars.
After starting Open Mercato, each tenant automatically gets an inbox address generated during setup. You can also configure a working language on the Settings page – proposals will be translated to this language for easier review.
The address format is:
ops-<first-8-chars-of-org-id>@<INBOX_OPS_DOMAIN>
For example: [email protected]
To find your address:
SELECT inbox_address FROM inbox_settings WHERE deleted_at IS NULL;If the address shows an old domain, update it to match your INBOX_OPS_DOMAIN:
UPDATE inbox_settings
SET inbox_address = REPLACE(inbox_address, 'old.domain.com', 'your-id.resend.app')
WHERE deleted_at IS NULL;
Share this address with your team. They'll forward email threads to it when they want Open Mercato to process them.
Send a test email to verify everything works end-to-end:
Subject: Re: Order for 50 units of Widget Pro
Hi,
Please proceed with our order:
- 50x Widget Pro at $12.50 each
- 20x Gadget Basic at $8.00 each
Delivery by March 15 please.
Best regards,
John Smith
[email protected]
[email protected])email.received event) with Svix signature headersRESEND_WEBHOOK_SIGNING_SECRETRESEND_API_KEY)| Symptom | Cause | Fix |
|---|---|---|
| No email appears in the inbox log | Webhook not reaching your server | Verify the URL in Resend is correct and your server is publicly accessible. Check Resend webhook logs: Dashboard → Webhooks → click your webhook → Logs |
| HTTP 503 from webhook | Signing secret not set | Add RESEND_WEBHOOK_SIGNING_SECRET to .env and restart |
| HTTP 400 from webhook | Signing secret mismatch | Ensure RESEND_WEBHOOK_SIGNING_SECRET matches exactly (including whsec_ prefix) |
| "Failed to fetch Resend email" in logs | RESEND_API_KEY missing or invalid | Verify RESEND_API_KEY is set and has permission to read receiving emails |
| Email received but stuck in "received" status | AI provider not configured or API key invalid | Check OPENCODE_PROVIDER and the corresponding API key |
| Proposal created but no products matched | Your catalog is empty or product names differ | Add products to the catalog; the system does fuzzy matching on names and SKUs |
| HTTP 429 from webhook | Rate limit exceeded | Default limits: 10/min, 100/hour, 1000/day per inbox address |
| Same email not processed twice | Deduplication by message ID or content hash | This is intentional – each unique email is only processed once |
This section is a complete, step-by-step walkthrough for running InboxOps on your laptop against a real Resend account using an ngrok tunnel to expose the webhook endpoint. Allow about 15–20 minutes for the first-time setup.
(forwarded email)
[you] ───────────────────────▶ anything@<id>.resend.app
│
Resend servers (email.received)
│
(POST /api/inbox_ops/webhook/inbound)
▼
https://<slug>.ngrok-free.app
│ (ngrok tunnel)
▼
http://localhost:3000 (your dev server)
│
extraction worker + proposal
If any link in that chain is broken, the flow fails silently – the Troubleshooting Local Development section below maps each failure mode to its fix.
open-mercato-local.re_). You will paste it into .env in Step C.eldaaelkia.resend.app. Copy the full domain – you will reuse it as INBOX_OPS_DOMAIN.Note · Where is my free receiving domain?
If you do not see a *.resend.app entry on the Domains list, go to Emails → Receiving – Resend exposes it there as well. Any address you invent under that domain (for example [email protected]) is a valid receiving inbox.
Install ngrok: brew install ngrok on macOS, or follow https://ngrok.com/download for other platforms.
Create a free ngrok account, grab your authtoken from https://dashboard.ngrok.com/get-started/your-authtoken, and register it once:
ngrok config add-authtoken <your-token>
Start your Open Mercato dev server in one terminal:
yarn dev
By default it binds to http://localhost:3000.
Start the tunnel in a second terminal:
ngrok http 3000
ngrok prints a forwarding URL similar to:
Forwarding https://9e3a-203-0-113-42.ngrok-free.app -> http://localhost:3000
Copy the https://...ngrok-free.app URL. You will paste it into Resend in Step D.
Caution · ngrok URLs rotate
A free ngrok URL changes every time you restart the tunnel. You will need to update the Resend webhook URL (Step D) each time. For a stable URL, claim a reserved domain under Cloud Edge → Domains in the ngrok dashboard and run ngrok http --domain=<your>.ngrok-free.app 3000.
Open apps/mercato/.env (or copy from apps/mercato/.env.example if it does not exist yet) and set the following block. Uncomment the keys, do not leave the sample # prefix:
# ----- InboxOps (Resend + ngrok local dev) -----
RESEND_API_KEY="<resend-api-key>"
RESEND_WEBHOOK_SIGNING_SECRET="<resend-webhook-signing-secret>"
INBOX_OPS_DOMAIN=eldaaelkia.resend.app
# AI provider — pick one
OPENCODE_PROVIDER=anthropic
ANTHROPIC_API_KEY="<anthropic-api-key>"
# OPENAI_API_KEY="$OPENAI_API_KEY"
# GOOGLE_GENERATIVE_AI_API_KEY="$GOOGLE_GENERATIVE_AI_API_KEY"
Leave RESEND_WEBHOOK_SIGNING_SECRET empty for now – Resend will give it to you in Step D, and you will restart the dev server after filling it in.
Tip · Prefer HMAC mode for offline tests?
If you only need to exercise the webhook without involving Resend (for example in CI or during automated E2E), set INBOX_OPS_WEBHOOK_SECRET=<any-long-string> and use scripts/test-inbox-webhook*.sh instead. The endpoint accepts either mode as long as at least one secret is configured. See Developer Testing.
In Resend, open Webhooks → Add Webhook.
Endpoint URL: paste your ngrok URL with the webhook path appended:
https://9e3a-203-0-113-42.ngrok-free.app/api/inbox_ops/webhook/inbound
Events: select email.received. You can leave other events unchecked for now.
Click Create. Resend shows the webhook detail page with a Signing secret that starts with whsec_.
Copy the signing secret and paste it into your .env as RESEND_WEBHOOK_SIGNING_SECRET.
Restart the dev server (Ctrl+C, then yarn dev again) so the new secret is picked up.
Note · Screenshots
If you want visual references while following along, capture the Resend API Keys, Domains (or Emails → Receiving), and Webhooks → Edit Webhook screens, plus the ngrok terminal output showing the Forwarding line. These screens are the only five places where a misconfiguration can happen, and each has a unique visible field (API key prefix, domain value, webhook URL, signing secret, ngrok forwarding URL) that maps 1:1 to the env vars above.
Open Mercato generates the tenant's inbox address at tenant setup time using whatever INBOX_OPS_DOMAIN was set then. If you changed INBOX_OPS_DOMAIN (for example because you used the default inbox.mercato.local on first boot), the address stored in inbox_settings.inbox_address will still point at the old domain and Resend traffic will never match it.
Check the current address:
SELECT id, inbox_address, is_active
FROM inbox_settings
WHERE deleted_at IS NULL;
If the domain does not match your INBOX_OPS_DOMAIN, update it:
UPDATE inbox_settings
SET inbox_address = REPLACE(inbox_address, 'inbox.mercato.local', 'eldaaelkia.resend.app'),
updated_at = NOW()
WHERE deleted_at IS NULL;
Replace both strings with the values that match your setup. You can also edit it from the admin UI: Inbox Ops → Settings shows the current address, but the domain part is only editable by rewriting the row directly until automatic resync is implemented.
After updating, refresh the admin UI and confirm the inbox address displayed on Inbox Ops → Settings matches ops-<slug>@<INBOX_OPS_DOMAIN>.
POST /api/inbox_ops/webhook/inbound 200 OK. No line here means Resend never sent the webhook (usually a Resend-side config issue).inbox_ops.webhook.received and inbox_ops.extraction.completed. Errors like Failed to fetch Resend email or Inbox address not found are logged here.If nothing lands in the UI, Resend's own Webhooks → Logs tab shows you the HTTP status code it saw when it called your ngrok URL. This is the single most useful debugging signal – see the next section.
Use this table in addition to the general Troubleshooting table – the failure modes below are specific to local tunnelled setups.
| Symptom | Likely cause | Fix |
|---|---|---|
| Resend webhook log shows 200 OK but no proposal appears in the UI | The inbox address on the email does not match any inbox_settings.inbox_address for an active tenant (silent accept). | Run the SQL from Step E and confirm the domain matches INBOX_OPS_DOMAIN. Then re-forward the email – old deliveries are deduplicated by message ID and will not replay. |
| Resend webhook log shows repeated connection refused or 502 errors | ngrok is not running, or its URL changed and Resend is still calling the old one. | In the ngrok terminal, copy the current Forwarding URL and update the Resend webhook endpoint in Webhooks → Edit. Restart ngrok with a reserved domain if this happens often. |
Resend webhook log shows 503 with RESEND_WEBHOOK_SIGNING_SECRET not configured | The dev server started before you filled in the secret. | Fill RESEND_WEBHOOK_SIGNING_SECRET in .env, stop yarn dev with Ctrl+C, then start it again. |
Resend webhook log shows 400 with invalid signature | Signing secret mismatch – common after recreating the webhook in Resend. | Copy the current signing secret from Webhooks → Edit → Signing secret, replace it in .env, and restart the dev server. |
Dev server logs Failed to fetch Resend email after a 200 webhook | RESEND_API_KEY is missing, expired, or lacks permission to read received emails. | Regenerate the key in Resend with full access, paste it into .env, and restart. |
Dev server logs Inbox address not found right after a valid signature | The email was sent to a @<domain> that is not the tenant's configured inbox_address. | Either send the test email to the address shown on Inbox Ops → Settings, or rewrite inbox_settings.inbox_address to match the domain you are actually using. |
Email lands but stays stuck at status received; no extraction runs | AI provider misconfigured – no OPENCODE_PROVIDER or the matching API key is empty. | Set OPENCODE_PROVIDER and its API key (ANTHROPIC_API_KEY, OPENAI_API_KEY, or GOOGLE_GENERATIVE_AI_API_KEY), restart, then click Reprocess on the proposal. |
| Forwarding the same email twice does nothing the second time | Deduplication by message ID / content hash is intentional. | Change the email body (even a single character) before re-forwarding, or reprocess the existing proposal from the admin UI. |
| ngrok shows the request but the dev server logs nothing | Dev server is not bound to localhost:3000, or you tunnelled the wrong port. | Confirm the port in the yarn dev output and restart ngrok http <port> accordingly. |
The webhook endpoint is protected by multiple layers:
Svix signature verification – Every Resend webhook request includes svix-id, svix-timestamp, and svix-signature headers. The handler verifies these against your RESEND_WEBHOOK_SIGNING_SECRET. Without the secret, requests are rejected.
Replay protection – Svix signatures include a timestamp; the verification rejects expired signatures.
Rate limiting – Even valid requests are throttled per inbox address (10/min, 100/hour, 1000/day).
Payload size limit – Requests larger than 2MB are rejected (HTTP 413).
Deduplication – Emails with the same message ID or content hash are only processed once, preventing accidental re-processing.
If someone discovers and emails your inbox address, Resend will legitimately deliver it as a webhook (with a valid signature). The email will be processed.
The inbox address is obscure by design – it contains a random slug from your organization ID, making it impractical to guess. For additional protection:
Inbox Ops uses feature-based access control:
| Permission | Who gets it by default | What it allows |
|---|---|---|
inbox_ops.proposals.view | Admin, Employee | View proposals and their actions |
inbox_ops.proposals.manage | Admin, Employee | Accept/reject/edit proposal actions |
inbox_ops.settings.manage | Admin | Change inbox settings (working language, active status) |
inbox_ops.log.view | Admin | View the email processing log |
inbox_ops.replies.send | Admin, Employee | Send draft replies via email |
Superadmins have all permissions (inbox_ops.*).
When a proposal is created, the system sends in-app and email notifications to users who have the inbox_ops.proposals.manage permission. To configure email delivery:
/backend/config/notifications)Once set up, the typical workflow for your team is:
Tip · Translation
If your team works in a language different from the emails, configure a working language in Inbox Ops → Settings. The system will translate AI summaries and action descriptions to your preferred language. You can also translate individual proposals on demand from the proposal detail page.
For local development and automated testing, the webhook also supports a custom HMAC-SHA256 mode alongside the Resend/Svix mode. See the test scripts in scripts/test-inbox-webhook*.sh for details.
To enable both modes simultaneously, set both secrets:
INBOX_OPS_WEBHOOK_SECRET="<inbox-ops-webhook-secret>" # for test scripts
RESEND_WEBHOOK_SIGNING_SECRET="<resend-webhook-signing-secret>" # for real Resend webhooks
At least one of these must be configured for the webhook endpoint to be active.
Previous: Manage feature toggles · Next: Integration Marketplace