CORTEXFLOW · FREE FOREVER

Automation

Shopify AI Support Agent

↓ Download workflow JSON

Import in n8n: Workflows → ⋯ → Import from file, then add your credentials. Free download with a free account.

How it works

Your always-on support desk for your Shopify store — routine questions get answered in seconds, money questions wait for a human:

  1. STEP 1 — New email → extract order number — a Gmail trigger polls your support inbox every minute. A regex pulls the order number from the subject/body (#1234 or order 1234). Emails without one keep flowing — the order lookup just comes back empty.
  2. STEP 2 — Log to Sheets + Shopify lookup — every email is appended to the Support Inbox tab with status RECEIVED, then the order number is looked up in Shopify. The lookup swallows errors (unknown number, API hiccup) so triage never blocks.
  3. STEP 3 — AI triage with structured output — an AI Agent reads the email plus the order JSON and returns a structured verdict via a Structured Output Parser: intent (order_status / policy_question / refund_request / order_change / other), confidence 0–100, a ready-to-send draft reply, a needs_human flag, and a one-line order summary. The sheet flips to TRIAGED.
  4. STEP 4 — Route: auto-reply / human draft / Slack — Compute Routing sets two flags: auto_resolvable (routine intent AND confidence ≥ threshold AND no human flag) and money_involved (refund/change intent or flagged). Auto-resolvable → Gmail sends the reply, sheet flips to AUTO_RESOLVED. Money-involved → a Gmail draft is created for a human to review and send, sheet flips to DRAFT_CREATED. Everything else → a rich Slack alert lands in your support channel, sheet flips to ESCALATED.
  5. STEP 5 — Digest notification — all three branches merge and one Telegram summary goes out: how many emails were triaged, plus auto-resolved / drafts / escalated counts.

Status flow in Sheets: RECEIVED → TRIAGED → AUTO_RESOLVED / DRAFT_CREATED / ESCALATED

Set up steps

You’ll need:

  • n8n (self-hosted or cloud)
  • Gmail OAuth2 credential for your support inbox — n8n Credentials → Gmail OAuth2 API (connect the account that receives support mail)
  • Shopify Admin API access token with the read_orders scope — your store admin → Apps and sales channels → Develop apps → Create a custom app → Configure Admin API access scopes → install and copy the token
  • An OpenAI API key — platform.openai.com → API keys
  • Google Sheets OAuth2 credential — n8n Credentials → Google Sheets OAuth2 API
  • A Slack bot token — api.slack.com → Create app → OAuth & Permissions → add chat:write, invite the bot to your support channel
  • A Telegram bot — message @BotFather, send /newbot, copy the token; get your chat ID from @userinfobot

Steps:

  1. Import the workflow — in n8n, Workflows → Import from File → select shopify-ai-support-agent.json.
  2. CONFIG — Shop — open the Set node and fill in:
    • shop_domain — e.g. your-shop.myshopify.com
    • support_email — the inbox address the workflow monitors
    • confidence_threshold — minimum AI confidence (0–100) before an email is auto-answered (80 is a safe start)
  3. Google Sheet — create a Google Sheet with a tab named Support Inbox and these exact headers: Date | From | Subject | Order Number | Intent | Confidence | Status | Resolution Note. Select your Google Sheets credential in all four Sheets nodes (the node picks the sheet after you connect).
  4. CONFIG — AI — set openai_model (default gpt-4o-mini), and select your OpenAI credential in the OpenAI Chat Model — Triage node.
  5. CONFIG — Notifications — paste your telegram_chat_id and your slack_channel (e.g. support-alerts), select your Telegram and Slack credentials in their nodes.
  6. Credentials on the action nodes — select your Gmail credential in Gmail — Send Reply and Gmail — Create Draft for Human, and your Shopify credential in Shopify — Get Order. Then activate the workflow.

Customize it

  • Stricter auto-replies — raise confidence_threshold to 90+ in CONFIG — Shop so the AI answers only when it’s very sure; borderline emails fall through to drafts or Slack.
  • Different mailbox — point the Gmail trigger at a dedicated address (e.g. [email protected]) and add a trigger filter so marketing/newsletter mail never enters the flow.
  • More intents — extend the parser schema and the Compute Routing code with your own categories (e.g. wholesale_inquiry) and wire them to a new IF branch.
  • Kill the money risk entirely — remove the auto-reply branch and route everything to drafts while you calibrate; flip the IF back on once you trust the confidence scores.
  • Escalation instead of Slack — swap the Slack node for WhatsApp, SMS, or a PagerDuty-style webhook; the routing logic doesn’t change.
  • Log replies for QA — add an Auto Reply Text column to the sheet and write output.draft_reply into it in Update Sheet — AUTO_RESOLVED so you can audit what the AI sent.
  • Cheaper triage — gpt-4o-mini is already the default; for high volume, pre-filter obvious spam with an extra IF on subject keywords before the agent runs.

Workflow nodes

This workflow is built from 24 nodes. Here's what each one does:

#NodeTypeWhat it does
1 New Support Email Gmail Trigger Starts the workflow when a new email arrives in Gmail.
2 CONFIG — Shop Set Holds editable configuration values — fill in your own settings here before activating.
3 Extract Order Number Code Runs custom JavaScript to transform, filter, or compute data between steps.
4 Log Email — RECEIVED Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
5 Shopify — Get Order Shopify Reads or updates data in your Shopify store.
6 Merge Order Context Code Runs custom JavaScript to transform, filter, or compute data between steps.
7 CONFIG — AI Set Holds editable configuration values — fill in your own settings here before activating.
8 AI Agent — Triage Support Email AI Agent The AI brain — reasons over the task and calls tools to get it done.
9 OpenAI Chat Model — Triage OpenAI Chat Model The language model powering the AI agent.
10 Structured Output Parser — Triage Structured Output Parser Forces the AI to return clean, structured JSON instead of free text.
11 Compute Routing Code Runs custom JavaScript to transform, filter, or compute data between steps.
12 Update Sheet — TRIAGED Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
13 CONFIG — Notifications Set Holds editable configuration values — fill in your own settings here before activating.
14 IF — Auto-Resolvable? IF Splits the flow into branches based on a condition.
15 Gmail — Send Reply Gmail Sends or reads email through your Gmail account.
16 Update Sheet — AUTO_RESOLVED Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
17 IF — Money Involved? IF Splits the flow into branches based on a condition.
18 Gmail — Create Draft for Human Gmail Sends or reads email through your Gmail account.
19 Update Sheet — DRAFT_CREATED Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
20 Slack — Alert Support Channel Slack Posts messages or reads data in Slack.
21 Update Sheet — ESCALATED Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
22 Merge — Combine Branches Merge Combines the outputs of two or more branches back into one flow.
23 Build Summary Code Runs custom JavaScript to transform, filter, or compute data between steps.
24 Telegram — Send Summary Telegram Sends you a Telegram message or alert.

Setup instructions

1. Add your credentials

In n8n go to Credentials → New, create each credential below, then open the named node and select it:

NodeCredential to add
New Support Email Gmail OAuth2
Log Email — RECEIVED Google Sheets OAuth2
Shopify — Get Order Shopify API
OpenAI Chat Model — Triage OpenAI API
Update Sheet — TRIAGED Google Sheets OAuth2
Gmail — Send Reply Gmail OAuth2
Update Sheet — AUTO_RESOLVED Google Sheets OAuth2
Gmail — Create Draft for Human Gmail OAuth2
Update Sheet — DRAFT_CREATED Google Sheets OAuth2
Slack — Alert Support Channel Slack API (token)
Update Sheet — ESCALATED Google Sheets OAuth2
Telegram — Send Summary Telegram Bot API

2. Fill in your config values

Open the config node listed below and replace each placeholder with your own value before activating the workflow:

NodeFieldWhat to paste
CONFIG — Shop shop_domain PASTE_YOUR_SHOP_DOMAIN
Your shop domain
CONFIG — Shop support_email PASTE_YOUR_SUPPORT_EMAIL
Your support email
CONFIG — Notifications telegram_chat_id PASTE_YOUR_TELEGRAM_CHAT_ID
Your telegram chat id
CONFIG — Notifications slack_channel PASTE_YOUR_SLACK_CHANNEL
Your slack channel

How this workflow starts

  • Gmail Trigger: Fires automatically on its event — activate the workflow and connect the service.

Use cases

Support email for a Shopify store follows a cruel pattern: most messages are routine, where is my order and shipping questions, and a minority are refund and money questions where one wrong automatic reply costs real money. This template splits the two and never confuses them. A Gmail trigger watches the support inbox every minute. Extract Order Number pulls the order number from the subject or body with a regex, every email is logged to a Support Inbox sheet with status RECEIVED, and Shopify Get Order fetches the real order behind it. Then an AI Agent with a Structured Output Parser returns a strict verdict: intent, a confidence score from 0 to 100, a draft reply, a needs-human flag, and a one-line order summary. Compute Routing turns that verdict into two flags: auto resolvable, meaning a routine intent with confidence at or above the threshold and no human flag, and money involved, meaning a refund or change intent. Auto-resolvable mail gets an instant Gmail reply and the sheet flips to AUTO RESOLVED. Money-involved mail becomes a Gmail draft waiting for a human, and the sheet flips to DRAFT CREATED. Everything else raises a rich Slack alert in the support channel and the sheet flips to ESCALATED. All three branches merge into one Telegram summary with the triaged, auto-resolved, draft, and escalated counts. It is built for store owners who want instant replies without ever letting the AI touch money.

The solo founder buried in where is my order

A founder selling skincare does about 150 orders a day and used to answer email at midnight. Eighty percent of the inbox is order status questions with the order number right in the subject line. The workflow extracts it, Shopify Get Order returns the tracking state, and the AI drafts a correct reply that goes out in under a minute. The confidence threshold in CONFIG Shop starts at 80, so borderline mail falls through to a human.

  • Variation: add an Auto Reply Text column to the sheet and write the sent draft into it at Update Sheet AUTO RESOLVED, so there is a permanent audit trail of exactly what the AI told each customer.

The print-on-demand store at four hundred emails a day

A print-on-demand shop selling custom mugs and tees gets crushed every holiday season: hundreds of where is my order and what is your return policy emails daily, mixed with genuine refund requests for misprinted items. The routine intents auto-resolve around the clock, while refund request and order change intents always land as Gmail drafts.

  • Variation: raise the confidence threshold to 90 during peak season so the AI answers only when it is very sure, and let the extra volume fall through to drafts rather than risk a bad auto-reply.

The three-person support team protecting its SLAs

A small team supporting a mid-size fashion store has a four-hour first-response SLA and no night shift. The Slack escalation branch is their safety net: anything the AI cannot confidently resolve posts to the support channel with the order summary attached, so the morning shift triages from Slack instead of re-reading the inbox.

  • Variation: point the Gmail trigger at a dedicated support address and filter out marketing and newsletter mail before it ever enters the flow, so the AI never wastes a triage on a promo blast.

The international store drowning in shipping questions

A store shipping to forty countries gets the same questions daily: how long to Germany, who pays customs, what if the parcel is stuck. These are policy questions with stable answers, ideal for auto-resolution once the AI has the policy text in its context. Lost-parcel cases, where the answer might involve reshipping at the store's cost, stay firmly in the draft branch: the human sees the AI's draft and the one-line order summary, edits if needed, and sends.

  • Variation: extend the parser schema and Compute Routing with a wholesale inquiry intent wired to its own branch, so B2B mail skips the consumer flow entirely.

The new store owner calibrating trust

A first-time founder loves the idea of auto-replies and fears them in equal measure. The template has a built-in calibration mode: remove the auto-reply branch and route everything to drafts while the store is new. Once the scores earn trust, the IF branch goes back on and routine mail starts resolving itself.

  • Variation: pre-filter obvious spam with an extra IF on subject keywords before the agent runs, so junk mail never spends OpenAI tokens or pollutes the triage counts.

← All templates