","targetProduct":"Shopify"},{"@type":"SoftwareSourceCode","name":"Klaviyo Event Trigger","programmingLanguage":"text/plain","codeSampleType":"snippet","text":"Trigger: Chatbot conversation marked as resolved (webhook from your app)\n\nCondition: If escalation_flag = true, skip; otherwise proceed\n\nThen:\n 1. Call Shopify Flow HTTP action to POST to Klaviyo\n 2. Send payload:\n - customer email\n - conversation summary\n - products mentioned (SKUs)\n - order numbers referenced\n - timestamp\n 3. Klaviyo receives event 'support_chat_resolved'\n 4. Your team sees message in Klaviyo customer profile","targetProduct":"Shopify"},{"@type":"SoftwareSourceCode","name":"Escalation & Agent Handoff","programmingLanguage":"GraphQL","codeSampleType":"snippet","text":"# Admin GraphQL\nmutation TagCustomerForSupport($customerId: ID!, $tags: [String!]!) {\n customerUpdate(input: { id: $customerId, tags: $tags }) {\n customer {\n id\n email\n tags\n }\n userErrors {\n field\n message\n }\n }\n}\n\nquery FetchEscalatedCustomers($query: String!) {\n customers(first: 50, query: $query) {\n edges {\n node {\n id\n email\n firstName\n lastName\n orders(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n }\n }\n }\n}","targetProduct":"Shopify"}]} "}]},{"@type":"HowToStep","position":3,"name":"Klaviyo Event Trigger","text":"When a chat conversation ends, sends the summary and customer info to Klaviyo so your support team sees context in their customer profiles and can follow up if needed. (Paste target: Shopify Flow editor: When → Then.)","itemListElement":[{"@type":"HowToDirection","text":"Trigger: Chatbot conversation marked as resolved (webhook from your app)\n\nCondition: If escalation_flag = true, skip; otherwise proceed\n\nThen:\n 1. Call Shopify Flow HTTP action to POST to Klaviyo\n 2. Send payload:\n - customer email\n - conversation summary\n - products mentioned (SKUs)\n - order numbers referenced\n - timestamp\n 3. Klaviyo receives event 'support_chat_resolved'\n 4. Your team sees message in Klaviyo customer profile"}]},{"@type":"HowToStep","position":4,"name":"Escalation & Agent Handoff","text":"If the bot can't answer a question, it automatically tags the conversation and routes it to your support team in Shopify or email. Your agents see the customer and their order history fetched from Shopify. (Paste target: Admin GraphQL explorer.)","itemListElement":[{"@type":"HowToDirection","text":"# Admin GraphQL\nmutation TagCustomerForSupport($customerId: ID!, $tags: [String!]!) {\n customerUpdate(input: { id: $customerId, tags: $tags }) {\n customer {\n id\n email\n tags\n }\n userErrors {\n field\n message\n }\n }\n}\n\nquery FetchEscalatedCustomers($query: String!) {\n customers(first: 50, query: $query) {\n edges {\n node {\n id\n email\n firstName\n lastName\n orders(first: 5) {\n edges {\n node {\n id\n name\n }\n }\n }\n }\n }\n }\n}"}]}]}
Tom Sailors
Brief · Anonymized case study

Automated Order Lookup Chatbot with Agent Escalation

I'd build a chatbot backend that syncs Shopify orders on a schedule and exposes them via a retrieval-augmented chat interface. The merchant embeds a chat widget on their storefront, customers ask questions about their orders, and the bot pulls from live Shopify data to answer directly. When the bot hits the limits of what it knows, it escalates the conversation to a human agent with full context—tagging the customer and logging everything to Klaviyo so their support team sees the conversation history in one place.

A Shopify merchant running customer support through their storefront wanted to reduce manual agent time answering repetitive order-status questions. They needed a chatbot that could pull live order data from Shopify, answer common tracking and fulfillment inquiries without human intervention, and gracefully escalate complex issues to their support team while logging all interactions for context.
Four pieces
Customer Service

Order Data Sync

Pulls customer orders and shipping status from Shopify on a schedule, so the bot always has live tracking data to answer fulfillment questions without querying Shopify on every chat message.

Backend service + Shopify Admin
Customer Service

Chatbot Interface & Retrieval

A chat widget that listens for customer messages, retrieves matching products and orders from your synced data, and generates answers. Embeds on the storefront and passes the customer ID from Liquid so the bot knows whose orders to show.

Custom Shopify app + React frontend
theme/snippets/support-chatbot.liquid liquid
{% comment %}
  Minimal chatbot embed snippet for storefront.
  Paste into theme/snippets/support-chatbot.liquid and render it in your theme.
{% endcomment %}

<div id="support-chatbot-root" data-shop="{{ shop.permanent_domain }}" data-customer-id="{{ customer.id | default: 'anon' }}"></div>

<style>
  #support-chatbot-root {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    max-height: 600px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    z-index: 999;
  }
</style>

<script src="https://your-app-domain.com/chatbot.js" defer></script>
Replace your-app-domain.com with your Heroku or custom domain. The app reads customer ID from Liquid so it auto-loads their order history when they click the widget.
Customer Service

Klaviyo Event Trigger

When a chat conversation ends, sends the summary and customer info to Klaviyo so your support team sees context in their customer profiles and can follow up if needed.

Shopify Flow + Klaviyo API
Shopify Flow editor: When → Then flow
Trigger: Chatbot conversation marked as resolved (webhook from your app)

Condition: If escalation_flag = true, skip; otherwise proceed

Then:
  1. Call Shopify Flow HTTP action to POST to Klaviyo
  2. Send payload:
     - customer email
     - conversation summary
     - products mentioned (SKUs)
     - order numbers referenced
     - timestamp
  3. Klaviyo receives event 'support_chat_resolved'
  4. Your team sees message in Klaviyo customer profile
Requires Klaviyo API key in Flow custom action; set up the Klaviyo event in their segment builder so your team gets alerts for unresolved chats.
Customer Service

Escalation & Agent Handoff

If the bot can't answer a question, it automatically tags the conversation and routes it to your support team in Shopify or email. Your agents see the customer and their order history fetched from Shopify.

Custom Shopify app + Gorgias or email
Admin GraphQL explorer graphql
# Admin GraphQL
mutation TagCustomerForSupport($customerId: ID!, $tags: [String!]!) {
  customerUpdate(input: { id: $customerId, tags: $tags }) {
    customer {
      id
      email
      tags
    }
    userErrors {
      field
      message
    }
  }
}

query FetchEscalatedCustomers($query: String!) {
  customers(first: 50, query: $query) {
    edges {
      node {
        id
        email
        firstName
        lastName
        orders(first: 5) {
          edges {
            node {
              id
              name
            }
          }
        }
      }
    }
  }
}
Changed variable from $tag to $query and used it in the customers query filter. Allows dynamic tag queries like query: "tag:support-escalation".

Got a similar problem?

Sketch your build in 30 seconds — voice, type, or attach a screenshot.

Sketch the build →