How to Automate Email Processing with Webhooks

Replace manual email handling with a fully automated pipeline. JsonHook converts inbound email into webhook events your application can act on instantly — no polling, no manual sorting.

Table of Contents
  1. Overview
  2. Prerequisites
  3. Step-by-Step Instructions
  4. Code Example
  5. Common Pitfalls

Overview

Email processing automation means replacing the human step of reading, categorizing, and acting on email with code. When an order confirmation arrives, your system automatically extracts the order number and updates your database. When a lead submits a form that generates an email notification, your CRM record is created without human intervention.

The key enabler is a reliable mechanism to convert inbound email into application events — which is exactly what JsonHook provides. By assigning a unique @in.jsonhook.com address to each automation workflow and routing emails to webhook handlers, you build pipelines that are:

  • Real-time: Processing happens within seconds of email receipt, not during the next manual review cycle
  • Reliable: HMAC-signed deliveries with automatic retry ensure no emails are lost
  • Auditable: Every delivery is logged with request/response details in the JsonHook delivery log
  • Scalable: The same architecture handles 10 emails a day or 100,000 emails a month

Prerequisites

For a complete email automation pipeline you will need:

  • A JsonHook account and API key
  • One or more inbound addresses (one per automation workflow is a clean pattern)
  • A web server or serverless function to host your webhook handlers
  • A database or downstream service to store or act on the extracted email data
  • Optionally: a message queue (e.g., Redis + BullMQ, SQS, RabbitMQ) for high-volume or CPU-intensive processing

For low-code automation, you can also route JsonHook webhooks to Zapier, Make, or n8n and build workflows without writing a handler yourself.

Automate Your Email Workflows Today

Every inbound email becomes a webhook event. Start free — no credit card needed.

Get Free API Key

Step-by-Step Instructions

Build an automated email processing pipeline with these steps:

  1. Map your email flows. List every email type you want to process: order confirmations, lead alerts, invoice PDFs, support requests, etc. Each flow gets its own JsonHook address and handler.
  2. Create a JsonHook address for each flow via the API, pointing to the appropriate handler URL.
  3. Route email sources. Update your forms, integrations, and forwarding rules to send relevant emails to the corresponding JsonHook address instead of a human mailbox.
  4. Implement each webhook handler. Each handler receives a POST with the parsed email JSON, extracts the relevant fields, and performs the automated action (DB write, API call, notification).
  5. Add idempotency. Store processed deliveryId values in a set or database to safely handle retried deliveries without side effects.
  6. Monitor via delivery logs. Use the JsonHook API to query delivery history and alert on repeated failures, which indicate issues with your handler or downstream systems.

Code Example

This example shows an automated order confirmation processor in Node.js that parses an order number from the email subject and updates a database:

import express from "express";
import crypto from "crypto";
import { db } from "./db";

const app = express();
app.use(express.raw({ type: "application/json" }));

app.post("/webhooks/orders", async (req, res) => {
  // Verify signature
  const sig = req.headers["x-jsonhook-signature"];
  const expected = crypto
    .createHmac("sha256", process.env.JSONHOOK_SECRET!)
    .update(req.body).digest("hex");
  if (sig !== expected) return res.sendStatus(401);

  const { email, deliveryId } = JSON.parse(req.body.toString());

  // Idempotency check
  const already = await db.deliveries.findOne({ deliveryId });
  if (already) return res.sendStatus(200);
  await db.deliveries.insert({ deliveryId });

  // Extract order number from subject: "Order #12345 Confirmed"
  const match = email.subject.match(/Order #(d+)/i);
  if (match) {
    const orderId = match[1];
    await db.orders.update({ id: orderId }, { status: "confirmed" });
    console.log(`Order ${orderId} confirmed via email`);
  }

  res.sendStatus(200);
});

app.listen(3000);

Common Pitfalls

Automation pipelines fail silently if you are not careful. Avoid these issues:

  • No idempotency. Webhook handlers can be called multiple times for the same email (retries). Always check the deliveryId before performing side effects.
  • Brittle subject-line parsing. Email subjects change format over time. Where possible, use the sender address, custom headers, or the recipient address for routing decisions rather than parsing subject text.
  • No dead-letter handling. When a delivery fails all retries, it ends up in your JsonHook failed delivery log. Set up a daily alert or monitoring dashboard to catch and investigate these failures promptly.
  • Processing everything in the webhook handler. For anything taking more than a second, push a job to a queue and return 200. Long-running webhook handlers lead to timeouts and unnecessary retries.
  • No test environment. Create a separate JsonHook address pointing to a staging webhook for each flow so you can test with real emails before going live.

Frequently Asked Questions

Can I automate email processing without writing code?

Yes. Route your JsonHook webhook to a no-code tool like Zapier, Make, or n8n. These platforms receive the JSON payload and let you build multi-step automation workflows visually — creating CRM records, sending Slack messages, updating spreadsheets, etc. — without writing a custom handler.

How do I handle multiple email formats from the same sender?

Use the email.from address and email.subject together in a routing decision within your handler, or create separate JsonHook addresses for different email types and ask senders to use different To addresses. Per-address routing is the most reliable approach.

What is the best way to monitor my automation pipeline?

Query the JsonHook delivery log API regularly for failed deliveries and alert your team. Also instrument your webhook handler with application-level logging and track success/failure metrics. Services like Datadog, Grafana, or even a simple cron job checking the delivery log work well.

Can I replay failed deliveries after fixing my handler?

Yes. From the JsonHook dashboard or API you can trigger a manual replay of any delivery in your log. This is especially useful after fixing a bug in your handler — you can replay all failures from the affected time window without re-sending the original emails.