Platform Integrations
ecommerce
How to Build a Shopify Order Notification System
Get real-time notifications for Shopify orders, returns, and inventory.
Jay Banlasan
The AI Systems Guy
I build shopify order notification automation system systems that give store owners instant visibility into orders, returns, and inventory. This automation runs in the background so you can focus on growth instead of operational tasks.
What You Need
- Python 3.9+ or Node.js 18+
- Shopify API credentials
- A notification channel (Slack, email, or SMS)
Step 1: Connect to the Shopify API
import requests
import os
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv("SHOPIFY_API_KEY")
SHOP_URL = os.getenv('SHOPIFY_STORE_URL')
headers = {
'X-Shopify-Access-Token': API_KEY,
"Content-Type": "application/json"
}
def fetch_data(endpoint, params=None):
url = f'https://{SHOP_URL}/admin/api/2024-01/{endpoint}.json'
response = requests.get(url, headers=headers, params=params or {})
return response.json()
Step 2: Build the Processing Logic
from datetime import datetime
import json
def process_items(items):
results = []
for item in items:
processed = {
"id": item.get("id"),
"name": item.get("name", item.get("title", "")),
"status": item.get("status", ""),
"amount": item.get("total_price", item.get("amount", 0)),
"processed_at": datetime.now().isoformat()
}
results.append(processed)
return results
Step 3: Set Up Notifications
def send_notification(message):
slack_token = os.getenv("SLACK_BOT_TOKEN")
channel = os.getenv("ECOM_CHANNEL")
requests.post("https://slack.com/api/chat.postMessage",
headers={"Authorization": f"Bearer {slack_token}"},
json={"channel": channel, "text": message})
def notify_batch(processed_items):
for item in processed_items:
msg = f"*{item['name']}* | Status: {item['status']} | ${item['amount']}"
send_notification(msg)
print(f"Sent {len(processed_items)} notifications")
Step 4: Add Webhook Handler
from flask import Flask, request
app = Flask(__name__)
@app.route("/webhook/shopify", methods=["POST"])
def handle_webhook():
data = request.json
processed = process_items([data])
notify_batch(processed)
return "OK", 200
Step 5: Run on Schedule
import sqlite3
def log_run(action, count):
conn = sqlite3.connect("ecom_automation.db")
conn.execute("""CREATE TABLE IF NOT EXISTS runs (
action TEXT, count INTEGER, ran_at TEXT
)""")
conn.execute("INSERT INTO runs VALUES (?, ?, ?)",
(action, count, datetime.now().isoformat()))
conn.commit()
def main():
data = fetch_data("orders", {"status": "any", "limit": 50})
items = data.get("orders", data.get("data", []))
processed = process_items(items)
notify_batch(processed)
log_run("Shopify order notifications", len(processed))
main()
What to Build Next
Add a dashboard in Google Sheets that shows Shopify order notifications trends over time. Connect it to the webhook handler so data flows in real time, not just on schedule.
Related Reading
- Building Your First Automation: A Complete Guide - how to pick the right automation approach for your business
- The Notification System Design - getting the right alerts to the right people
- Building a Reconciliation System - practical guidance for building AI-powered business systems
Want this system built for your business?
Get a free assessment. We will map every system your business needs and show you the ROI.
Get Your Free Assessment