DEV Community

Brad
Brad

Posted on

Stop Paying for Zapier: Build Your Own Automation Hub With Python and Flask

Zapier costs $49-250/month. You can replace it with 200 lines of Python running on a $5 server.

Here's how to build your own automation hub that handles webhooks, triggers actions, and connects any service with an API.

Why Zapier Costs So Much

Zapier charges per "task" (each action triggered). At 1,000 tasks/month — trivial for any active business — you're on the $49/month plan minimum.

Your own Flask webhook server costs $5/month or $0 if you have a server.

The Architecture

External Service → Webhook POST → Flask Server → Action Handler → Done
Enter fullscreen mode Exit fullscreen mode

That's it. Zapier is just a hosted version of this pattern.

Building the Webhook Hub

from flask import Flask, request, jsonify
import logging

app = Flask(__name__)
logging.basicConfig(level=logging.INFO)
handlers = {}

def register(trigger_name):
    # Decorator to register webhook handlers
    def decorator(func):
        handlers[trigger_name] = func
        return func
    return decorator

@app.route("/webhook/<trigger>", methods=["POST"])
def handle_webhook(trigger):
    data = request.get_json(silent=True) or request.form.to_dict()

    if trigger not in handlers:
        return jsonify({"error": f"Unknown trigger: {trigger}"}), 404

    try:
        result = handlers[trigger](data)
        logging.info(f"Trigger '{trigger}' executed")
        return jsonify({"status": "ok", "result": str(result)})
    except Exception as e:
        return jsonify({"error": str(e)}), 500

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5000)
Enter fullscreen mode Exit fullscreen mode

Handler Examples

@register("new_contact")
def on_new_contact(data):
    name = data.get("name", "there")
    email = data.get("email")
    add_to_crm(name, email)
    send_welcome_email(email, name)
    notify_slack(f"New contact: {name} ({email})")
    return f"Processed: {name}"

@register("payment_received")
def on_payment(data):
    invoice_id = data.get("invoice_id")
    mark_invoice_paid(invoice_id)
    send_receipt(data.get("client"), data.get("amount"))
    return f"Invoice {invoice_id} marked paid"

@register("github_push")
def on_github_push(data):
    repo = data["repository"]["name"]
    pusher = data["pusher"]["name"]
    trigger_ci(repo)
    notify_slack(f"{pusher} pushed to {repo}")
    return "CI triggered"
Enter fullscreen mode Exit fullscreen mode

Deployment

pip install flask gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:app --daemon
Enter fullscreen mode Exit fullscreen mode

Connecting External Services

Point any service's webhook URL to your server:

  • GitHub: Settings → Webhooks → https://yourdomain.com/webhook/github_push
  • Stripe: Dashboard → Webhooks → https://yourdomain.com/webhook/payment_received
  • HTML Forms: action="https://yourdomain.com/webhook/new_contact"

The Full Stack

This webhook hub plus 45+ more automation scripts (invoicing, client reporting, email automation, business dashboards) are in the Python Business Automation Toolkit.

No monthly subscription. No vendor lock-in. Full control.

Top comments (0)