{
  "name": "Trentzy: reply to a new order",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "trentzy-order",
        "options": {}
      },
      "id": "b1b2c3d4-0001-4000-8000-000000000001",
      "name": "Trentzy webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [0, 0],
      "webhookId": "trentzy-order"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json.body.type }}",
              "rightValue": "order.created",
              "operator": { "type": "string", "operation": "equals" }
            },
            {
              "id": "c2",
              "leftValue": "={{ $json.body.data.order.conversation_id }}",
              "rightValue": "",
              "operator": { "type": "string", "operation": "notEmpty", "singleValue": true }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "b1b2c3d4-0002-4000-8000-000000000002",
      "name": "New order with a conversation",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [240, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.trentzy.com/api/v1/inbox/conversations/{{ $json.body.data.order.conversation_id }}/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ content: 'Thanks for your order ' + $json.body.data.order.number_label + '! We are packing it and will confirm dispatch here.' }) }}",
        "options": {}
      },
      "id": "b1b2c3d4-0003-4000-8000-000000000003",
      "name": "Send DM through Trentzy",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [500, -80]
    }
  ],
  "connections": {
    "Trentzy webhook": {
      "main": [[{ "node": "New order with a conversation", "type": "main", "index": 0 }]]
    },
    "New order with a conversation": {
      "main": [[{ "node": "Send DM through Trentzy", "type": "main", "index": 0 }], []]
    }
  },
  "settings": { "executionOrder": "v1" },
  "meta": {
    "templateCredsSetupCompleted": false,
    "description": "Paste the Webhook node's Production URL into Trentzy → Integrations → Webhooks with the order.created event. Create an API key with the inbox:write scope under Integrations → API & n8n, then add an n8n Header Auth credential (name: Authorization, value: Bearer trz_live_…) and select it on the HTTP Request node. The DM is sent only inside Instagram's 24-hour window."
  }
}
