When an incoming message is received, Telerivet typically applies services from top to bottom as listed on the Services page. To change the order of your active services, drag the listing for any service at the top of the Services page:
Note that the service listing is only visible if your project has multiple active services that handle incoming messages.
Handling MessagesIf one service "handles" an incoming message, then Telerivet will not try applying any subsequent services for that message.
By default, Telerivet will consider a service to have "handled" the message if it performs any the following actions:
- Sending an SMS message
- Adding or removing a group member
- Answering a poll question
- Setting the return_value variable to 1 (Custom Actions, Cloud Script API, or Webhook API)
- A webhook service at the top that forwards all messages to your own server (but doesn't send replies)
- A SMS poll to collect feedback about customer service
- A subscription service that handles keywords like "JOIN" and "STOP"
- An auto-reply service that handles keywords like "HOURS" or "COUPON"
- A catch-all service at the bottom that sends an auto-reply if someone sends an unknown keyword
- Send the message to the webhook URL on your server; since it doesn't send a reply it would continue to the next service
- Test if "JOIN" is accepted as a valid response to the SMS poll and if the contact is allowed to participate in the poll; if so, interpret it as a poll response and stop; otherwise, continue to the next service
- Perform the actions for the "JOIN" keyword on the subscription service, by adding the contact to a subscribers group and sending an auto-reply. Since an SMS message was sent (and a contact was added to a group), the message is marked as "handled", so Telerivet will stop there without applying the other services. By stopping, service 5 will not send a message saying that the keyword is invalid.
Overriding Top-to-Bottom OrderTelerivet will override the top-to-bottom order of service execution for a particular contact if a particular service is "waiting" for a response, or more precisely, when a contact has "state" for a particular service. Any services where a contact has "state" will be tried first, in order of the most recent time that service was applied for that contact.
Telerivet overrides the top-to-bottom order of services in several situations:
- whenever a contact triggers a "Wait for response" action
- if you manually set the "state.id" variable within a custom service
- when a contact is in process of answering a poll
Usually, this intuitively does what you want. For example, suppose you have multiple SMS polls active at the same time. If you send someone an SMS poll and someone replies, the message should be interpreted as a response to the SMS poll you actually sent them, not the poll which happened to be listed first on your Services page.