דלג לתוכן הראשי
Subscribe to receive a notification only when a specific label is added to a chat. Other label changes (different labels added, labels removed) are filtered out. Useful for triggering automations from a single designated label such as vip or escalated. Event name: chatSpecificLabelAdded\ Required token scopes:
  • Create scenarios
  • Manage scenarios on behalf of user
see Authentication

Subscribe

Send the body below to Import Subscription. You only need to change:
  • url (required) - Located under data.actions[0].params.url. Replace {{yourWebhookURL}} with the destination URL that should receive the events.
  • targetLabelId (required) - Located inside data.conditions[0][0].params.expression (the expression inArray(addedLabels, "{{targetLabelId}}")). Replace {{targetLabelId}} with the label ID you want to watch (e.g. vip, urgent, escalated). The subscription only fires when that exact label appears in the addedLabels diff.
  • asStatus - Keep "active" to enable the subscription immediately, or "inactive" to save it as an inactive revision.
Import body
{
  "data": {
    "version": "v1",
    "name": "(SUB) Specific Label Added",
    "description": "Sends a webhook when a specific label is added to a chat.",
    "triggerEvents": [
      "domain.chat.labels"
    ],
    "loaders": {},
    "conditions": [
      [
        {
          "name": "filtrex",
          "params": {
            "expression": "inArray(addedLabels, \"{{targetLabelId}}\")",
            "value": {
              "addedLabels": {
                "##provide": {
                  "provider": "addedLabels",
                  "key": "labels"
                }
              }
            }
          },
          "confidentialData": false
        }
      ]
    ],
    "actions": [
      {
        "name": "request",
        "params": {
          "url": "{{yourWebhookURL}}",
          "method": "post",
          "json": true,
          "data": {
            "eventName": "chatSpecificLabelAdded",
            "eventData": {
              "chat": {
                "##provide": {
                  "provider": "chat",
                  "key": "chat"
                }
              },
              "oldLabels": {
                "##provide": {
                  "provider": "oldLabels",
                  "key": "labels"
                }
              },
              "addedLabels": {
                "##provide": {
                  "provider": "addedLabels",
                  "key": "labels"
                }
              },
              "removedLabels": {
                "##provide": {
                  "provider": "removedLabels",
                  "key": "labels"
                }
              }
            }
          }
        },
        "confidentialData": false
      }
    ],
    "options": {
      "unorderedActions": false
    }
  },
  "asStatus": "active"
}
A 201 response returns your new subscription - save its _id to manage it later. You can also add an optional authorUid root field (a Texter user UID) to attribute the subscription to a specific user.

Payload

When the event fires, your URL receives an HTTP POST with eventName: "chatSpecificLabelAdded" and the following eventData:
chat
Chat
The chat whose labels changed. chat.labels reflects the new label set. See the Chat object for all fields.
oldLabels
string[]
Label IDs on the chat before the change.
addedLabels
string[]
Label IDs that were just added - includes your configured target label.
removedLabels
string[]
Label IDs that were just removed.
Example payload
{
  "eventName": "chatSpecificLabelAdded",
  "eventData": {
    "chat": {
      "_id": "69062b15262e17ab3033f886",
      "displayName": "Tyler Joseph",
      "labels": [
        "urgent",
        "vip"
      ],
      "...": "..."
    },
    "oldLabels": [
      "urgent"
    ],
    "addedLabels": [
      "vip"
    ],
    "removedLabels": []
  }
}

Manage this subscription