Automate first responses to Gorgias support tickets using n8n

medium complexityCost: $0-24/mo

Prerequisites

Prerequisites
  • 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

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 → HTTPAdd 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
1where is my order, tracking, order status, when will it arriveOrder Status reply
2return, send back, exchange, how do i returnReturns reply
3refund, money back, charged, when will i get my refundRefund reply
4cancel, change my order, wrong address, wrong itemOrder Change reply
5ship to, international, how long does shippingShipping 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 Team

Create a similar Set node for each other route (returns, refund, cancel, shipping info).

Enrich with live Shopify data

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"
    }
  }
}
Setting from_agent to true closes the SLA clock

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

  1. Add Retry On Fail on all HTTP Request nodes
  2. Create a test ticket in Gorgias for each question type
  3. Verify the reply arrives in the ticket thread within a few seconds
  4. Toggle to Active

Cost

  • n8n Cloud: ~8 node executions per auto-replied ticket. 300 auto-replies/month = ~2,400 executions.
  • Self-hosted: Free.

Need help implementing this?

We build and optimize automation systems for mid-market businesses. Let's discuss the right approach for your team.