דלג לתוכן הראשי
Subscribe to receive a notification for each new incoming message event. Outgoing messages are excluded. Event name: newIncomingMessage\ 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.
  • asStatus - Keep "active" to enable the subscription immediately, or "inactive" to save it as an inactive revision.
Import body
{
  "data": {
    "version": "v1",
    "name": "(SUB) New Incoming Messages",
    "description": "Sends a webhook for each new incoming message",
    "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
        }
      ]
    ],
    "actions": [
      {
        "name": "request",
        "params": {
          "url": "{{yourWebhookURL}}",
          "method": "post",
          "json": true,
          "data": {
            "eventName": "newIncomingMessage",
            "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: "newIncomingMessage" and the following eventData:
message
Message
The incoming message. 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": "newIncomingMessage",
  "eventData": {
    "message": {
      "_id": "64de3b15398a8o09c47a9f62",
      "text": "Hey, can someone call me back?",
      "direction": "incoming",
      "...": "..."
    },
    "chat": {
      "_id": "69062b15262e17ab3033f886",
      "displayName": "Josh Dun",
      "...": "..."
    }
  }
}

Manage this subscription