{
  "updatedAt": "2026-03-31T00:36:47.842Z",
  "createdAt": "2026-03-30T23:31:54.243Z",
  "id": "bmM2Z172DjCUMmec",
  "name": "NC TikTok DM Router v2",
  "description": null,
  "active": false,
  "isArchived": false,
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "nc-tiktok-dm-router",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        220,
        400
      ],
      "id": "webhook",
      "name": "Webhook",
      "webhookId": "nc-tiktok-dm-router"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "responses": {
          "values": [
            {
              "content": "=Inbound Message: {{ $json.body.inbound_message }}\n\nIs this a business inquiry? Answer only YES or NO."
            },
            {
              "role": "system",
              "content": "You classify TikTok DMs for Nurse Charles Media.\n\nAnswer YES if the message is any of these:\n- Brand partnership, sponsorship, or collaboration request\n- Speaking engagement or event invitation\n- Media, press, or interview request\n- Someone wanting to hire Charles or pay for a service\n- A doctor, executive, or organization reaching out professionally\n- An explicit business proposal\n\nAnswer NO if the message is any of these:\n- Fan message, compliment, or \"great video\"\n- Health question or nursing advice\n- Someone asking for a free resource or link\n- General chat, \"hello\", or casual conversation\n- Someone asking about the challenge or free content\n- Anything that is not a clear business opportunity\n\nOutput ONLY the word YES or NO. Nothing else."
            }
          ]
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        440,
        400
      ],
      "id": "classify",
      "name": "Business Inquiry?",
      "credentials": {
        "openAiApi": {
          "id": "aIfAJu72uRgeFCql",
          "name": "OpenAI API Key"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.output[0].content[0].text }}",
                    "rightValue": "YES",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "business"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.output[0].content[0].text }}",
                    "rightValue": "NO",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "fan"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.4,
      "position": [
        660,
        400
      ],
      "id": "switch",
      "name": "Route"
    },
    {
      "parameters": {
        "chatId": "-5170274773",
        "text": "=\ud83d\udd25 BUSINESS DM on TikTok!\n\nName: {{ $('Webhook').item.json.body.contact_name }}\nMessage: {{ $('Webhook').item.json.body.inbound_message }}\nAI Response: {{ $('Webhook').item.json.body.ai_response }}\nTime: {{ $now.setZone('America/New_York').toFormat('MM/dd/yyyy hh:mm a') }}\n\nRespond in GHL ASAP.",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        880,
        300
      ],
      "id": "telegram",
      "name": "Alert: Business DM",
      "credentials": {
        "telegramApi": {
          "id": "VbEHHBR1aAnNPEs8",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Send auto-reply via GHL pushing them to subscribe\nconst GHL_KEY = 'pit-b68fa048-e2a1-4206-a68a-b3e6d3d7091b';\nconst contactId = $('Webhook').first().json.body.contact_id;\nconst contactName = $('Webhook').first().json.body.contact_name || '';\nconst firstName = contactName.split(' ')[0] || 'Hey';\n\nconst reply = `${firstName}! Thank you for reaching out. I get thousands of DMs and I wish I could answer every one personally.\\n\\nThat's exactly why I built my subscriber community -- it's where I go deep on ER stories, answer health questions live every week, and actually get to connect with people one-on-one.\\n\\nJoin here and I'll see your message there: [subscriber link]\\n\\nAnd if you're trying to quit smoking or vaping, text READY to 470-672-7008 for my free 5-day challenge. -Nurse Charles`;\n\ntry {\n  await this.helpers.httpRequest({\n    method: 'POST',\n    url: 'https://services.leadconnectorhq.com/conversations/messages',\n    headers: {\n      'Authorization': 'Bearer ' + GHL_KEY,\n      'Version': '2021-04-15',\n      'Content-Type': 'application/json'\n    },\n    body: { type: 'TYPE_TIKTOK', contactId, message: reply },\n    json: true\n  });\n} catch(e) {\n  // If TikTok reply fails, try SMS\n  // TikTok DM reply may not be supported via API\n}\n\nreturn [{ json: { action: 'auto_reply_sent', contactId, firstName } }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        880,
        500
      ],
      "id": "auto-reply",
      "name": "Auto-Reply: Join Community"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1ulvBJBOszHhqhhz8iGRWgo99b0aKiagC8hUGNJfsrcg",
          "mode": "list",
          "cachedResultName": "CF Contacts"
        },
        "sheetName": {
          "__rl": true,
          "value": 24003387,
          "mode": "list",
          "cachedResultName": "Tiktok DM"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Name": "={{ $('Webhook').item.json.body.contact_name }}",
            "Inbound Message": "={{ $('Webhook').item.json.body.inbound_message }}",
            "Response": "={{ $('Webhook').item.json.body.ai_response }}",
            "Inquiry Type": "={{ $('Business Inquiry?').item.json.output[0].content[0].text === 'YES' ? 'Business' : 'Fan/General' }}",
            "Date": "={{ $now.setZone('America/New_York').toFormat('MM/dd/yyyy hh:mm a') }}"
          },
          "matchingColumns": [
            "Name"
          ],
          "schema": [
            {
              "id": "Name",
              "displayName": "Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Inbound Message",
              "displayName": "Inbound Message",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Response",
              "displayName": "Response",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Inquiry Type",
              "displayName": "Inquiry Type",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Date",
              "displayName": "Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        440,
        600
      ],
      "id": "sheets",
      "name": "Log to Sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "OhjizsinSISmx4Gl",
          "name": "Google Sheets OAuth2 API"
        }
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Business Inquiry?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Business Inquiry?": {
      "main": [
        [
          {
            "node": "Log to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Sheet": {
      "main": [
        [
          {
            "node": "Route",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route": {
      "main": [
        [
          {
            "node": "Alert: Business DM",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Auto-Reply: Join Community",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Alert: Business DM": {
      "main": [
        []
      ]
    },
    "Auto-Reply: Join Community": {
      "main": [
        []
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false
  },
  "staticData": null,
  "meta": null,
  "pinData": null,
  "versionId": "ae44e0bb-a94a-47e5-a108-6ccdc72cb80d",
  "activeVersionId": null,
  "versionCounter": 8,
  "triggerCount": 1,
  "shared": [
    {
      "updatedAt": "2026-03-30T23:31:54.245Z",
      "createdAt": "2026-03-30T23:31:54.245Z",
      "role": "workflow:owner",
      "workflowId": "bmM2Z172DjCUMmec",
      "projectId": "91dLj8Hg37i136qG",
      "project": {
        "updatedAt": "2026-03-22T06:53:28.112Z",
        "createdAt": "2026-02-12T18:32:53.056Z",
        "id": "91dLj8Hg37i136qG",
        "name": "Bryce Folsom <bfolsom@emersonnorth.com>",
        "type": "personal",
        "icon": null,
        "description": null,
        "creatorId": "17d3676f-3e74-4586-8363-5c1f4d237ed7"
      }
    }
  ],
  "tags": [],
  "activeVersion": null
}