Automate first responses to Gorgias support tickets using n8n
Install this workflow
Download the n8n workflow JSON and import it into your n8n instance.
first-response.n8n.jsonPrerequisites
- n8n instance (cloud or self-hosted)
- Gorgias account with REST API access
- Gorgias API credentials: account email and API key
- Pre-written response text for each question type you want to automate
Why n8n?
n8n lets you enrich auto-replies with real-time data that Gorgias Macros can't access. Instead of sending a generic "track your order here" link, you can fetch the customer's actual shipping status from Shopify and include the real tracking URL and delivery estimate in the reply. This makes auto-replies feel personal rather than templated.
n8n also gives you more routing flexibility — you can build multi-step logic that checks order value, customer segment, or ticket channel before deciding which reply to send. Self-hosted n8n is completely free. n8n Cloud starts at $24/mo.
How it works
- Gorgias HTTP integration sends a webhook to n8n when a new ticket is created
- Code node extracts ticket text, verifies no agent has replied yet, and normalizes the content
- Switch node routes the ticket to the correct reply branch based on keyword matching
- Set nodes define the reply body for each question type (optionally enriched with Shopify data)
- HTTP Request node posts the reply to the Gorgias ticket via API with
from_agent: trueto stop the SLA clock - HTTP Request node tags the ticket
auto-repliedfor quality monitoring
Overview
This workflow receives new Gorgias tickets via webhook, identifies whether the question matches a known pattern, and posts a reply directly to the ticket via the Gorgias API. Unlike Gorgias native Macros, this approach lets you enrich replies with real-time data — for example, fetching an order's actual shipping status from Shopify before sending the response.
Step 1: Set up the Webhook trigger
Add a Webhook node:
- HTTP Method: POST
- Path:
gorgias-auto-reply
Copy the webhook URL.
Step 2: Register the webhook in Gorgias
Go to Settings → Integrations → HTTP → Add HTTP integration:
- Name: n8n Auto-Reply
- URL: Your n8n webhook URL
- Events: Ticket created
- Content-Type:
application/json
Step 3: Extract text and check if it's a first message
Add a Code node to normalize the ticket data and verify it needs an auto-reply:
const ticket = $input.first().json;
// Only process tickets with no agent reply yet
const hasAgentReply = (ticket.messages || []).some(m => m.source?.type === 'helpdesk');
if (hasAgentReply) {
return []; // stop processing — ticket already has a reply
}
const subject = (ticket.subject || '').toLowerCase();
const body = (ticket.messages?.[0]?.body_text || '').toLowerCase();
const combined = `${subject} ${body}`;
const customerName = ticket.requester?.firstname || 'there';
return [{
json: {
ticketId: ticket.id,
customerName,
text: combined,
shouldReply: true,
}
}];Step 4: Identify the question type
Add a Switch node to route to the appropriate reply:
Value: {{ $json.text }}
Cases:
| # | Keywords (any match) | Route to |
|---|---|---|
| 1 | where is my order, tracking, order status, when will it arrive | Order Status reply |
| 2 | return, send back, exchange, how do i return | Returns reply |
| 3 | refund, money back, charged, when will i get my refund | Refund reply |
| 4 | cancel, change my order, wrong address, wrong item | Order Change reply |
| 5 | ship to, international, how long does shipping | Shipping Info reply |
| Default | (no match) | Skip auto-reply |
Step 5: Build reply bodies for each route
For each Switch route, add a Set node with the reply text. Here's the order status example:
Set node: Order Status Reply
- Field
replyBody=
Hi {{ $('Code').item.json.customerName }},
Thanks for reaching out! You can track your order in real time here:
👉 https://yourstore.com/tracking
You'll need your order number and the email used at checkout. Tracking typically updates within 24 hours of your order shipping.
If you have any trouble finding it, reply here and we'll look into it right away.
Best,
The Support TeamCreate a similar Set node for each other route (returns, refund, cancel, shipping info).
For the order status reply, add an HTTP Request to the Shopify Orders API before the reply step — fetch the customer's most recent order and inject the real tracking URL and status. This makes auto-replies feel far more personal than a generic tracking page link.
Step 6: Post the reply to Gorgias
After each Set node, add an HTTP Request node to post the reply:
- Method: POST
- URL:
https://your-store.gorgias.com/api/tickets/{{ $('Code').item.json.ticketId }}/messages - Authentication: Basic Auth (Gorgias email + API key)
- Body (JSON):
{
"body_text": "{{ $json.replyBody }}",
"body_html": "<p>{{ $json.replyBody | replace: '\n', '</p><p>' }}</p>",
"channel": "email",
"from_agent": true,
"source": {
"type": "helpdesk",
"from": {
"name": "Support Team",
"address": "support@yourstore.com"
}
}
}Gorgias treats messages with from_agent: true as agent replies, which stops the first-response SLA timer. This is exactly what you want — but double-check that your SLA reporting tool picks up automated replies if you track that metric.
Step 7: Tag the ticket as auto-replied
After posting the reply, add one more HTTP Request to tag the ticket:
- Method: PUT
- URL:
https://your-store.gorgias.com/api/tickets/{{ $('Code').item.json.ticketId }} - Body:
{ "tags": [{ "name": "auto-replied" }] }
This lets you create a Gorgias View for auto-replied tickets so you can audit quality.
Step 8: Activate and monitor
- Add Retry On Fail on all HTTP Request nodes
- Create a test ticket in Gorgias for each question type
- Verify the reply arrives in the ticket thread within a few seconds
- Toggle to Active
Troubleshooting
Common questions
Does the auto-reply stop the SLA timer in Gorgias?
Yes, if you set from_agent: true in the message POST body. Gorgias treats messages with this flag as agent replies and stops the first-response SLA clock. Make sure your SLA reporting tool accounts for automated replies if you track that metric separately.
Can I add Shopify order data to the reply?
Yes. Add an HTTP Request node before the reply step that calls the Shopify Orders API to fetch the customer's most recent order. Inject the real tracking URL and status into the reply body. This is the main advantage of the n8n approach over native Gorgias Macros.
What happens if the Switch node doesn't match any keyword?
The default branch fires. You can either skip the auto-reply entirely (let the ticket go to the normal queue) or send a generic acknowledgment like "Thanks for reaching out — we'll get back to you within [SLA target]." The latter still reduces perceived wait time.
Cost
- n8n Cloud: ~8 node executions per auto-replied ticket. 300 auto-replies/month = ~2,400 executions.
- Self-hosted: Free.
Looking to scale your AI operations?
We build and optimize automation systems for mid-market businesses. Let's discuss the right approach for your team.