דלג לתוכן הראשי
Subscribe to receive a notification whenever a new incoming message matches specific text criteria. This lets you filter events by keywords, phrases, or complex logic. Event name: newMatchedMessage\ 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.
  • expression (required) - Located under data.conditions[0][1].params.expression. Replace the placeholder logic with your matching criteria using the syntax text == "your keyword":
    • Single keyword: text == "help"
    • Multiple keywords (OR): text == "buy" or text == "purchase"
    • Complex logic with and, or, not and parentheses: (text == "urgent" and text == "error") or text == "critical"
    • Whole sentences match the exact string: text == "I want to speak to a human"
  • asStatus - Keep "active" to enable the subscription immediately, or "inactive" to save it as an inactive revision.
Import body
{
  "data": {
    "version": "v1",
    "name": "(SUB) Messages with Specific Text",
    "description": "Sends a webhook when a new incoming message includes a specific word(s).",
    "triggerEvents": [
      "domain.message.created"
    ],
    "loaders": {
      "beforeConditions": [],
      "afterConditions": [
        {
          "name": "chat",
          "alias": "chat",
          "params": {
            "id": {
              "##provide": {
                "provider": "message",
                "key": "parent_chat"
              }
            }
          },
          "confidentialData": false
        }
      ]
    },
    "conditions": [
      [
        {
          "name": "filtrex",
          "params": {
            "expression": "direction == \"incoming\"",
            "value": {
              "##provide": {
                "provider": "message",
                "key": "message"
              }
            }
          },
          "confidentialData": false
        },
        {
          "name": "filtrex",
          "params": {
            "expression": "text == \"{{word1}}\" or text == \"{{word2}}\" ",
            "value": {
              "##provide": {
                "provider": "message",
                "key": "message"
              }
            }
          },
          "confidentialData": false
        }
      ]
    ],
    "actions": [
      {
        "name": "request",
        "params": {
          "url": "{{yourWebhookURL}}",
          "method": "post",
          "json": true,
          "data": {
            "eventName": "newMatchedMessage",
            "eventData": {
              "message": {
                "##provide": {
                  "provider": "message",
                  "key": "message"
                }
              },
              "chat": {
                "##provide": {
                  "provider": "chat",
                  "key": "chat"
                }
              }
            }
          }
        },
        "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: "newMatchedMessage" and the following eventData:
message
Message
The incoming message that matched your expression. See the Message object for all fields.
chat
Chat
The chat the message belongs to. See the Chat object for all fields.
Example payload
{
  "eventName": "newMatchedMessage",
  "eventData": {
    "message": {
      "_id": "64de3b15398a8o09c47a9f62",
      "text": "I need help with my billing",
      "direction": "incoming",
      "...": "..."
    },
    "chat": {
      "_id": "69062b15262e17ab3033f886",
      "displayName": "Niv Shtein",
      "...": "..."
    }
  }
}

Manage this subscription