Flag repeat customer contacts in Gorgias and alert Slack using n8n

medium complexityCost: $0-24/moRecommended

Prerequisites

Prerequisites
  • n8n instance (cloud or self-hosted)
  • Gorgias account with REST API access
  • Gorgias API credentials: account email and API key
  • Slack Incoming Webhook URL or Slack API credentials
  • A "repeat-contact" tag created in Gorgias (optional but recommended)

Overview

This workflow fires every time a new Gorgias ticket is created. It looks up the customer's recent ticket history via the Gorgias API, counts how many tickets they've opened in the past 7 days, and — if the count hits your threshold — tags the ticket and posts a Slack alert with context about the customer's recent activity. The entire check happens in under two seconds, so your team gets flagged before an agent even opens the ticket.

Step 1: Set up the Webhook trigger

Add a Webhook node:

  • HTTP Method: POST
  • Path: gorgias-repeat-contact

Copy the webhook URL — you'll register it with Gorgias in the next step.

Step 2: Register the webhook in Gorgias

Go to Settings → Integrations → HTTPAdd HTTP integration:

  • Name: n8n Repeat Contact Check
  • URL: Your n8n webhook URL
  • Events: Ticket created
  • Content-Type: application/json
Use a dedicated HTTP integration

Keep this separate from any other n8n integrations you have in Gorgias. This makes it easy to disable or debug the repeat contact check without affecting other workflows.

Step 3: Extract customer info from the webhook payload

Add a Code node to pull out the customer ID and ticket details:

const ticket = $input.first().json;
 
const customerId = ticket.customer?.id;
const customerEmail = ticket.customer?.email || 'unknown';
const customerName = ticket.customer?.firstname || customerEmail;
const ticketId = ticket.id;
const subject = ticket.subject || '(no subject)';
 
if (!customerId) {
  return []; // no customer attached — skip
}
 
return [{
  json: {
    customerId,
    customerEmail,
    customerName,
    ticketId,
    subject,
  }
}];

Step 4: Query the customer's recent tickets

Add an HTTP Request node to fetch the customer's tickets from the past 7 days:

  • Method: GET
  • URL: https://your-store.gorgias.com/api/tickets
  • Authentication: Basic Auth (Gorgias email + API key)
  • Query Parameters:
    • customer_id: {{ $json.customerId }}
    • limit: 50

This returns the customer's most recent tickets. You'll filter by date in the next step.

Step 5: Count tickets in the past 7 days

Add a Code node to count tickets within the 7-day window:

const tickets = $input.first().json.data || [];
const prevData = $('Code').first().json;
 
const sevenDaysAgo = new Date();
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
 
const recentTickets = tickets.filter(t => {
  const created = new Date(t.created_datetime);
  return created >= sevenDaysAgo;
});
 
return [{
  json: {
    ...prevData,
    recentTicketCount: recentTickets.length,
    recentTickets: recentTickets.map(t => ({
      id: t.id,
      subject: t.subject,
      created: t.created_datetime,
      status: t.status,
    })),
    isRepeatContact: recentTickets.length >= 3,
  }
}];

Step 6: Branch on the repeat contact threshold

Add an IF node:

  • Condition: {{ $json.isRepeatContact }} equals true

The true branch continues to tagging and Slack. The false branch ends — no action needed for customers below the threshold.

Adjust the threshold for your business

The default threshold of 3 tickets in 7 days works well for most e-commerce brands. If your product naturally generates more support volume (e.g., a subscription box with weekly shipments), raise this to 4 or 5 to avoid false positives.

Step 7: Tag the ticket in Gorgias

On the true branch, add an HTTP Request node:

  • Method: PUT
  • URL: https://your-store.gorgias.com/api/tickets/{{ $json.ticketId }}
  • Authentication: Basic Auth
  • Body (JSON):
{
  "tags": [{ "name": "repeat-contact" }]
}

This tag lets you create a dedicated Gorgias View that surfaces all repeat-contact tickets in one place.

Step 8: Post a Slack alert

Add a Slack node (or HTTP Request to a Webhook URL):

  • Channel: #support-escalations
  • Message:
:rotating_light: Repeat Contact Flagged
 
*{{ $json.customerName }}* ({{ $json.customerEmail }}) has opened *{{ $json.recentTicketCount }} tickets* in the last 7 days.
 
*Latest ticket:* #{{ $json.ticketId }} — {{ $json.subject }}
 
*Recent tickets:*
{{ $json.recentTickets.map(t => `• #${t.id}: ${t.subject} (${t.status})`).join('\n') }}
 
→ <https://your-store.gorgias.com/app/ticket/{{ $json.ticketId }}|View in Gorgias>
Include a summary of recent ticket subjects

Listing the subjects of all recent tickets in the Slack message gives the responding agent instant context. They can see at a glance whether the customer keeps asking about the same issue or has multiple unrelated problems.

Step 9: Activate and test

  1. Create a test customer in Gorgias (or use a test email)
  2. Submit 3 test tickets from that customer within a few minutes
  3. Verify the third ticket triggers the webhook, gets tagged, and posts a Slack alert
  4. Toggle the workflow to Active
  5. Add Retry On Fail on all HTTP Request nodes

Cost

  • n8n Cloud: ~6 node executions per ticket check. If you process 500 new tickets/month and 10% are repeat contacts, that's roughly 3,000 executions/month — well within the free tier.
  • 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.