File parcel loss and damage claims with Shopify, Shiprocket, GPT-4o-mini, and Slack
File parcel loss and damage claims with Shopify, Shiprocket, GPT-4o-mini, and Slack
Quick overview
This workflow monitors Shopify shipments using Shiprocket or AfterShip tracking, drafts and files lost/damaged parcel claims with carrier APIs or Gmail, records everything in Google Sheets, coordinates approvals and updates in Slack, and uses OpenAI to draft claims, classify carrier replies, and answer claim questions.
How it works
Runs every 6 hours, accepts a submitted “Report a lost or damaged parcel” form, or receives an approval-link webhook click from Slack.
For scheduled detection, reads existing claims from Google Sheets, fetches recent Shopify orders, filters to open fulfillments without an existing claim, and pulls the latest tracking scans from Shiprocket or AfterShip.
Flags shipments as lost/damaged/suspected-lost based on tracking text, scan staleness, and claim-window rules, then builds a claim case and searches Google Drive for matching proof photos.
Calculates the claim amount using the configured liability cap and approval thresholds, then uses OpenAI (gpt-4o-mini) to draft the carrier-claim email content and a short customer message.
If dry-run mode is enabled it posts a preview to Slack, otherwise it saves/updates the claim draft in the Google Sheets “Claims” tab and either posts an approval request to Slack or proceeds directly.
For approved claims, it generates a PDF dossier via Gotenberg, files the claim via the carrier API or sends it by Gmail with proof links and the dossier, updates the claim row and posts the filing status to Slack.
After filing, it triggers a customer remedy in Shopify (replacement draft order, refund, or COD cancellation), records the outcome in Google Sheets, and posts the remedy result to Slack.
Separately, it watches Gmail for carrier replies, uses OpenAI to classify the response and extract settlement info, updates the claim in Google Sheets, and supports Slack app mentions to answer claim-status questions from the Claims sheet.
Setup
Create and connect credentials for Shopify Admin API (HTTP Header auth), Google Sheets, Google Drive OAuth2, Gmail, Slack (app mention trigger and posting), and OpenAI.
Add Shiprocket authentication (custom HTTP credential for login) and optionally an AfterShip API key, then choose the tracker and enter keys in the Set Claim Config step.
Create a Google Sheets document with a “Claims” tab containing the columns used by the workflow (for example: claim_id, order_id, order_name, awb, carrier, status, claim_amount, email_subject, email_body, filed_at, response_due, remedy, remedy_status).
Update Set Claim Config with your Shopify store domain, Google Sheet ID, Slack channel ID, carrier claims email(s), Drive folder IDs for proof photos, liability/approval thresholds, and the public webhook URL for claim approvals.
Deploy a Gotenberg instance reachable at the configured URL (http://gotenberg:3000) so the workflow can render the claim dossier PDF.
Change the approval_secret in Set Claim Config and ensure the same secret is used in the approval-token verification logic, then set this workflow as its own error workflow so failures are posted to Slack.