---
title: "Create a service"
method: POST
path: "/v1/projects/{project_id}/services"
tags: ["Service"]
---

# Create a service

`POST /v1/projects/{project_id}/services`

## Request

- Base URL: `https://api.telerivet.com`
- URL: `https://api.telerivet.com/v1/projects/{project_id}/services`
- Auth: one of:
  - HTTP basic
  - OAuth 2 (authorization code, authorization URL `https://telerivet.com/oauth/authorize`, token URL `https://api.telerivet.com/oauth/token`)

Creates a new automated service.

 Only certain types of automated services can be created via the API. Other types of services can only be created via the web app.

**Service Types:** See `x-service-types` in the API info section for a machine-readable list of all supported service types and their required configuration parameters.

**Cloud Script Services:** When creating `*_script` service types, the `code` field contains JavaScript that runs in Telerivet's cloud script engine. See https://api.telerivet.com/script.d.ts for the full JavaScript API reference.

## Path parameters

- `project_id` string, required

## Request body

- CreateServiceRequest: Request body for POST /v1/projects/{project_id}/services
  - `service_type` 'incoming_message_actions' | 'contact_actions' | 'message_actions' | 'project_actions' | 'message_status_actions' | 'voice_actions' | 'ussd_actions' | 'data_row_actions' | 'incoming_message_webhook' | 'optin_optout' | 'keyword_auto_reply' | 'messaging_poll' | 'voice_poll' | 'scheduled_actions' | 'auto_reply' | 'call_auto_reply' | 'incoming_message_script' | 'contact_script' | 'message_script' | 'data_row_script' | 'scheduled_script' | 'webhook_script' | 'voice_script' | 'ussd_script' | 'project_script' | 'opt_out_page' | 'button_page' | 'custom_template_instance', required: Type of service to create. See x-service-types in info section for all types and their configurations.
  - `name` string: Name of the service (auto-generated if not provided)
  - `config` union, required: Configuration specific to the service_type. See x-service-types for required fields per type.
    - object: Configuration for `incoming_message_actions` service type.
      - `actions` MessageAction[]: Array of actions to execute. Each action is an object with a `type` property and additional properties depending on the action type. See <a href="/api/rules_engine#actions">Action Reference</a> for documentation of available action types.
        - union: An action available for `incoming_message_actions` and `message_actions` service types.
          - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
            - `type` 'reply', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
          - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
            - `type` 'send_text', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `to_number` string, required: Phone number to send the message to.
          - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
            - `type` 'send_text_to_group', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `group_name` string, required: Name of the group to send the message to.
            - `exclude_sender` boolean: If true, exclude the message sender from receiving the group message.
          - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'add_contact_to_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'remove_contact_from_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
            - `type` 'set_contact', required: Action type identifier
            - `phone_number` string, required: Phone number for the contact to use.
          - object: Updates the name of the current contact in Telerivet.
            - `type` 'set_contact_name', required: Action type identifier
            - `name` string, required: Name to assign to the contact.
          - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
            - `type` 'set_contact_var', required: Action type identifier
            - `variable` string, required: Name of the contact variable to set (without the contact.vars prefix).
            - `value` string: Value to assign to the variable.
          - object: Blocks the current contact.
            - `type` 'block_contact', required: Action type identifier
            - `send_blocked` boolean: If true, block sending messages to this contact. If false, unblock the contact. Default: true.
          - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
            - `type` 'send_email', required: Action type identifier
            - `to_email` string, required: Recipient email address.
            - `subject` string, required: Email subject line.
            - `body_text` string, required: Email body text.
            - `reply_to` string: Reply-to email address.
            - `include_message_attachments` boolean: If true, include any attachments from the current message as email attachments.
          - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
            - `type` 'send_airtime', required: Action type identifier
            - `provider_id` string, required: ID of the airtime provider to use.
            - `products` object[], required: Array of product configurations for different mobile networks or countries.
              - …
            - `actions` Action[]: Array of actions to execute if the contact is on a supported mobile network.
              - …
            - `on_success` string: Name of subroutine to execute when the airtime transaction succeeds.
            - `on_failure` string: Name of subroutine to execute when the airtime transaction fails.
          - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
            - `type` 'add_label_to_message', required: Action type identifier
            - `label_name` string, required: Name of the label to add to the message.
          - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
            - `type` 'star_message', required: Action type identifier
          - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
            - `type` 'set_variable', required: Action type identifier
            - `variable` string, required: Name of the variable to set (e.g. $foo, contact.vars.bar, phone.vars.baz).
            - `value` string, required: Value to assign to the variable.
            - `op` 'plus' | 'minus' | 'times' | 'div': Optional arithmetic operation to perform between value and value2.
            - `value2` string: Second operand for the arithmetic operation (required if op is specified).
          - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
            - `type` 'cancel_scheduled_messages', required: Action type identifier
          - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
            - `type` 'webhook', required: Action type identifier
            - `url` string, required: Webhook URL to receive the HTTP POST request.
            - `secret` string: Secret string passed as POST parameter for request verification.
            - `params` object[]: Custom POST parameters to include in the webhook request, in addition to the standard parameters (max 20). A custom parameter with the same name as a standard parameter (including <code>secret</code>) takes precedence over the standard value.
              - …
          - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
            - `type` 'log', required: Action type identifier
            - `value` string, required: Log message content.
          - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
            - `type` 'run_script', required: Action type identifier
            - `code` string, required: JavaScript code to execute. See <a href="https://telerivet.com/api/script">Cloud Script API</a> for available functions and variables.
          - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
            - `type` 'condition', required: Action type identifier
            - `conditions` object[]: Array of condition objects. Required unless <code>if_mode</code> is <code>else</code>.
              - …
            - `actions` Action[], required: Array of actions to execute if the conditions match.
              - …
            - `op` string: Operator to join multiple conditions. Values: <code>and</code> (all conditions must match), <code>or</code> (any condition must match). Default: <code>or</code>.
            - `if_mode` string: Controls how this condition relates to previous conditions. Values: <code>if</code> (default, starts a new conditional block), <code>else_if</code> (only evaluated if the previous <code>if</code> or <code>else_if</code> did not match), <code>else</code> (executed if none of the previous <code>if</code>/<code>else_if</code> conditions matched; does not require <code>conditions</code> array).
          - object: Triggers another service for the current contact.
            - `type` 'trigger_contact_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
            - `schedule` object: Schedule for when to trigger the service. If not specified, triggers the service immediately.
          - object: Triggers another service for the current message.
            - `type` 'trigger_message_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
          - object: Triggers another service for the current project.
            - `type` 'trigger_project_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
          - object: Stops processing rules for this message (for this service only).
            - `type` 'stop', required: Action type identifier
          - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
            - `type` 'copy_message_to_project', required: Action type identifier
            - `project_id` string, required: ID of the project to copy the message to. Must be a project within the same organization.
          - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
            - `type` 'set_message_var', required: Action type identifier
            - `variable` string, required: Name of the message variable to set (without the vars prefix).
            - `value` string: Value to assign to the variable.
          - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
            - `type` 'wait_response', required: Action type identifier
            - `state_id` string, required: ID of the response handler to process the contact's response.
            - `timeout` object: Schedule for response timeout.
          - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
            - `type` 'send_ussd', required: Action type identifier
            - `mmi_code` string, required: USSD/MMI code to send (e.g. *123#).
            - `route_id` string: ID of the route to send the USSD request from. If not specified, uses the default route.
          - object: Triggers a set of actions which can be reused multiple times in the same service.
            - `type` 'run_subroutine', required: Action type identifier
            - `name` string, required: Name of the subroutine to run.
          - object: Sends a voice call to the current contact using a specified IVR service.
            - `type` 'call_contact', required: Action type identifier
            - `service_id` string, required: ID of the voice/IVR service to use for the call.
            - `route_id` string: ID of the route to use for the call. If not specified, uses the default route.
            - `schedule` object: Schedule for when to make the call. If not specified, calls immediately.
          - object: Pushes the message to a Zendesk support inbox, in a ticket associated with the current contact. Zendesk agents can reply directly to the Zendesk ticket to send a reply to the contact.
            - `type` 'push_to_zendesk', required: Action type identifier
            - `subdomain` string, required: Zendesk subdomain (e.g., "example" for example.zendesk.com).
            - `subject` string, required: Subject line for the Zendesk ticket.
            - `content` string, required: Content of the Zendesk ticket.
          - object: Pushes the message to a HubSpot Help Desk inbox, in a conversation associated with the current contact. HubSpot agents can reply directly to send a reply to the contact.
            - `type` 'push_to_hubspot', required: Action type identifier
            - `integration_id` string, required: ID of the HubSpot channel integration config.
            - `content` string: Content of the message pushed to HubSpot.
      - `subroutines` object[]: Array of subroutine definitions. Subroutines are reusable sets of actions that can be called from the main actions or other subroutines.
        - `name` string, required: Unique name for the subroutine (max 32 characters).
        - `context` string: Context type for the subroutine. If not specified, defaults to the service's context.
        - `actions` Action[], required: Array of actions to execute when the subroutine is called. Available actions depend on the subroutine's context.
          - union: An action in a Custom Actions service. The `type` property determines which action is performed and what additional properties are available. See [Rules Engine Actions](/api/rules_engine#actions) for detailed documentation.
            - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
              - …
            - object: Blocks the current contact.
              - …
            - object: Sends a voice call to the current contact using a specified IVR service.
              - …
            - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
              - …
            - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
              - …
            - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
              - …
            - object: Ends the current USSD session.
              - …
            - object: Within a poll service, skips to the end of the survey.
              - …
            - object: Forwards the incoming call to another phone number.
              - …
            - object: Hangs up the phone call.
              - …
            - object: Within a poll service, ignores the current message.
              - …
            - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
              - …
            - object: Plays an audio file in WAV or MP3 format in the voice call, which may be uploaded, linked, or recorded via the Telerivet web app. Alternatively, can use text-to-speech to speak a message.
              - …
            - object: Pushes the message to a HubSpot Help Desk inbox, in a conversation associated with the current contact. HubSpot agents can reply directly to send a reply to the contact.
              - …
            - object: Pushes the message to a Zendesk support inbox, in a ticket associated with the current contact. Zendesk agents can reply directly to the Zendesk ticket to send a reply to the contact.
              - …
            - object: Records an audio response from the caller, saves the recording URL as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Within a poll service, repeats the current question again.
              - …
            - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text reply to the sender (simple version without labels, schedule, or route configuration).
              - …
            - object: Within a service triggered when a message status changes, will automatically resend the current message via the same route or a different route.
              - …
            - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
              - …
            - object: Triggers a set of actions which can be reused multiple times in the same service.
              - …
            - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
              - …
            - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
              - …
            - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text message to the current contact.
              - …
            - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
              - …
            - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
              - …
            - object: Shows the specified text in the active USSD session. If this action is followed by a 'Wait for response' action, the text will be displayed as part of a USSD prompt.
              - …
            - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
              - …
            - object: Updates the name of the current contact in Telerivet.
              - …
            - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
              - …
            - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
              - …
            - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
              - …
            - object: Within a poll service, skips to a question outside the normal order.
              - …
            - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
              - …
            - object: Stops processing rules for this message (for this service only).
              - …
            - object: Triggers another service for the current contact.
              - …
            - object: Triggers another service for the current message.
              - …
            - object: Triggers another service for the current project.
              - …
            - object: Within a custom route, selects one or more basic routes that can be used to send the message.
              - …
            - object: Waits for the caller to enter digits on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for the caller to press a single key on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
              - …
            - object: Prompts the user for input in the active USSD session, saves the response as a custom variable on the message, and triggers the associated response handler.
              - …
            - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
              - …
      - `response_handlers` object[]: Array of response handler definitions. Response handlers are triggered when the service is waiting for input (e.g., after `wait_response` actions).
        - `state_id` string, required: Unique state identifier for this response handler. Must be a valid variable name and cannot be "initial".
        - `actions` MessageAction[], required: Array of actions to execute when a response is received in this state.
          - union: An action available for `incoming_message_actions` and `message_actions` service types.
            - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
              - …
            - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
              - …
            - object: Updates the name of the current contact in Telerivet.
              - …
            - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
              - …
            - object: Blocks the current contact.
              - …
            - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
              - …
            - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
              - …
            - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
              - …
            - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
              - …
            - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
              - …
            - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
              - …
            - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
              - …
            - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
              - …
            - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
              - …
            - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
              - …
            - object: Triggers another service for the current contact.
              - …
            - object: Triggers another service for the current message.
              - …
            - object: Triggers another service for the current project.
              - …
            - object: Stops processing rules for this message (for this service only).
              - …
            - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
              - …
            - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
              - …
            - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
              - …
            - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
              - …
            - object: Triggers a set of actions which can be reused multiple times in the same service.
              - …
            - object: Sends a voice call to the current contact using a specified IVR service.
              - …
            - object: Pushes the message to a Zendesk support inbox, in a ticket associated with the current contact. Zendesk agents can reply directly to the Zendesk ticket to send a reply to the contact.
              - …
            - object: Pushes the message to a HubSpot Help Desk inbox, in a conversation associated with the current contact. HubSpot agents can reply directly to send a reply to the contact.
              - …
    - object: Configuration for `contact_actions` service type.
      - `actions` ContactAction[]: Array of actions to execute. Each action is an object with a `type` property and additional properties depending on the action type. See <a href="/api/rules_engine#actions">Action Reference</a> for documentation of available action types.
        - union: An action available for `contact_actions` and `data_row_actions` service types.
          - object: Sends a text message to the current contact.
            - `type` 'send_text_to_contact', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
          - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
            - `type` 'send_text', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `to_number` string, required: Phone number to send the message to.
          - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
            - `type` 'send_airtime', required: Action type identifier
            - `provider_id` string, required: ID of the airtime provider to use.
            - `products` object[], required: Array of product configurations for different mobile networks or countries.
              - …
            - `actions` Action[]: Array of actions to execute if the contact is on a supported mobile network.
              - …
            - `on_success` string: Name of subroutine to execute when the airtime transaction succeeds.
            - `on_failure` string: Name of subroutine to execute when the airtime transaction fails.
          - object: Sends a voice call to the current contact using a specified IVR service.
            - `type` 'call_contact', required: Action type identifier
            - `service_id` string, required: ID of the voice/IVR service to use for the call.
            - `route_id` string: ID of the route to use for the call. If not specified, uses the default route.
            - `schedule` object: Schedule for when to make the call. If not specified, calls immediately.
          - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'add_contact_to_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'remove_contact_from_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
            - `type` 'set_contact_var', required: Action type identifier
            - `variable` string, required: Name of the contact variable to set (without the contact.vars prefix).
            - `value` string: Value to assign to the variable.
          - object: Blocks the current contact.
            - `type` 'block_contact', required: Action type identifier
            - `send_blocked` boolean: If true, block sending messages to this contact. If false, unblock the contact. Default: true.
          - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
            - `type` 'send_ussd', required: Action type identifier
            - `mmi_code` string, required: USSD/MMI code to send (e.g. *123#).
            - `route_id` string: ID of the route to send the USSD request from. If not specified, uses the default route.
          - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
            - `type` 'send_email', required: Action type identifier
            - `to_email` string, required: Recipient email address.
            - `subject` string, required: Email subject line.
            - `body_text` string, required: Email body text.
            - `reply_to` string: Reply-to email address.
            - `include_message_attachments` boolean: If true, include any attachments from the current message as email attachments.
          - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
            - `type` 'set_variable', required: Action type identifier
            - `variable` string, required: Name of the variable to set (e.g. $foo, contact.vars.bar, phone.vars.baz).
            - `value` string, required: Value to assign to the variable.
            - `op` 'plus' | 'minus' | 'times' | 'div': Optional arithmetic operation to perform between value and value2.
            - `value2` string: Second operand for the arithmetic operation (required if op is specified).
          - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
            - `type` 'cancel_scheduled_messages', required: Action type identifier
          - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
            - `type` 'webhook', required: Action type identifier
            - `url` string, required: Webhook URL to receive the HTTP POST request.
            - `secret` string: Secret string passed as POST parameter for request verification.
            - `params` object[]: Custom POST parameters to include in the webhook request, in addition to the standard parameters (max 20). A custom parameter with the same name as a standard parameter (including <code>secret</code>) takes precedence over the standard value.
              - …
          - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
            - `type` 'log', required: Action type identifier
            - `value` string, required: Log message content.
          - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
            - `type` 'run_script', required: Action type identifier
            - `code` string, required: JavaScript code to execute. See <a href="https://telerivet.com/api/script">Cloud Script API</a> for available functions and variables.
          - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
            - `type` 'condition', required: Action type identifier
            - `conditions` object[]: Array of condition objects. Required unless <code>if_mode</code> is <code>else</code>.
              - …
            - `actions` Action[], required: Array of actions to execute if the conditions match.
              - …
            - `op` string: Operator to join multiple conditions. Values: <code>and</code> (all conditions must match), <code>or</code> (any condition must match). Default: <code>or</code>.
            - `if_mode` string: Controls how this condition relates to previous conditions. Values: <code>if</code> (default, starts a new conditional block), <code>else_if</code> (only evaluated if the previous <code>if</code> or <code>else_if</code> did not match), <code>else</code> (executed if none of the previous <code>if</code>/<code>else_if</code> conditions matched; does not require <code>conditions</code> array).
          - object: Stops processing rules for this message (for this service only).
            - `type` 'stop', required: Action type identifier
          - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
            - `type` 'wait_response', required: Action type identifier
            - `state_id` string, required: ID of the response handler to process the contact's response.
            - `timeout` object: Schedule for response timeout.
          - object: Triggers a set of actions which can be reused multiple times in the same service.
            - `type` 'run_subroutine', required: Action type identifier
            - `name` string, required: Name of the subroutine to run.
          - object: Triggers another service for the current contact.
            - `type` 'trigger_contact_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
            - `schedule` object: Schedule for when to trigger the service. If not specified, triggers the service immediately.
          - object: Triggers another service for the current project.
            - `type` 'trigger_project_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
          - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
            - `type` 'set_contact', required: Action type identifier
            - `phone_number` string, required: Phone number for the contact to use.
      - `subroutines` object[]: Array of subroutine definitions. Subroutines are reusable sets of actions that can be called from the main actions or other subroutines.
        - `name` string, required: Unique name for the subroutine (max 32 characters).
        - `context` string: Context type for the subroutine. If not specified, defaults to the service's context.
        - `actions` Action[], required: Array of actions to execute when the subroutine is called. Available actions depend on the subroutine's context.
          - union: An action in a Custom Actions service. The `type` property determines which action is performed and what additional properties are available. See [Rules Engine Actions](/api/rules_engine#actions) for detailed documentation.
            - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
              - …
            - object: Blocks the current contact.
              - …
            - object: Sends a voice call to the current contact using a specified IVR service.
              - …
            - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
              - …
            - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
              - …
            - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
              - …
            - object: Ends the current USSD session.
              - …
            - object: Within a poll service, skips to the end of the survey.
              - …
            - object: Forwards the incoming call to another phone number.
              - …
            - object: Hangs up the phone call.
              - …
            - object: Within a poll service, ignores the current message.
              - …
            - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
              - …
            - object: Plays an audio file in WAV or MP3 format in the voice call, which may be uploaded, linked, or recorded via the Telerivet web app. Alternatively, can use text-to-speech to speak a message.
              - …
            - object: Pushes the message to a HubSpot Help Desk inbox, in a conversation associated with the current contact. HubSpot agents can reply directly to send a reply to the contact.
              - …
            - object: Pushes the message to a Zendesk support inbox, in a ticket associated with the current contact. Zendesk agents can reply directly to the Zendesk ticket to send a reply to the contact.
              - …
            - object: Records an audio response from the caller, saves the recording URL as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Within a poll service, repeats the current question again.
              - …
            - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text reply to the sender (simple version without labels, schedule, or route configuration).
              - …
            - object: Within a service triggered when a message status changes, will automatically resend the current message via the same route or a different route.
              - …
            - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
              - …
            - object: Triggers a set of actions which can be reused multiple times in the same service.
              - …
            - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
              - …
            - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
              - …
            - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text message to the current contact.
              - …
            - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
              - …
            - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
              - …
            - object: Shows the specified text in the active USSD session. If this action is followed by a 'Wait for response' action, the text will be displayed as part of a USSD prompt.
              - …
            - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
              - …
            - object: Updates the name of the current contact in Telerivet.
              - …
            - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
              - …
            - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
              - …
            - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
              - …
            - object: Within a poll service, skips to a question outside the normal order.
              - …
            - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
              - …
            - object: Stops processing rules for this message (for this service only).
              - …
            - object: Triggers another service for the current contact.
              - …
            - object: Triggers another service for the current message.
              - …
            - object: Triggers another service for the current project.
              - …
            - object: Within a custom route, selects one or more basic routes that can be used to send the message.
              - …
            - object: Waits for the caller to enter digits on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for the caller to press a single key on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
              - …
            - object: Prompts the user for input in the active USSD session, saves the response as a custom variable on the message, and triggers the associated response handler.
              - …
            - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
              - …
      - `response_handlers` object[]: Array of response handler definitions. Response handlers are triggered when the service is waiting for input (e.g., after `wait_response` actions).
        - `state_id` string, required: Unique state identifier for this response handler. Must be a valid variable name and cannot be "initial".
        - `actions` MessageAction[], required: Array of actions to execute when a response is received in this state.
          - union: An action available for `incoming_message_actions` and `message_actions` service types.
            - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
              - …
            - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
              - …
            - object: Updates the name of the current contact in Telerivet.
              - …
            - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
              - …
            - object: Blocks the current contact.
              - …
            - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
              - …
            - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
              - …
            - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
              - …
            - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
              - …
            - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
              - …
            - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
              - …
            - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
              - …
            - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
              - …
            - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
              - …
            - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
              - …
            - object: Triggers another service for the current contact.
              - …
            - object: Triggers another service for the current message.
              - …
            - object: Triggers another service for the current project.
              - …
            - object: Stops processing rules for this message (for this service only).
              - …
            - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
              - …
            - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
              - …
            - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
              - …
            - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
              - …
            - object: Triggers a set of actions which can be reused multiple times in the same service.
              - …
            - object: Sends a voice call to the current contact using a specified IVR service.
              - …
            - object: Pushes the message to a Zendesk support inbox, in a ticket associated with the current contact. Zendesk agents can reply directly to the Zendesk ticket to send a reply to the contact.
              - …
            - object: Pushes the message to a HubSpot Help Desk inbox, in a conversation associated with the current contact. HubSpot agents can reply directly to send a reply to the contact.
              - …
    - object: Configuration for `message_actions` service type.
      - `actions` MessageAction[]: Array of actions to execute. Each action is an object with a `type` property and additional properties depending on the action type. See <a href="/api/rules_engine#actions">Action Reference</a> for documentation of available action types.
        - union: An action available for `incoming_message_actions` and `message_actions` service types.
          - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
            - `type` 'reply', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
          - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
            - `type` 'send_text', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `to_number` string, required: Phone number to send the message to.
          - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
            - `type` 'send_text_to_group', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `group_name` string, required: Name of the group to send the message to.
            - `exclude_sender` boolean: If true, exclude the message sender from receiving the group message.
          - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'add_contact_to_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'remove_contact_from_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
            - `type` 'set_contact', required: Action type identifier
            - `phone_number` string, required: Phone number for the contact to use.
          - object: Updates the name of the current contact in Telerivet.
            - `type` 'set_contact_name', required: Action type identifier
            - `name` string, required: Name to assign to the contact.
          - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
            - `type` 'set_contact_var', required: Action type identifier
            - `variable` string, required: Name of the contact variable to set (without the contact.vars prefix).
            - `value` string: Value to assign to the variable.
          - object: Blocks the current contact.
            - `type` 'block_contact', required: Action type identifier
            - `send_blocked` boolean: If true, block sending messages to this contact. If false, unblock the contact. Default: true.
          - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
            - `type` 'send_email', required: Action type identifier
            - `to_email` string, required: Recipient email address.
            - `subject` string, required: Email subject line.
            - `body_text` string, required: Email body text.
            - `reply_to` string: Reply-to email address.
            - `include_message_attachments` boolean: If true, include any attachments from the current message as email attachments.
          - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
            - `type` 'send_airtime', required: Action type identifier
            - `provider_id` string, required: ID of the airtime provider to use.
            - `products` object[], required: Array of product configurations for different mobile networks or countries.
              - …
            - `actions` Action[]: Array of actions to execute if the contact is on a supported mobile network.
              - …
            - `on_success` string: Name of subroutine to execute when the airtime transaction succeeds.
            - `on_failure` string: Name of subroutine to execute when the airtime transaction fails.
          - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
            - `type` 'add_label_to_message', required: Action type identifier
            - `label_name` string, required: Name of the label to add to the message.
          - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
            - `type` 'star_message', required: Action type identifier
          - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
            - `type` 'set_variable', required: Action type identifier
            - `variable` string, required: Name of the variable to set (e.g. $foo, contact.vars.bar, phone.vars.baz).
            - `value` string, required: Value to assign to the variable.
            - `op` 'plus' | 'minus' | 'times' | 'div': Optional arithmetic operation to perform between value and value2.
            - `value2` string: Second operand for the arithmetic operation (required if op is specified).
          - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
            - `type` 'cancel_scheduled_messages', required: Action type identifier
          - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
            - `type` 'webhook', required: Action type identifier
            - `url` string, required: Webhook URL to receive the HTTP POST request.
            - `secret` string: Secret string passed as POST parameter for request verification.
            - `params` object[]: Custom POST parameters to include in the webhook request, in addition to the standard parameters (max 20). A custom parameter with the same name as a standard parameter (including <code>secret</code>) takes precedence over the standard value.
              - …
          - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
            - `type` 'log', required: Action type identifier
            - `value` string, required: Log message content.
          - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
            - `type` 'run_script', required: Action type identifier
            - `code` string, required: JavaScript code to execute. See <a href="https://telerivet.com/api/script">Cloud Script API</a> for available functions and variables.
          - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
            - `type` 'condition', required: Action type identifier
            - `conditions` object[]: Array of condition objects. Required unless <code>if_mode</code> is <code>else</code>.
              - …
            - `actions` Action[], required: Array of actions to execute if the conditions match.
              - …
            - `op` string: Operator to join multiple conditions. Values: <code>and</code> (all conditions must match), <code>or</code> (any condition must match). Default: <code>or</code>.
            - `if_mode` string: Controls how this condition relates to previous conditions. Values: <code>if</code> (default, starts a new conditional block), <code>else_if</code> (only evaluated if the previous <code>if</code> or <code>else_if</code> did not match), <code>else</code> (executed if none of the previous <code>if</code>/<code>else_if</code> conditions matched; does not require <code>conditions</code> array).
          - object: Triggers another service for the current contact.
            - `type` 'trigger_contact_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
            - `schedule` object: Schedule for when to trigger the service. If not specified, triggers the service immediately.
          - object: Triggers another service for the current message.
            - `type` 'trigger_message_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
          - object: Triggers another service for the current project.
            - `type` 'trigger_project_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
          - object: Stops processing rules for this message (for this service only).
            - `type` 'stop', required: Action type identifier
          - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
            - `type` 'copy_message_to_project', required: Action type identifier
            - `project_id` string, required: ID of the project to copy the message to. Must be a project within the same organization.
          - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
            - `type` 'set_message_var', required: Action type identifier
            - `variable` string, required: Name of the message variable to set (without the vars prefix).
            - `value` string: Value to assign to the variable.
          - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
            - `type` 'wait_response', required: Action type identifier
            - `state_id` string, required: ID of the response handler to process the contact's response.
            - `timeout` object: Schedule for response timeout.
          - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
            - `type` 'send_ussd', required: Action type identifier
            - `mmi_code` string, required: USSD/MMI code to send (e.g. *123#).
            - `route_id` string: ID of the route to send the USSD request from. If not specified, uses the default route.
          - object: Triggers a set of actions which can be reused multiple times in the same service.
            - `type` 'run_subroutine', required: Action type identifier
            - `name` string, required: Name of the subroutine to run.
          - object: Sends a voice call to the current contact using a specified IVR service.
            - `type` 'call_contact', required: Action type identifier
            - `service_id` string, required: ID of the voice/IVR service to use for the call.
            - `route_id` string: ID of the route to use for the call. If not specified, uses the default route.
            - `schedule` object: Schedule for when to make the call. If not specified, calls immediately.
          - object: Pushes the message to a Zendesk support inbox, in a ticket associated with the current contact. Zendesk agents can reply directly to the Zendesk ticket to send a reply to the contact.
            - `type` 'push_to_zendesk', required: Action type identifier
            - `subdomain` string, required: Zendesk subdomain (e.g., "example" for example.zendesk.com).
            - `subject` string, required: Subject line for the Zendesk ticket.
            - `content` string, required: Content of the Zendesk ticket.
          - object: Pushes the message to a HubSpot Help Desk inbox, in a conversation associated with the current contact. HubSpot agents can reply directly to send a reply to the contact.
            - `type` 'push_to_hubspot', required: Action type identifier
            - `integration_id` string, required: ID of the HubSpot channel integration config.
            - `content` string: Content of the message pushed to HubSpot.
      - `subroutines` object[]: Array of subroutine definitions. Subroutines are reusable sets of actions that can be called from the main actions or other subroutines.
        - `name` string, required: Unique name for the subroutine (max 32 characters).
        - `context` string: Context type for the subroutine. If not specified, defaults to the service's context.
        - `actions` Action[], required: Array of actions to execute when the subroutine is called. Available actions depend on the subroutine's context.
          - union: An action in a Custom Actions service. The `type` property determines which action is performed and what additional properties are available. See [Rules Engine Actions](/api/rules_engine#actions) for detailed documentation.
            - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
              - …
            - object: Blocks the current contact.
              - …
            - object: Sends a voice call to the current contact using a specified IVR service.
              - …
            - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
              - …
            - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
              - …
            - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
              - …
            - object: Ends the current USSD session.
              - …
            - object: Within a poll service, skips to the end of the survey.
              - …
            - object: Forwards the incoming call to another phone number.
              - …
            - object: Hangs up the phone call.
              - …
            - object: Within a poll service, ignores the current message.
              - …
            - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
              - …
            - object: Plays an audio file in WAV or MP3 format in the voice call, which may be uploaded, linked, or recorded via the Telerivet web app. Alternatively, can use text-to-speech to speak a message.
              - …
            - object: Pushes the message to a HubSpot Help Desk inbox, in a conversation associated with the current contact. HubSpot agents can reply directly to send a reply to the contact.
              - …
            - object: Pushes the message to a Zendesk support inbox, in a ticket associated with the current contact. Zendesk agents can reply directly to the Zendesk ticket to send a reply to the contact.
              - …
            - object: Records an audio response from the caller, saves the recording URL as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Within a poll service, repeats the current question again.
              - …
            - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text reply to the sender (simple version without labels, schedule, or route configuration).
              - …
            - object: Within a service triggered when a message status changes, will automatically resend the current message via the same route or a different route.
              - …
            - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
              - …
            - object: Triggers a set of actions which can be reused multiple times in the same service.
              - …
            - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
              - …
            - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
              - …
            - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text message to the current contact.
              - …
            - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
              - …
            - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
              - …
            - object: Shows the specified text in the active USSD session. If this action is followed by a 'Wait for response' action, the text will be displayed as part of a USSD prompt.
              - …
            - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
              - …
            - object: Updates the name of the current contact in Telerivet.
              - …
            - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
              - …
            - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
              - …
            - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
              - …
            - object: Within a poll service, skips to a question outside the normal order.
              - …
            - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
              - …
            - object: Stops processing rules for this message (for this service only).
              - …
            - object: Triggers another service for the current contact.
              - …
            - object: Triggers another service for the current message.
              - …
            - object: Triggers another service for the current project.
              - …
            - object: Within a custom route, selects one or more basic routes that can be used to send the message.
              - …
            - object: Waits for the caller to enter digits on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for the caller to press a single key on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
              - …
            - object: Prompts the user for input in the active USSD session, saves the response as a custom variable on the message, and triggers the associated response handler.
              - …
            - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
              - …
      - `response_handlers` object[]: Array of response handler definitions. Response handlers are triggered when the service is waiting for input (e.g., after `wait_response` actions).
        - `state_id` string, required: Unique state identifier for this response handler. Must be a valid variable name and cannot be "initial".
        - `actions` MessageAction[], required: Array of actions to execute when a response is received in this state.
          - union: An action available for `incoming_message_actions` and `message_actions` service types.
            - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
              - …
            - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
              - …
            - object: Updates the name of the current contact in Telerivet.
              - …
            - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
              - …
            - object: Blocks the current contact.
              - …
            - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
              - …
            - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
              - …
            - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
              - …
            - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
              - …
            - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
              - …
            - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
              - …
            - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
              - …
            - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
              - …
            - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
              - …
            - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
              - …
            - object: Triggers another service for the current contact.
              - …
            - object: Triggers another service for the current message.
              - …
            - object: Triggers another service for the current project.
              - …
            - object: Stops processing rules for this message (for this service only).
              - …
            - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
              - …
            - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
              - …
            - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
              - …
            - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
              - …
            - object: Triggers a set of actions which can be reused multiple times in the same service.
              - …
            - object: Sends a voice call to the current contact using a specified IVR service.
              - …
            - object: Pushes the message to a Zendesk support inbox, in a ticket associated with the current contact. Zendesk agents can reply directly to the Zendesk ticket to send a reply to the contact.
              - …
            - object: Pushes the message to a HubSpot Help Desk inbox, in a conversation associated with the current contact. HubSpot agents can reply directly to send a reply to the contact.
              - …
    - object: Configuration for `project_actions` service type.
      - `actions` ProjectAction[]: Array of actions to execute. Each action is an object with a `type` property and additional properties depending on the action type. See <a href="/api/rules_engine#actions">Action Reference</a> for documentation of available action types.
        - union: An action available for `project_actions` and `scheduled_actions` service types.
          - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
            - `type` 'send_text', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `to_number` string, required: Phone number to send the message to.
          - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
            - `type` 'send_text_to_group', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `group_name` string, required: Name of the group to send the message to.
            - `exclude_sender` boolean: If true, exclude the message sender from receiving the group message.
          - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
            - `type` 'send_ussd', required: Action type identifier
            - `mmi_code` string, required: USSD/MMI code to send (e.g. *123#).
            - `route_id` string: ID of the route to send the USSD request from. If not specified, uses the default route.
          - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
            - `type` 'send_email', required: Action type identifier
            - `to_email` string, required: Recipient email address.
            - `subject` string, required: Email subject line.
            - `body_text` string, required: Email body text.
            - `reply_to` string: Reply-to email address.
            - `include_message_attachments` boolean: If true, include any attachments from the current message as email attachments.
          - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
            - `type` 'set_variable', required: Action type identifier
            - `variable` string, required: Name of the variable to set (e.g. $foo, contact.vars.bar, phone.vars.baz).
            - `value` string, required: Value to assign to the variable.
            - `op` 'plus' | 'minus' | 'times' | 'div': Optional arithmetic operation to perform between value and value2.
            - `value2` string: Second operand for the arithmetic operation (required if op is specified).
          - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
            - `type` 'webhook', required: Action type identifier
            - `url` string, required: Webhook URL to receive the HTTP POST request.
            - `secret` string: Secret string passed as POST parameter for request verification.
            - `params` object[]: Custom POST parameters to include in the webhook request, in addition to the standard parameters (max 20). A custom parameter with the same name as a standard parameter (including <code>secret</code>) takes precedence over the standard value.
              - …
          - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
            - `type` 'log', required: Action type identifier
            - `value` string, required: Log message content.
          - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
            - `type` 'run_script', required: Action type identifier
            - `code` string, required: JavaScript code to execute. See <a href="https://telerivet.com/api/script">Cloud Script API</a> for available functions and variables.
          - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
            - `type` 'condition', required: Action type identifier
            - `conditions` object[]: Array of condition objects. Required unless <code>if_mode</code> is <code>else</code>.
              - …
            - `actions` Action[], required: Array of actions to execute if the conditions match.
              - …
            - `op` string: Operator to join multiple conditions. Values: <code>and</code> (all conditions must match), <code>or</code> (any condition must match). Default: <code>or</code>.
            - `if_mode` string: Controls how this condition relates to previous conditions. Values: <code>if</code> (default, starts a new conditional block), <code>else_if</code> (only evaluated if the previous <code>if</code> or <code>else_if</code> did not match), <code>else</code> (executed if none of the previous <code>if</code>/<code>else_if</code> conditions matched; does not require <code>conditions</code> array).
          - object: Stops processing rules for this message (for this service only).
            - `type` 'stop', required: Action type identifier
          - object: Triggers a set of actions which can be reused multiple times in the same service.
            - `type` 'run_subroutine', required: Action type identifier
            - `name` string, required: Name of the subroutine to run.
          - object: Triggers another service for the current project.
            - `type` 'trigger_project_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
      - `subroutines` object[]: Array of subroutine definitions. Subroutines are reusable sets of actions that can be called from the main actions or other subroutines.
        - `name` string, required: Unique name for the subroutine (max 32 characters).
        - `context` string: Context type for the subroutine. If not specified, defaults to the service's context.
        - `actions` Action[], required: Array of actions to execute when the subroutine is called. Available actions depend on the subroutine's context.
          - union: An action in a Custom Actions service. The `type` property determines which action is performed and what additional properties are available. See [Rules Engine Actions](/api/rules_engine#actions) for detailed documentation.
            - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
              - …
            - object: Blocks the current contact.
              - …
            - object: Sends a voice call to the current contact using a specified IVR service.
              - …
            - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
              - …
            - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
              - …
            - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
              - …
            - object: Ends the current USSD session.
              - …
            - object: Within a poll service, skips to the end of the survey.
              - …
            - object: Forwards the incoming call to another phone number.
              - …
            - object: Hangs up the phone call.
              - …
            - object: Within a poll service, ignores the current message.
              - …
            - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
              - …
            - object: Plays an audio file in WAV or MP3 format in the voice call, which may be uploaded, linked, or recorded via the Telerivet web app. Alternatively, can use text-to-speech to speak a message.
              - …
            - object: Pushes the message to a HubSpot Help Desk inbox, in a conversation associated with the current contact. HubSpot agents can reply directly to send a reply to the contact.
              - …
            - object: Pushes the message to a Zendesk support inbox, in a ticket associated with the current contact. Zendesk agents can reply directly to the Zendesk ticket to send a reply to the contact.
              - …
            - object: Records an audio response from the caller, saves the recording URL as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Within a poll service, repeats the current question again.
              - …
            - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text reply to the sender (simple version without labels, schedule, or route configuration).
              - …
            - object: Within a service triggered when a message status changes, will automatically resend the current message via the same route or a different route.
              - …
            - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
              - …
            - object: Triggers a set of actions which can be reused multiple times in the same service.
              - …
            - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
              - …
            - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
              - …
            - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text message to the current contact.
              - …
            - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
              - …
            - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
              - …
            - object: Shows the specified text in the active USSD session. If this action is followed by a 'Wait for response' action, the text will be displayed as part of a USSD prompt.
              - …
            - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
              - …
            - object: Updates the name of the current contact in Telerivet.
              - …
            - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
              - …
            - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
              - …
            - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
              - …
            - object: Within a poll service, skips to a question outside the normal order.
              - …
            - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
              - …
            - object: Stops processing rules for this message (for this service only).
              - …
            - object: Triggers another service for the current contact.
              - …
            - object: Triggers another service for the current message.
              - …
            - object: Triggers another service for the current project.
              - …
            - object: Within a custom route, selects one or more basic routes that can be used to send the message.
              - …
            - object: Waits for the caller to enter digits on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for the caller to press a single key on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
              - …
            - object: Prompts the user for input in the active USSD session, saves the response as a custom variable on the message, and triggers the associated response handler.
              - …
            - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
              - …
    - object: Configuration for `message_status_actions` service type.
      - `actions` MessageStatusAction[]: Array of actions to execute. Each action is an object with a `type` property and additional properties depending on the action type. See <a href="/api/rules_engine#actions">Action Reference</a> for documentation of available action types.
        - union: An action available for `message_status_actions` service type.
          - object: Within a service triggered when a message status changes, will automatically resend the current message via the same route or a different route.
            - `type` 'resend_message', required: Action type identifier
            - `route_id` string: ID of the route to resend the message from. If not specified, uses the original route.
            - `schedule` object: Schedule for when to resend the message. If not specified, resends immediately.
          - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'add_contact_to_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'remove_contact_from_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
            - `type` 'set_contact_var', required: Action type identifier
            - `variable` string, required: Name of the contact variable to set (without the contact.vars prefix).
            - `value` string: Value to assign to the variable.
          - object: Blocks the current contact.
            - `type` 'block_contact', required: Action type identifier
            - `send_blocked` boolean: If true, block sending messages to this contact. If false, unblock the contact. Default: true.
          - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
            - `type` 'send_email', required: Action type identifier
            - `to_email` string, required: Recipient email address.
            - `subject` string, required: Email subject line.
            - `body_text` string, required: Email body text.
            - `reply_to` string: Reply-to email address.
            - `include_message_attachments` boolean: If true, include any attachments from the current message as email attachments.
          - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
            - `type` 'add_label_to_message', required: Action type identifier
            - `label_name` string, required: Name of the label to add to the message.
          - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
            - `type` 'star_message', required: Action type identifier
          - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
            - `type` 'set_variable', required: Action type identifier
            - `variable` string, required: Name of the variable to set (e.g. $foo, contact.vars.bar, phone.vars.baz).
            - `value` string, required: Value to assign to the variable.
            - `op` 'plus' | 'minus' | 'times' | 'div': Optional arithmetic operation to perform between value and value2.
            - `value2` string: Second operand for the arithmetic operation (required if op is specified).
          - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
            - `type` 'cancel_scheduled_messages', required: Action type identifier
          - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
            - `type` 'webhook', required: Action type identifier
            - `url` string, required: Webhook URL to receive the HTTP POST request.
            - `secret` string: Secret string passed as POST parameter for request verification.
            - `params` object[]: Custom POST parameters to include in the webhook request, in addition to the standard parameters (max 20). A custom parameter with the same name as a standard parameter (including <code>secret</code>) takes precedence over the standard value.
              - …
          - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
            - `type` 'log', required: Action type identifier
            - `value` string, required: Log message content.
          - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
            - `type` 'condition', required: Action type identifier
            - `conditions` object[]: Array of condition objects. Required unless <code>if_mode</code> is <code>else</code>.
              - …
            - `actions` Action[], required: Array of actions to execute if the conditions match.
              - …
            - `op` string: Operator to join multiple conditions. Values: <code>and</code> (all conditions must match), <code>or</code> (any condition must match). Default: <code>or</code>.
            - `if_mode` string: Controls how this condition relates to previous conditions. Values: <code>if</code> (default, starts a new conditional block), <code>else_if</code> (only evaluated if the previous <code>if</code> or <code>else_if</code> did not match), <code>else</code> (executed if none of the previous <code>if</code>/<code>else_if</code> conditions matched; does not require <code>conditions</code> array).
          - object: Stops processing rules for this message (for this service only).
            - `type` 'stop', required: Action type identifier
          - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
            - `type` 'copy_message_to_project', required: Action type identifier
            - `project_id` string, required: ID of the project to copy the message to. Must be a project within the same organization.
          - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
            - `type` 'set_message_var', required: Action type identifier
            - `variable` string, required: Name of the message variable to set (without the vars prefix).
            - `value` string: Value to assign to the variable.
          - object: Triggers a set of actions which can be reused multiple times in the same service.
            - `type` 'run_subroutine', required: Action type identifier
            - `name` string, required: Name of the subroutine to run.
          - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
            - `type` 'run_script', required: Action type identifier
            - `code` string, required: JavaScript code to execute. See <a href="https://telerivet.com/api/script">Cloud Script API</a> for available functions and variables.
          - object: Triggers another service for the current contact.
            - `type` 'trigger_contact_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
            - `schedule` object: Schedule for when to trigger the service. If not specified, triggers the service immediately.
          - object: Triggers another service for the current message.
            - `type` 'trigger_message_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
          - object: Triggers another service for the current project.
            - `type` 'trigger_project_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
      - `subroutines` object[]: Array of subroutine definitions. Subroutines are reusable sets of actions that can be called from the main actions or other subroutines.
        - `name` string, required: Unique name for the subroutine (max 32 characters).
        - `context` string: Context type for the subroutine. If not specified, defaults to the service's context.
        - `actions` Action[], required: Array of actions to execute when the subroutine is called. Available actions depend on the subroutine's context.
          - union: An action in a Custom Actions service. The `type` property determines which action is performed and what additional properties are available. See [Rules Engine Actions](/api/rules_engine#actions) for detailed documentation.
            - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
              - …
            - object: Blocks the current contact.
              - …
            - object: Sends a voice call to the current contact using a specified IVR service.
              - …
            - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
              - …
            - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
              - …
            - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
              - …
            - object: Ends the current USSD session.
              - …
            - object: Within a poll service, skips to the end of the survey.
              - …
            - object: Forwards the incoming call to another phone number.
              - …
            - object: Hangs up the phone call.
              - …
            - object: Within a poll service, ignores the current message.
              - …
            - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
              - …
            - object: Plays an audio file in WAV or MP3 format in the voice call, which may be uploaded, linked, or recorded via the Telerivet web app. Alternatively, can use text-to-speech to speak a message.
              - …
            - object: Pushes the message to a HubSpot Help Desk inbox, in a conversation associated with the current contact. HubSpot agents can reply directly to send a reply to the contact.
              - …
            - object: Pushes the message to a Zendesk support inbox, in a ticket associated with the current contact. Zendesk agents can reply directly to the Zendesk ticket to send a reply to the contact.
              - …
            - object: Records an audio response from the caller, saves the recording URL as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Within a poll service, repeats the current question again.
              - …
            - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text reply to the sender (simple version without labels, schedule, or route configuration).
              - …
            - object: Within a service triggered when a message status changes, will automatically resend the current message via the same route or a different route.
              - …
            - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
              - …
            - object: Triggers a set of actions which can be reused multiple times in the same service.
              - …
            - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
              - …
            - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
              - …
            - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text message to the current contact.
              - …
            - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
              - …
            - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
              - …
            - object: Shows the specified text in the active USSD session. If this action is followed by a 'Wait for response' action, the text will be displayed as part of a USSD prompt.
              - …
            - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
              - …
            - object: Updates the name of the current contact in Telerivet.
              - …
            - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
              - …
            - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
              - …
            - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
              - …
            - object: Within a poll service, skips to a question outside the normal order.
              - …
            - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
              - …
            - object: Stops processing rules for this message (for this service only).
              - …
            - object: Triggers another service for the current contact.
              - …
            - object: Triggers another service for the current message.
              - …
            - object: Triggers another service for the current project.
              - …
            - object: Within a custom route, selects one or more basic routes that can be used to send the message.
              - …
            - object: Waits for the caller to enter digits on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for the caller to press a single key on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
              - …
            - object: Prompts the user for input in the active USSD session, saves the response as a custom variable on the message, and triggers the associated response handler.
              - …
            - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
              - …
    - object: Configuration for `voice_actions` service type.
      - `actions` VoiceAction[]: Array of actions to execute. Each action is an object with a `type` property and additional properties depending on the action type. See <a href="/api/rules_engine#actions">Action Reference</a> for documentation of available action types.
        - union: An action available for `voice_actions` service type.
          - object: Plays an audio file in WAV or MP3 format in the voice call, which may be uploaded, linked, or recorded via the Telerivet web app. Alternatively, can use text-to-speech to speak a message.
            - `type` 'play_audio', required: Action type identifier
            - `mode` 'file' | 'tts', required: Audio source mode.
            - `audio_url` string: URL of the audio file to play (WAV or MP3). Required when mode is "file".
            - `audio_title` string: Title for the audio file displayed in the web app (not played to the caller). Used when mode is "file".
            - `text` string: Text to speak using text-to-speech. Required when mode is "tts". If mode is "file", the text is not used in the actual call but is displayed as the transcript of the file within the web app.
            - `language` string: Language code for text-to-speech (e.g., "en-US"). Used when mode is "tts".
            - `voice` string: Voice for text-to-speech (e.g., "man", "woman"). Used when mode is "tts".
            - `repeat` boolean: If true, repeat the audio once after a short pause.
          - object: Plays an audio file in WAV or MP3 format in the voice call, which may be uploaded, linked, or recorded via the Telerivet web app. Alternatively, can use text-to-speech to speak a message.
            - `type` 'play_audio', required: Action type identifier
            - `mode` 'file' | 'tts', required: Audio source mode.
            - `audio_url` string: URL of the audio file to play (WAV or MP3). Required when mode is "file".
            - `audio_title` string: Title for the audio file displayed in the web app (not played to the caller). Used when mode is "file".
            - `text` string: Text to speak using text-to-speech. Required when mode is "tts". If mode is "file", the text is not used in the actual call but is displayed as the transcript of the file within the web app.
            - `language` string: Language code for text-to-speech (e.g., "en-US"). Used when mode is "tts".
            - `voice` string: Voice for text-to-speech (e.g., "man", "woman"). Used when mode is "tts".
            - `repeat` boolean: If true, repeat the audio once after a short pause.
          - object: Forwards the incoming call to another phone number.
            - `type` 'forward_call', required: Action type identifier
            - `phone_number` string, required: Phone number to forward the call to.
          - object: Sends a voice call to the current contact using a specified IVR service.
            - `type` 'call_contact', required: Action type identifier
            - `service_id` string, required: ID of the voice/IVR service to use for the call.
            - `route_id` string: ID of the route to use for the call. If not specified, uses the default route.
            - `schedule` object: Schedule for when to make the call. If not specified, calls immediately.
          - object: Hangs up the phone call.
            - `type` 'hangup', required: Action type identifier
          - object: Records an audio response from the caller, saves the recording URL as a custom variable on the message, then triggers the associated response handler.
            - `type` 'record_audio', required: Action type identifier
            - `state_id` string, required: ID of the response handler that will be triggered when the recording is received (e.g., "recording"). Also used as the name of the variable where the recording URL will be stored (e.g. [[vars.recording]]).
          - object: Waits for the caller to press a single key on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
            - `type` 'wait_for_key', required: Action type identifier
            - `state_id` string, required: ID of the response handler that will be triggered when the key is pressed (e.g., "input"). Also used as the name of the variable where the pressed key will be stored (e.g. [[vars.input]]).
          - object: Waits for the caller to enter digits on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
            - `type` 'wait_for_digits', required: Action type identifier
            - `state_id` string, required: ID of the response handler that will be triggered when the response is received (e.g., "input"). Also used as the name of the variable where the entered digits will be stored (e.g. [[vars.input]].
            - `max_digits` number, required: Maximum number of digits to wait for.
            - `timeout` number: Number of seconds to wait after the last key press. Default: 10.
            - `submit_on_hash` boolean: If true, submit the input when the caller presses #.
          - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
            - `type` 'reply', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
          - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
            - `type` 'send_text', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `to_number` string, required: Phone number to send the message to.
          - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
            - `type` 'send_text_to_group', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `group_name` string, required: Name of the group to send the message to.
            - `exclude_sender` boolean: If true, exclude the message sender from receiving the group message.
          - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'add_contact_to_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'remove_contact_from_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
            - `type` 'set_contact', required: Action type identifier
            - `phone_number` string, required: Phone number for the contact to use.
          - object: Updates the name of the current contact in Telerivet.
            - `type` 'set_contact_name', required: Action type identifier
            - `name` string, required: Name to assign to the contact.
          - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
            - `type` 'set_contact_var', required: Action type identifier
            - `variable` string, required: Name of the contact variable to set (without the contact.vars prefix).
            - `value` string: Value to assign to the variable.
          - object: Blocks the current contact.
            - `type` 'block_contact', required: Action type identifier
            - `send_blocked` boolean: If true, block sending messages to this contact. If false, unblock the contact. Default: true.
          - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
            - `type` 'send_email', required: Action type identifier
            - `to_email` string, required: Recipient email address.
            - `subject` string, required: Email subject line.
            - `body_text` string, required: Email body text.
            - `reply_to` string: Reply-to email address.
            - `include_message_attachments` boolean: If true, include any attachments from the current message as email attachments.
          - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
            - `type` 'send_airtime', required: Action type identifier
            - `provider_id` string, required: ID of the airtime provider to use.
            - `products` object[], required: Array of product configurations for different mobile networks or countries.
              - …
            - `actions` Action[]: Array of actions to execute if the contact is on a supported mobile network.
              - …
            - `on_success` string: Name of subroutine to execute when the airtime transaction succeeds.
            - `on_failure` string: Name of subroutine to execute when the airtime transaction fails.
          - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
            - `type` 'add_label_to_message', required: Action type identifier
            - `label_name` string, required: Name of the label to add to the message.
          - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
            - `type` 'star_message', required: Action type identifier
          - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
            - `type` 'set_variable', required: Action type identifier
            - `variable` string, required: Name of the variable to set (e.g. $foo, contact.vars.bar, phone.vars.baz).
            - `value` string, required: Value to assign to the variable.
            - `op` 'plus' | 'minus' | 'times' | 'div': Optional arithmetic operation to perform between value and value2.
            - `value2` string: Second operand for the arithmetic operation (required if op is specified).
          - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
            - `type` 'cancel_scheduled_messages', required: Action type identifier
          - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
            - `type` 'webhook', required: Action type identifier
            - `url` string, required: Webhook URL to receive the HTTP POST request.
            - `secret` string: Secret string passed as POST parameter for request verification.
            - `params` object[]: Custom POST parameters to include in the webhook request, in addition to the standard parameters (max 20). A custom parameter with the same name as a standard parameter (including <code>secret</code>) takes precedence over the standard value.
              - …
          - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
            - `type` 'log', required: Action type identifier
            - `value` string, required: Log message content.
          - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
            - `type` 'run_script', required: Action type identifier
            - `code` string, required: JavaScript code to execute. See <a href="https://telerivet.com/api/script">Cloud Script API</a> for available functions and variables.
          - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
            - `type` 'condition', required: Action type identifier
            - `conditions` object[]: Array of condition objects. Required unless <code>if_mode</code> is <code>else</code>.
              - …
            - `actions` Action[], required: Array of actions to execute if the conditions match.
              - …
            - `op` string: Operator to join multiple conditions. Values: <code>and</code> (all conditions must match), <code>or</code> (any condition must match). Default: <code>or</code>.
            - `if_mode` string: Controls how this condition relates to previous conditions. Values: <code>if</code> (default, starts a new conditional block), <code>else_if</code> (only evaluated if the previous <code>if</code> or <code>else_if</code> did not match), <code>else</code> (executed if none of the previous <code>if</code>/<code>else_if</code> conditions matched; does not require <code>conditions</code> array).
          - object: Triggers another service for the current contact.
            - `type` 'trigger_contact_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
            - `schedule` object: Schedule for when to trigger the service. If not specified, triggers the service immediately.
          - object: Triggers another service for the current message.
            - `type` 'trigger_message_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
          - object: Triggers another service for the current project.
            - `type` 'trigger_project_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
          - object: Stops processing rules for this message (for this service only).
            - `type` 'stop', required: Action type identifier
          - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
            - `type` 'copy_message_to_project', required: Action type identifier
            - `project_id` string, required: ID of the project to copy the message to. Must be a project within the same organization.
          - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
            - `type` 'set_message_var', required: Action type identifier
            - `variable` string, required: Name of the message variable to set (without the vars prefix).
            - `value` string: Value to assign to the variable.
          - object: Triggers a set of actions which can be reused multiple times in the same service.
            - `type` 'run_subroutine', required: Action type identifier
            - `name` string, required: Name of the subroutine to run.
      - `subroutines` object[]: Array of subroutine definitions. Subroutines are reusable sets of actions that can be called from the main actions or other subroutines.
        - `name` string, required: Unique name for the subroutine (max 32 characters).
        - `context` string: Context type for the subroutine. If not specified, defaults to the service's context.
        - `actions` Action[], required: Array of actions to execute when the subroutine is called. Available actions depend on the subroutine's context.
          - union: An action in a Custom Actions service. The `type` property determines which action is performed and what additional properties are available. See [Rules Engine Actions](/api/rules_engine#actions) for detailed documentation.
            - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
              - …
            - object: Blocks the current contact.
              - …
            - object: Sends a voice call to the current contact using a specified IVR service.
              - …
            - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
              - …
            - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
              - …
            - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
              - …
            - object: Ends the current USSD session.
              - …
            - object: Within a poll service, skips to the end of the survey.
              - …
            - object: Forwards the incoming call to another phone number.
              - …
            - object: Hangs up the phone call.
              - …
            - object: Within a poll service, ignores the current message.
              - …
            - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
              - …
            - object: Plays an audio file in WAV or MP3 format in the voice call, which may be uploaded, linked, or recorded via the Telerivet web app. Alternatively, can use text-to-speech to speak a message.
              - …
            - object: Pushes the message to a HubSpot Help Desk inbox, in a conversation associated with the current contact. HubSpot agents can reply directly to send a reply to the contact.
              - …
            - object: Pushes the message to a Zendesk support inbox, in a ticket associated with the current contact. Zendesk agents can reply directly to the Zendesk ticket to send a reply to the contact.
              - …
            - object: Records an audio response from the caller, saves the recording URL as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Within a poll service, repeats the current question again.
              - …
            - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text reply to the sender (simple version without labels, schedule, or route configuration).
              - …
            - object: Within a service triggered when a message status changes, will automatically resend the current message via the same route or a different route.
              - …
            - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
              - …
            - object: Triggers a set of actions which can be reused multiple times in the same service.
              - …
            - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
              - …
            - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
              - …
            - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text message to the current contact.
              - …
            - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
              - …
            - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
              - …
            - object: Shows the specified text in the active USSD session. If this action is followed by a 'Wait for response' action, the text will be displayed as part of a USSD prompt.
              - …
            - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
              - …
            - object: Updates the name of the current contact in Telerivet.
              - …
            - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
              - …
            - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
              - …
            - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
              - …
            - object: Within a poll service, skips to a question outside the normal order.
              - …
            - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
              - …
            - object: Stops processing rules for this message (for this service only).
              - …
            - object: Triggers another service for the current contact.
              - …
            - object: Triggers another service for the current message.
              - …
            - object: Triggers another service for the current project.
              - …
            - object: Within a custom route, selects one or more basic routes that can be used to send the message.
              - …
            - object: Waits for the caller to enter digits on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for the caller to press a single key on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
              - …
            - object: Prompts the user for input in the active USSD session, saves the response as a custom variable on the message, and triggers the associated response handler.
              - …
            - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
              - …
      - `response_handlers` object[]: Array of response handler definitions. Response handlers are triggered when the service is waiting for input (e.g., after `prompt_key`, `prompt_digits`, or `record_audio` actions).
        - `state_id` string, required: Unique state identifier for this response handler. Must be a valid variable name and cannot be "initial".
        - `actions` VoiceAction[], required: Array of actions to execute when a response is received in this state.
          - union: An action available for `voice_actions` service type.
            - object: Plays an audio file in WAV or MP3 format in the voice call, which may be uploaded, linked, or recorded via the Telerivet web app. Alternatively, can use text-to-speech to speak a message.
              - …
            - object: Plays an audio file in WAV or MP3 format in the voice call, which may be uploaded, linked, or recorded via the Telerivet web app. Alternatively, can use text-to-speech to speak a message.
              - …
            - object: Forwards the incoming call to another phone number.
              - …
            - object: Sends a voice call to the current contact using a specified IVR service.
              - …
            - object: Hangs up the phone call.
              - …
            - object: Records an audio response from the caller, saves the recording URL as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for the caller to press a single key on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for the caller to enter digits on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
              - …
            - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
              - …
            - object: Updates the name of the current contact in Telerivet.
              - …
            - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
              - …
            - object: Blocks the current contact.
              - …
            - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
              - …
            - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
              - …
            - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
              - …
            - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
              - …
            - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
              - …
            - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
              - …
            - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
              - …
            - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
              - …
            - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
              - …
            - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
              - …
            - object: Triggers another service for the current contact.
              - …
            - object: Triggers another service for the current message.
              - …
            - object: Triggers another service for the current project.
              - …
            - object: Stops processing rules for this message (for this service only).
              - …
            - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
              - …
            - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
              - …
            - object: Triggers a set of actions which can be reused multiple times in the same service.
              - …
    - object: Configuration for `ussd_actions` service type.
      - `actions` USSDAction[]: Array of actions to execute. Each action is an object with a `type` property and additional properties depending on the action type. See <a href="/api/rules_engine#actions">Action Reference</a> for documentation of available action types.
        - union: An action available for `ussd_actions` service type.
          - object: Shows the specified text in the active USSD session. If this action is followed by a 'Wait for response' action, the text will be displayed as part of a USSD prompt.
            - `type` 'send_ussd_reply', required: Action type identifier
            - `text` string, required: Text to display in the USSD session.
          - object: Ends the current USSD session.
            - `type` 'end_session', required: Action type identifier
          - object: Prompts the user for input in the active USSD session, saves the response as a custom variable on the message, and triggers the associated response handler.
            - `type` 'wait_ussd_response', required: Action type identifier
            - `state_id` string, required: ID of the response handler that will be triggered when the response is received (e.g., "input"). Also used as the name of the variable where the USSD response will be stored (e.g. [[vars.input]]).
          - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
            - `type` 'reply', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
          - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
            - `type` 'send_text', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `to_number` string, required: Phone number to send the message to.
          - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
            - `type` 'send_text_to_group', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `group_name` string, required: Name of the group to send the message to.
            - `exclude_sender` boolean: If true, exclude the message sender from receiving the group message.
          - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'add_contact_to_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'remove_contact_from_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
            - `type` 'set_contact', required: Action type identifier
            - `phone_number` string, required: Phone number for the contact to use.
          - object: Updates the name of the current contact in Telerivet.
            - `type` 'set_contact_name', required: Action type identifier
            - `name` string, required: Name to assign to the contact.
          - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
            - `type` 'set_contact_var', required: Action type identifier
            - `variable` string, required: Name of the contact variable to set (without the contact.vars prefix).
            - `value` string: Value to assign to the variable.
          - object: Blocks the current contact.
            - `type` 'block_contact', required: Action type identifier
            - `send_blocked` boolean: If true, block sending messages to this contact. If false, unblock the contact. Default: true.
          - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
            - `type` 'send_email', required: Action type identifier
            - `to_email` string, required: Recipient email address.
            - `subject` string, required: Email subject line.
            - `body_text` string, required: Email body text.
            - `reply_to` string: Reply-to email address.
            - `include_message_attachments` boolean: If true, include any attachments from the current message as email attachments.
          - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
            - `type` 'send_airtime', required: Action type identifier
            - `provider_id` string, required: ID of the airtime provider to use.
            - `products` object[], required: Array of product configurations for different mobile networks or countries.
              - …
            - `actions` Action[]: Array of actions to execute if the contact is on a supported mobile network.
              - …
            - `on_success` string: Name of subroutine to execute when the airtime transaction succeeds.
            - `on_failure` string: Name of subroutine to execute when the airtime transaction fails.
          - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
            - `type` 'add_label_to_message', required: Action type identifier
            - `label_name` string, required: Name of the label to add to the message.
          - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
            - `type` 'star_message', required: Action type identifier
          - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
            - `type` 'set_variable', required: Action type identifier
            - `variable` string, required: Name of the variable to set (e.g. $foo, contact.vars.bar, phone.vars.baz).
            - `value` string, required: Value to assign to the variable.
            - `op` 'plus' | 'minus' | 'times' | 'div': Optional arithmetic operation to perform between value and value2.
            - `value2` string: Second operand for the arithmetic operation (required if op is specified).
          - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
            - `type` 'cancel_scheduled_messages', required: Action type identifier
          - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
            - `type` 'webhook', required: Action type identifier
            - `url` string, required: Webhook URL to receive the HTTP POST request.
            - `secret` string: Secret string passed as POST parameter for request verification.
            - `params` object[]: Custom POST parameters to include in the webhook request, in addition to the standard parameters (max 20). A custom parameter with the same name as a standard parameter (including <code>secret</code>) takes precedence over the standard value.
              - …
          - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
            - `type` 'log', required: Action type identifier
            - `value` string, required: Log message content.
          - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
            - `type` 'run_script', required: Action type identifier
            - `code` string, required: JavaScript code to execute. See <a href="https://telerivet.com/api/script">Cloud Script API</a> for available functions and variables.
          - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
            - `type` 'condition', required: Action type identifier
            - `conditions` object[]: Array of condition objects. Required unless <code>if_mode</code> is <code>else</code>.
              - …
            - `actions` Action[], required: Array of actions to execute if the conditions match.
              - …
            - `op` string: Operator to join multiple conditions. Values: <code>and</code> (all conditions must match), <code>or</code> (any condition must match). Default: <code>or</code>.
            - `if_mode` string: Controls how this condition relates to previous conditions. Values: <code>if</code> (default, starts a new conditional block), <code>else_if</code> (only evaluated if the previous <code>if</code> or <code>else_if</code> did not match), <code>else</code> (executed if none of the previous <code>if</code>/<code>else_if</code> conditions matched; does not require <code>conditions</code> array).
          - object: Triggers another service for the current contact.
            - `type` 'trigger_contact_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
            - `schedule` object: Schedule for when to trigger the service. If not specified, triggers the service immediately.
          - object: Triggers another service for the current message.
            - `type` 'trigger_message_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
          - object: Triggers another service for the current project.
            - `type` 'trigger_project_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
          - object: Stops processing rules for this message (for this service only).
            - `type` 'stop', required: Action type identifier
          - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
            - `type` 'copy_message_to_project', required: Action type identifier
            - `project_id` string, required: ID of the project to copy the message to. Must be a project within the same organization.
          - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
            - `type` 'set_message_var', required: Action type identifier
            - `variable` string, required: Name of the message variable to set (without the vars prefix).
            - `value` string: Value to assign to the variable.
          - object: Triggers a set of actions which can be reused multiple times in the same service.
            - `type` 'run_subroutine', required: Action type identifier
            - `name` string, required: Name of the subroutine to run.
      - `subroutines` object[]: Array of subroutine definitions. Subroutines are reusable sets of actions that can be called from the main actions or other subroutines.
        - `name` string, required: Unique name for the subroutine (max 32 characters).
        - `context` string: Context type for the subroutine. If not specified, defaults to the service's context.
        - `actions` Action[], required: Array of actions to execute when the subroutine is called. Available actions depend on the subroutine's context.
          - union: An action in a Custom Actions service. The `type` property determines which action is performed and what additional properties are available. See [Rules Engine Actions](/api/rules_engine#actions) for detailed documentation.
            - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
              - …
            - object: Blocks the current contact.
              - …
            - object: Sends a voice call to the current contact using a specified IVR service.
              - …
            - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
              - …
            - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
              - …
            - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
              - …
            - object: Ends the current USSD session.
              - …
            - object: Within a poll service, skips to the end of the survey.
              - …
            - object: Forwards the incoming call to another phone number.
              - …
            - object: Hangs up the phone call.
              - …
            - object: Within a poll service, ignores the current message.
              - …
            - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
              - …
            - object: Plays an audio file in WAV or MP3 format in the voice call, which may be uploaded, linked, or recorded via the Telerivet web app. Alternatively, can use text-to-speech to speak a message.
              - …
            - object: Pushes the message to a HubSpot Help Desk inbox, in a conversation associated with the current contact. HubSpot agents can reply directly to send a reply to the contact.
              - …
            - object: Pushes the message to a Zendesk support inbox, in a ticket associated with the current contact. Zendesk agents can reply directly to the Zendesk ticket to send a reply to the contact.
              - …
            - object: Records an audio response from the caller, saves the recording URL as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Within a poll service, repeats the current question again.
              - …
            - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text reply to the sender (simple version without labels, schedule, or route configuration).
              - …
            - object: Within a service triggered when a message status changes, will automatically resend the current message via the same route or a different route.
              - …
            - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
              - …
            - object: Triggers a set of actions which can be reused multiple times in the same service.
              - …
            - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
              - …
            - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
              - …
            - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text message to the current contact.
              - …
            - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
              - …
            - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
              - …
            - object: Shows the specified text in the active USSD session. If this action is followed by a 'Wait for response' action, the text will be displayed as part of a USSD prompt.
              - …
            - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
              - …
            - object: Updates the name of the current contact in Telerivet.
              - …
            - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
              - …
            - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
              - …
            - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
              - …
            - object: Within a poll service, skips to a question outside the normal order.
              - …
            - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
              - …
            - object: Stops processing rules for this message (for this service only).
              - …
            - object: Triggers another service for the current contact.
              - …
            - object: Triggers another service for the current message.
              - …
            - object: Triggers another service for the current project.
              - …
            - object: Within a custom route, selects one or more basic routes that can be used to send the message.
              - …
            - object: Waits for the caller to enter digits on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for the caller to press a single key on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
              - …
            - object: Prompts the user for input in the active USSD session, saves the response as a custom variable on the message, and triggers the associated response handler.
              - …
            - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
              - …
      - `response_handlers` object[]: Array of response handler definitions. Response handlers are triggered when the service is waiting for input (e.g., after `wait_ussd_response` actions).
        - `state_id` string, required: Unique state identifier for this response handler. Must be a valid variable name and cannot be "initial".
        - `actions` USSDAction[], required: Array of actions to execute when a response is received in this state.
          - union: An action available for `ussd_actions` service type.
            - object: Shows the specified text in the active USSD session. If this action is followed by a 'Wait for response' action, the text will be displayed as part of a USSD prompt.
              - …
            - object: Ends the current USSD session.
              - …
            - object: Prompts the user for input in the active USSD session, saves the response as a custom variable on the message, and triggers the associated response handler.
              - …
            - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
              - …
            - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
              - …
            - object: Updates the name of the current contact in Telerivet.
              - …
            - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
              - …
            - object: Blocks the current contact.
              - …
            - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
              - …
            - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
              - …
            - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
              - …
            - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
              - …
            - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
              - …
            - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
              - …
            - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
              - …
            - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
              - …
            - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
              - …
            - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
              - …
            - object: Triggers another service for the current contact.
              - …
            - object: Triggers another service for the current message.
              - …
            - object: Triggers another service for the current project.
              - …
            - object: Stops processing rules for this message (for this service only).
              - …
            - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
              - …
            - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
              - …
            - object: Triggers a set of actions which can be reused multiple times in the same service.
              - …
    - object: Configuration for `data_row_actions` service type.
      - `actions` ContactAction[]: Array of actions to execute. Each action is an object with a `type` property and additional properties depending on the action type. See <a href="/api/rules_engine#actions">Action Reference</a> for documentation of available action types.
        - union: An action available for `contact_actions` and `data_row_actions` service types.
          - object: Sends a text message to the current contact.
            - `type` 'send_text_to_contact', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
          - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
            - `type` 'send_text', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `to_number` string, required: Phone number to send the message to.
          - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
            - `type` 'send_airtime', required: Action type identifier
            - `provider_id` string, required: ID of the airtime provider to use.
            - `products` object[], required: Array of product configurations for different mobile networks or countries.
              - …
            - `actions` Action[]: Array of actions to execute if the contact is on a supported mobile network.
              - …
            - `on_success` string: Name of subroutine to execute when the airtime transaction succeeds.
            - `on_failure` string: Name of subroutine to execute when the airtime transaction fails.
          - object: Sends a voice call to the current contact using a specified IVR service.
            - `type` 'call_contact', required: Action type identifier
            - `service_id` string, required: ID of the voice/IVR service to use for the call.
            - `route_id` string: ID of the route to use for the call. If not specified, uses the default route.
            - `schedule` object: Schedule for when to make the call. If not specified, calls immediately.
          - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'add_contact_to_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'remove_contact_from_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
            - `type` 'set_contact_var', required: Action type identifier
            - `variable` string, required: Name of the contact variable to set (without the contact.vars prefix).
            - `value` string: Value to assign to the variable.
          - object: Blocks the current contact.
            - `type` 'block_contact', required: Action type identifier
            - `send_blocked` boolean: If true, block sending messages to this contact. If false, unblock the contact. Default: true.
          - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
            - `type` 'send_ussd', required: Action type identifier
            - `mmi_code` string, required: USSD/MMI code to send (e.g. *123#).
            - `route_id` string: ID of the route to send the USSD request from. If not specified, uses the default route.
          - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
            - `type` 'send_email', required: Action type identifier
            - `to_email` string, required: Recipient email address.
            - `subject` string, required: Email subject line.
            - `body_text` string, required: Email body text.
            - `reply_to` string: Reply-to email address.
            - `include_message_attachments` boolean: If true, include any attachments from the current message as email attachments.
          - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
            - `type` 'set_variable', required: Action type identifier
            - `variable` string, required: Name of the variable to set (e.g. $foo, contact.vars.bar, phone.vars.baz).
            - `value` string, required: Value to assign to the variable.
            - `op` 'plus' | 'minus' | 'times' | 'div': Optional arithmetic operation to perform between value and value2.
            - `value2` string: Second operand for the arithmetic operation (required if op is specified).
          - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
            - `type` 'cancel_scheduled_messages', required: Action type identifier
          - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
            - `type` 'webhook', required: Action type identifier
            - `url` string, required: Webhook URL to receive the HTTP POST request.
            - `secret` string: Secret string passed as POST parameter for request verification.
            - `params` object[]: Custom POST parameters to include in the webhook request, in addition to the standard parameters (max 20). A custom parameter with the same name as a standard parameter (including <code>secret</code>) takes precedence over the standard value.
              - …
          - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
            - `type` 'log', required: Action type identifier
            - `value` string, required: Log message content.
          - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
            - `type` 'run_script', required: Action type identifier
            - `code` string, required: JavaScript code to execute. See <a href="https://telerivet.com/api/script">Cloud Script API</a> for available functions and variables.
          - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
            - `type` 'condition', required: Action type identifier
            - `conditions` object[]: Array of condition objects. Required unless <code>if_mode</code> is <code>else</code>.
              - …
            - `actions` Action[], required: Array of actions to execute if the conditions match.
              - …
            - `op` string: Operator to join multiple conditions. Values: <code>and</code> (all conditions must match), <code>or</code> (any condition must match). Default: <code>or</code>.
            - `if_mode` string: Controls how this condition relates to previous conditions. Values: <code>if</code> (default, starts a new conditional block), <code>else_if</code> (only evaluated if the previous <code>if</code> or <code>else_if</code> did not match), <code>else</code> (executed if none of the previous <code>if</code>/<code>else_if</code> conditions matched; does not require <code>conditions</code> array).
          - object: Stops processing rules for this message (for this service only).
            - `type` 'stop', required: Action type identifier
          - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
            - `type` 'wait_response', required: Action type identifier
            - `state_id` string, required: ID of the response handler to process the contact's response.
            - `timeout` object: Schedule for response timeout.
          - object: Triggers a set of actions which can be reused multiple times in the same service.
            - `type` 'run_subroutine', required: Action type identifier
            - `name` string, required: Name of the subroutine to run.
          - object: Triggers another service for the current contact.
            - `type` 'trigger_contact_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
            - `schedule` object: Schedule for when to trigger the service. If not specified, triggers the service immediately.
          - object: Triggers another service for the current project.
            - `type` 'trigger_project_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
          - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
            - `type` 'set_contact', required: Action type identifier
            - `phone_number` string, required: Phone number for the contact to use.
      - `subroutines` object[]: Array of subroutine definitions. Subroutines are reusable sets of actions that can be called from the main actions or other subroutines.
        - `name` string, required: Unique name for the subroutine (max 32 characters).
        - `context` string: Context type for the subroutine. If not specified, defaults to the service's context.
        - `actions` Action[], required: Array of actions to execute when the subroutine is called. Available actions depend on the subroutine's context.
          - union: An action in a Custom Actions service. The `type` property determines which action is performed and what additional properties are available. See [Rules Engine Actions](/api/rules_engine#actions) for detailed documentation.
            - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
              - …
            - object: Blocks the current contact.
              - …
            - object: Sends a voice call to the current contact using a specified IVR service.
              - …
            - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
              - …
            - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
              - …
            - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
              - …
            - object: Ends the current USSD session.
              - …
            - object: Within a poll service, skips to the end of the survey.
              - …
            - object: Forwards the incoming call to another phone number.
              - …
            - object: Hangs up the phone call.
              - …
            - object: Within a poll service, ignores the current message.
              - …
            - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
              - …
            - object: Plays an audio file in WAV or MP3 format in the voice call, which may be uploaded, linked, or recorded via the Telerivet web app. Alternatively, can use text-to-speech to speak a message.
              - …
            - object: Pushes the message to a HubSpot Help Desk inbox, in a conversation associated with the current contact. HubSpot agents can reply directly to send a reply to the contact.
              - …
            - object: Pushes the message to a Zendesk support inbox, in a ticket associated with the current contact. Zendesk agents can reply directly to the Zendesk ticket to send a reply to the contact.
              - …
            - object: Records an audio response from the caller, saves the recording URL as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Within a poll service, repeats the current question again.
              - …
            - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text reply to the sender (simple version without labels, schedule, or route configuration).
              - …
            - object: Within a service triggered when a message status changes, will automatically resend the current message via the same route or a different route.
              - …
            - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
              - …
            - object: Triggers a set of actions which can be reused multiple times in the same service.
              - …
            - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
              - …
            - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
              - …
            - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text message to the current contact.
              - …
            - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
              - …
            - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
              - …
            - object: Shows the specified text in the active USSD session. If this action is followed by a 'Wait for response' action, the text will be displayed as part of a USSD prompt.
              - …
            - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
              - …
            - object: Updates the name of the current contact in Telerivet.
              - …
            - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
              - …
            - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
              - …
            - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
              - …
            - object: Within a poll service, skips to a question outside the normal order.
              - …
            - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
              - …
            - object: Stops processing rules for this message (for this service only).
              - …
            - object: Triggers another service for the current contact.
              - …
            - object: Triggers another service for the current message.
              - …
            - object: Triggers another service for the current project.
              - …
            - object: Within a custom route, selects one or more basic routes that can be used to send the message.
              - …
            - object: Waits for the caller to enter digits on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for the caller to press a single key on the keypad, saves the input as a custom variable on the message, then triggers the associated response handler.
              - …
            - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
              - …
            - object: Prompts the user for input in the active USSD session, saves the response as a custom variable on the message, and triggers the associated response handler.
              - …
            - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
              - …
      - `response_handlers` object[]: Array of response handler definitions. Response handlers are triggered when the service is waiting for input (e.g., after `wait_response` actions).
        - `state_id` string, required: Unique state identifier for this response handler. Must be a valid variable name and cannot be "initial".
        - `actions` MessageAction[], required: Array of actions to execute when a response is received in this state.
          - union: An action available for `incoming_message_actions` and `message_actions` service types.
            - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
              - …
            - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
              - …
            - object: Updates the name of the current contact in Telerivet.
              - …
            - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
              - …
            - object: Blocks the current contact.
              - …
            - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
              - …
            - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
              - …
            - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
              - …
            - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
              - …
            - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
              - …
            - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
              - …
            - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
              - …
            - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
              - …
            - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
              - …
            - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
              - …
            - object: Triggers another service for the current contact.
              - …
            - object: Triggers another service for the current message.
              - …
            - object: Triggers another service for the current project.
              - …
            - object: Stops processing rules for this message (for this service only).
              - …
            - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
              - …
            - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
              - …
            - object: Waits for a response from the current contact, then processes the response using another set of actions or conditions. Useful for back-and-forth conversations or data collection that requires the contact to send multiple messages.
              - …
            - object: Sends a USSD request from your Android phone to your mobile network. On some mobile networks, USSD requests can be used to check your airtime balance, transfer airtime to other phone numbers, and more. Note that this requires a compatible Android phone running the Telerivet Gateway app. Also, Telerivet cannot automatically invoke USSD requests that return menus or prompts.
              - …
            - object: Triggers a set of actions which can be reused multiple times in the same service.
              - …
            - object: Sends a voice call to the current contact using a specified IVR service.
              - …
            - object: Pushes the message to a Zendesk support inbox, in a ticket associated with the current contact. Zendesk agents can reply directly to the Zendesk ticket to send a reply to the contact.
              - …
            - object: Pushes the message to a HubSpot Help Desk inbox, in a conversation associated with the current contact. HubSpot agents can reply directly to send a reply to the contact.
              - …
    - object: Configuration for incoming_message_webhook service type
      - `url` string, required: Webhook URL that will receive POST requests when messages arrive. HTTPS is recommended for production use.
      - `secret` string: Secret string passed as POST parameter for request verification. Auto-generated if not provided.
    - object: Configuration for optin_optout service type
      - `subscribe_keywords` object[]: Keywords that subscribe a contact (up to 20 keywords, each 1-30 characters). Matching is case-insensitive.
        - `type` string
      - `subscribe_reply` MessageBody
        - `content` string: Text content of the message.
        - `media` object[]: Array of media attachments.
          - `url` string: URL of the media file. Required unless file_id is provided. For media files that are not already accessible via the internet or uploaded as a stored file, the URL may be a data URI with the file data encoded via Base64 (e.g. "data:image/png;base64,..."), with a maximum decoded file size of 5 MB. When using a data URI, Telerivet will automatically store the file in your project.
          - `type` string: MIME type of the media file (e.g., image/jpeg). If not provided, Telerivet will attempt to determine the MIME type automatically from the extension of the filename or URL path component. Ignored if file_id is provided. Use `route_vcard` (without url or file_id) to attach the Contact Card of the route that sends each message.
          - `filename` string: Original filename of the media file. Ignored if file_id is provided.
          - `size` integer: Size of the media file in bytes.
          - `file_id` string: ID of the stored file, if applicable. If file_id is provided, url is not required.
        - `route_params` object: Route-specific parameters for the message. See <a href="#route_params">Route-Specific Parameters</a>.
        - `track_clicks` boolean: Whether to shorten links and track link clicks in this message.
        - `short_link_params` object: Parameters for short links when track_clicks is enabled.
          - `domain` string: Custom domain for short links. Must be configured for this project.
          - `expiration_sec` integer: Expiration time in seconds for short links. Must be positive and less than one year.
      - `unsubscribe_keywords` object[]: Keywords that unsubscribe a contact (up to 20 keywords, each 1-30 characters). Matching is case-insensitive.
        - `type` string
      - `unsubscribe_reply` MessageBody
        - `content` string: Text content of the message.
        - `media` object[]: Array of media attachments.
          - `url` string: URL of the media file. Required unless file_id is provided. For media files that are not already accessible via the internet or uploaded as a stored file, the URL may be a data URI with the file data encoded via Base64 (e.g. "data:image/png;base64,..."), with a maximum decoded file size of 5 MB. When using a data URI, Telerivet will automatically store the file in your project.
          - `type` string: MIME type of the media file (e.g., image/jpeg). If not provided, Telerivet will attempt to determine the MIME type automatically from the extension of the filename or URL path component. Ignored if file_id is provided. Use `route_vcard` (without url or file_id) to attach the Contact Card of the route that sends each message.
          - `filename` string: Original filename of the media file. Ignored if file_id is provided.
          - `size` integer: Size of the media file in bytes.
          - `file_id` string: ID of the stored file, if applicable. If file_id is provided, url is not required.
        - `route_params` object: Route-specific parameters for the message. See <a href="#route_params">Route-Specific Parameters</a>.
        - `track_clicks` boolean: Whether to shorten links and track link clicks in this message.
        - `short_link_params` object: Parameters for short links when track_clicks is enabled.
          - `domain` string: Custom domain for short links. Must be configured for this project.
          - `expiration_sec` integer: Expiration time in seconds for short links. Must be positive and less than one year.
      - `subscriber_group` string, required: Name of the contact group containing subscribers. The group is created if it does not already exist.
      - `unsubscriber_group` string: Name of the contact group containing unsubscribers. Required when add_unsubscriber or remove_unsubscriber action is enabled. The group is created if it does not already exist (with sending blocked).
      - `subscribe_label` string: Name of the message label applied on subscribe. Required when add_subscribe_label action is enabled.
      - `unsubscribe_label` string: Name of the message label applied on unsubscribe. Required when add_unsubscribe_label action is enabled.
      - `actions` object: Actions to perform on subscribe and unsubscribe. Each action defaults to true; set to false to disable. At least one subscribe action must be enabled when subscribe_keywords is set, and at least one unsubscribe action when unsubscribe_keywords is set.
        - `add_subscriber` boolean: Add the contact to the subscriber group on subscribe.
        - `remove_subscriber` boolean: Remove the contact from the subscriber group on unsubscribe.
        - `add_unsubscriber` boolean: Add the contact to the unsubscriber group on unsubscribe.
        - `remove_unsubscriber` boolean: Remove the contact from the unsubscriber group on subscribe.
        - `add_subscribe_label` boolean: Apply the subscribe label to the message on subscribe.
        - `add_unsubscribe_label` boolean: Apply the unsubscribe label to the message on unsubscribe.
        - `subscribe_unblock` boolean: Unblock the contact on subscribe.
        - `unsubscribe_block` boolean: Block the contact on unsubscribe.
    - object: Configuration for keyword_auto_reply service type
      - `items` object[], required: Up to 100 items. Each item defines a list of keywords and the reply sent when an incoming message matches any of the keywords. Items are evaluated in order and only the first matching item is applied.
        - `keywords` object[], required: Up to 20 keywords (each up to 70 characters). Matching is case-insensitive.
          - `type` string
        - `reply` MessageBody, required
          - `content` string: Text content of the message.
          - `media` object[]: Array of media attachments.
            - `url` string: URL of the media file. Required unless file_id is provided. For media files that are not already accessible via the internet or uploaded as a stored file, the URL may be a data URI with the file data encoded via Base64 (e.g. "data:image/png;base64,..."), with a maximum decoded file size of 5 MB. When using a data URI, Telerivet will automatically store the file in your project.
            - `type` string: MIME type of the media file (e.g., image/jpeg). If not provided, Telerivet will attempt to determine the MIME type automatically from the extension of the filename or URL path component. Ignored if file_id is provided. Use `route_vcard` (without url or file_id) to attach the Contact Card of the route that sends each message.
            - `filename` string: Original filename of the media file. Ignored if file_id is provided.
            - `size` integer: Size of the media file in bytes.
            - `file_id` string: ID of the stored file, if applicable. If file_id is provided, url is not required.
          - `route_params` object: Route-specific parameters for the message. See <a href="#route_params">Route-Specific Parameters</a>.
          - `track_clicks` boolean: Whether to shorten links and track link clicks in this message.
          - `short_link_params` object: Parameters for short links when track_clicks is enabled.
            - `domain` string: Custom domain for short links. Must be configured for this project.
            - `expiration_sec` integer: Expiration time in seconds for short links. Must be positive and less than one year.
    - object: Configuration for messaging_poll service type
      - `response_mode` 'outgoing' | 'direct' | 'keyword': Controls how responses are collected.
      - `trigger_keyword` string: Keyword that starts the poll when response_mode is "keyword".
      - `multiple_action` 'allow' | 'ignore': Action when a contact tries to respond multiple times.
      - `response_actions` MessagingPollAction[]: Array of rule actions to execute whenever a response is received, before the actions for the current question. For example, a condition on [[content]] matching a keyword like END can end the survey regardless of which question the contact is answering. If these actions ignore the message or change the poll state (end survey, skip to question, repeat question), the current question's actions are skipped and the response is not recorded. See <a href="https://telerivet.com/api/rules_engine#actions">Actions</a>.
        - union: An action available for `messaging_poll` service type.
          - object: Within a poll service, skips to a question outside the normal order.
            - `type` 'skip_to_question', required: Action type identifier
            - `question_id` string, required: ID of the poll question to skip to.
          - object: Within a poll service, skips to the end of the survey.
            - `type` 'end_survey', required: Action type identifier
          - object: Within a poll service, repeats the current question again.
            - `type` 'repeat_question', required: Action type identifier
          - object: Within a poll service, ignores the current message.
            - `type` 'ignore_message', required: Action type identifier
          - object: Sends a text reply to the sender (simple version without labels, schedule, or route configuration).
            - `type` 'reply_simple', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `schedule` object: Schedule to send the message at a later time.
          - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
            - `type` 'reply', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
          - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
            - `type` 'send_text', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `to_number` string, required: Phone number to send the message to.
          - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
            - `type` 'send_text_to_group', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `group_name` string, required: Name of the group to send the message to.
            - `exclude_sender` boolean: If true, exclude the message sender from receiving the group message.
          - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'add_contact_to_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'remove_contact_from_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
            - `type` 'set_contact', required: Action type identifier
            - `phone_number` string, required: Phone number for the contact to use.
          - object: Updates the name of the current contact in Telerivet.
            - `type` 'set_contact_name', required: Action type identifier
            - `name` string, required: Name to assign to the contact.
          - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
            - `type` 'set_contact_var', required: Action type identifier
            - `variable` string, required: Name of the contact variable to set (without the contact.vars prefix).
            - `value` string: Value to assign to the variable.
          - object: Blocks the current contact.
            - `type` 'block_contact', required: Action type identifier
            - `send_blocked` boolean: If true, block sending messages to this contact. If false, unblock the contact. Default: true.
          - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
            - `type` 'send_email', required: Action type identifier
            - `to_email` string, required: Recipient email address.
            - `subject` string, required: Email subject line.
            - `body_text` string, required: Email body text.
            - `reply_to` string: Reply-to email address.
            - `include_message_attachments` boolean: If true, include any attachments from the current message as email attachments.
          - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
            - `type` 'send_airtime', required: Action type identifier
            - `provider_id` string, required: ID of the airtime provider to use.
            - `products` object[], required: Array of product configurations for different mobile networks or countries.
              - …
            - `actions` Action[]: Array of actions to execute if the contact is on a supported mobile network.
              - …
            - `on_success` string: Name of subroutine to execute when the airtime transaction succeeds.
            - `on_failure` string: Name of subroutine to execute when the airtime transaction fails.
          - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
            - `type` 'add_label_to_message', required: Action type identifier
            - `label_name` string, required: Name of the label to add to the message.
          - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
            - `type` 'star_message', required: Action type identifier
          - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
            - `type` 'set_variable', required: Action type identifier
            - `variable` string, required: Name of the variable to set (e.g. $foo, contact.vars.bar, phone.vars.baz).
            - `value` string, required: Value to assign to the variable.
            - `op` 'plus' | 'minus' | 'times' | 'div': Optional arithmetic operation to perform between value and value2.
            - `value2` string: Second operand for the arithmetic operation (required if op is specified).
          - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
            - `type` 'cancel_scheduled_messages', required: Action type identifier
          - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
            - `type` 'webhook', required: Action type identifier
            - `url` string, required: Webhook URL to receive the HTTP POST request.
            - `secret` string: Secret string passed as POST parameter for request verification.
            - `params` object[]: Custom POST parameters to include in the webhook request, in addition to the standard parameters (max 20). A custom parameter with the same name as a standard parameter (including <code>secret</code>) takes precedence over the standard value.
              - …
          - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
            - `type` 'log', required: Action type identifier
            - `value` string, required: Log message content.
          - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
            - `type` 'run_script', required: Action type identifier
            - `code` string, required: JavaScript code to execute. See <a href="https://telerivet.com/api/script">Cloud Script API</a> for available functions and variables.
          - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
            - `type` 'condition', required: Action type identifier
            - `conditions` object[]: Array of condition objects. Required unless <code>if_mode</code> is <code>else</code>.
              - …
            - `actions` Action[], required: Array of actions to execute if the conditions match.
              - …
            - `op` string: Operator to join multiple conditions. Values: <code>and</code> (all conditions must match), <code>or</code> (any condition must match). Default: <code>or</code>.
            - `if_mode` string: Controls how this condition relates to previous conditions. Values: <code>if</code> (default, starts a new conditional block), <code>else_if</code> (only evaluated if the previous <code>if</code> or <code>else_if</code> did not match), <code>else</code> (executed if none of the previous <code>if</code>/<code>else_if</code> conditions matched; does not require <code>conditions</code> array).
          - object: Triggers another service for the current contact.
            - `type` 'trigger_contact_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
            - `schedule` object: Schedule for when to trigger the service. If not specified, triggers the service immediately.
          - object: Triggers another service for the current message.
            - `type` 'trigger_message_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
          - object: Triggers another service for the current project.
            - `type` 'trigger_project_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
          - object: Stops processing rules for this message (for this service only).
            - `type` 'stop', required: Action type identifier
          - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
            - `type` 'copy_message_to_project', required: Action type identifier
            - `project_id` string, required: ID of the project to copy the message to. Must be a project within the same organization.
          - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
            - `type` 'set_message_var', required: Action type identifier
            - `variable` string, required: Name of the message variable to set (without the vars prefix).
            - `value` string: Value to assign to the variable.
      - `end_actions` MessagingPollAction[]: Array of rule actions to execute when the poll is completed, e.g. a reply thanking the respondent. Replaces the deprecated `end_reply` parameter (a message body), which is still accepted when `end_actions` is not provided. See <a href="https://telerivet.com/api/rules_engine#actions">Actions</a>.
        - union: An action available for `messaging_poll` service type.
          - object: Within a poll service, skips to a question outside the normal order.
            - `type` 'skip_to_question', required: Action type identifier
            - `question_id` string, required: ID of the poll question to skip to.
          - object: Within a poll service, skips to the end of the survey.
            - `type` 'end_survey', required: Action type identifier
          - object: Within a poll service, repeats the current question again.
            - `type` 'repeat_question', required: Action type identifier
          - object: Within a poll service, ignores the current message.
            - `type` 'ignore_message', required: Action type identifier
          - object: Sends a text reply to the sender (simple version without labels, schedule, or route configuration).
            - `type` 'reply_simple', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `schedule` object: Schedule to send the message at a later time.
          - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
            - `type` 'reply', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
          - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
            - `type` 'send_text', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `to_number` string, required: Phone number to send the message to.
          - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
            - `type` 'send_text_to_group', required: Action type identifier
            - `body` MessageBodyWithVariants, required
              - …
            - `route_id` string: ID of the route to send the message from. If not specified, uses the default route.
            - `label_names` string[]: Array of label names to apply to the sent message.
            - `schedule` object: Schedule to send the message at a later time.
            - `on_click` string: Name of a subroutine (with context `message`) to run the first time the recipient clicks a link in the message. Requires `body.track_clicks`. Within the subroutine, [[$destination_url]] is the URL that was clicked.
            - `on_click_timeout` object: Runs a subroutine (with context `message`) if the recipient has not clicked a link in the message within the specified time. Requires `body.track_clicks`.
            - `group_name` string, required: Name of the group to send the message to.
            - `exclude_sender` boolean: If true, exclude the message sender from receiving the group message.
          - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'add_contact_to_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
            - `type` 'remove_contact_from_group', required: Action type identifier
            - `group_name` string, required: Name of the group. If the group does not exist, it will be created.
          - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
            - `type` 'set_contact', required: Action type identifier
            - `phone_number` string, required: Phone number for the contact to use.
          - object: Updates the name of the current contact in Telerivet.
            - `type` 'set_contact_name', required: Action type identifier
            - `name` string, required: Name to assign to the contact.
          - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
            - `type` 'set_contact_var', required: Action type identifier
            - `variable` string, required: Name of the contact variable to set (without the contact.vars prefix).
            - `value` string: Value to assign to the variable.
          - object: Blocks the current contact.
            - `type` 'block_contact', required: Action type identifier
            - `send_blocked` boolean: If true, block sending messages to this contact. If false, unblock the contact. Default: true.
          - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
            - `type` 'send_email', required: Action type identifier
            - `to_email` string, required: Recipient email address.
            - `subject` string, required: Email subject line.
            - `body_text` string, required: Email body text.
            - `reply_to` string: Reply-to email address.
            - `include_message_attachments` boolean: If true, include any attachments from the current message as email attachments.
          - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
            - `type` 'send_airtime', required: Action type identifier
            - `provider_id` string, required: ID of the airtime provider to use.
            - `products` object[], required: Array of product configurations for different mobile networks or countries.
              - …
            - `actions` Action[]: Array of actions to execute if the contact is on a supported mobile network.
              - …
            - `on_success` string: Name of subroutine to execute when the airtime transaction succeeds.
            - `on_failure` string: Name of subroutine to execute when the airtime transaction fails.
          - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
            - `type` 'add_label_to_message', required: Action type identifier
            - `label_name` string, required: Name of the label to add to the message.
          - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
            - `type` 'star_message', required: Action type identifier
          - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
            - `type` 'set_variable', required: Action type identifier
            - `variable` string, required: Name of the variable to set (e.g. $foo, contact.vars.bar, phone.vars.baz).
            - `value` string, required: Value to assign to the variable.
            - `op` 'plus' | 'minus' | 'times' | 'div': Optional arithmetic operation to perform between value and value2.
            - `value2` string: Second operand for the arithmetic operation (required if op is specified).
          - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
            - `type` 'cancel_scheduled_messages', required: Action type identifier
          - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
            - `type` 'webhook', required: Action type identifier
            - `url` string, required: Webhook URL to receive the HTTP POST request.
            - `secret` string: Secret string passed as POST parameter for request verification.
            - `params` object[]: Custom POST parameters to include in the webhook request, in addition to the standard parameters (max 20). A custom parameter with the same name as a standard parameter (including <code>secret</code>) takes precedence over the standard value.
              - …
          - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
            - `type` 'log', required: Action type identifier
            - `value` string, required: Log message content.
          - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
            - `type` 'run_script', required: Action type identifier
            - `code` string, required: JavaScript code to execute. See <a href="https://telerivet.com/api/script">Cloud Script API</a> for available functions and variables.
          - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
            - `type` 'condition', required: Action type identifier
            - `conditions` object[]: Array of condition objects. Required unless <code>if_mode</code> is <code>else</code>.
              - …
            - `actions` Action[], required: Array of actions to execute if the conditions match.
              - …
            - `op` string: Operator to join multiple conditions. Values: <code>and</code> (all conditions must match), <code>or</code> (any condition must match). Default: <code>or</code>.
            - `if_mode` string: Controls how this condition relates to previous conditions. Values: <code>if</code> (default, starts a new conditional block), <code>else_if</code> (only evaluated if the previous <code>if</code> or <code>else_if</code> did not match), <code>else</code> (executed if none of the previous <code>if</code>/<code>else_if</code> conditions matched; does not require <code>conditions</code> array).
          - object: Triggers another service for the current contact.
            - `type` 'trigger_contact_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
            - `schedule` object: Schedule for when to trigger the service. If not specified, triggers the service immediately.
          - object: Triggers another service for the current message.
            - `type` 'trigger_message_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
            - `route_id` string: ID of the route to use as the default route for messages sent by the triggered service. If not specified, uses the current default route.
          - object: Triggers another service for the current project.
            - `type` 'trigger_project_service', required: Action type identifier
            - `service_id` string, required: ID of the service to trigger.
          - object: Stops processing rules for this message (for this service only).
            - `type` 'stop', required: Action type identifier
          - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
            - `type` 'copy_message_to_project', required: Action type identifier
            - `project_id` string, required: ID of the project to copy the message to. Must be a project within the same organization.
          - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
            - `type` 'set_message_var', required: Action type identifier
            - `variable` string, required: Name of the message variable to set (without the vars prefix).
            - `value` string: Value to assign to the variable.
      - `label_id` string: ID of the label to apply to poll messages.
      - `sample_group_id` string: ID of the contact group for poll recipients.
      - `respondent_group_id` string: ID of the contact group for contacts who have completed the poll.
      - `questions` PollQuestion[], required: Array of poll questions.
        - `id` string, required: Unique identifier for the question (alphanumeric, max 15 characters). Used as the variable name for storing responses.
        - `question_type` 'open' | 'multiple_choice', required: Type of question.
        - `body` MessageBodyWithVariants, required
          - `content` string: Text content of the message.
          - `media` object[]: Array of media attachments.
            - `url` string: URL of the media file. Required unless file_id is provided. For media files that are not already accessible via the internet or uploaded as a stored file, the URL may be a data URI with the file data encoded via Base64 (e.g. "data:image/png;base64,..."), with a maximum decoded file size of 5 MB. When using a data URI, Telerivet will automatically store the file in your project.
            - `type` string: MIME type of the media file (e.g., image/jpeg). If not provided, Telerivet will attempt to determine the MIME type automatically from the extension of the filename or URL path component. Ignored if file_id is provided. Use `route_vcard` (without url or file_id) to attach the Contact Card of the route that sends each message.
            - `filename` string: Original filename of the media file. Ignored if file_id is provided.
            - `size` integer: Size of the media file in bytes.
            - `file_id` string: ID of the stored file, if applicable. If file_id is provided, url is not required.
          - `route_params` object: Route-specific parameters for the message. See <a href="#route_params">Route-Specific Parameters</a>.
          - `track_clicks` boolean: Whether to shorten links and track link clicks in this message.
          - `short_link_params` object: Parameters for short links when track_clicks is enabled.
            - `domain` string: Custom domain for short links. Must be configured for this project.
            - `expiration_sec` integer: Expiration time in seconds for short links. Must be positive and less than one year.
          - `variants` object[]: Allows sending different message bodies depending on the route that sends the message, or the contact that the message is sent to. Each variant has conditions and its own message body. When each message is sent, the first variant whose conditions match is used instead of the default message body; if no variant matches, the default message body is used. A variant replaces the entire message body: content, media, route_params, track_clicks and short_link_params that are not specified in the variant are empty, not inherited from the default message body. Conditions are evaluated when the message is sent by a particular basic route, and can use the same variables as outgoing message content: contact variables such as [[contact.name]] and [[contact.vars.\*]], [[to_number]], [[time]], [[project.\*]], and variables of the basic route sending the message: [[phone.type]] (e.g. whatsapp), [[phone.id]], [[phone.vars.\*]], and [[phone.supports_quick_replies]], [[phone.supports_link_button]], [[phone.supports_native_attachments]] (1 if the route supports the feature, otherwise 0). Variables may include filters, e.g. [[contact.vars.language|default:"en"]]. For all available variables, see the <a href='https://telerivet.com/api/rest#variables'>Variable Reference</a>. In services and polls, conditions can't use variables that are only available in the service, such as [[content]] or [[state.\*]] (to use them, first store the value in a contact field, e.g. with a set_contact_var action, and then use [[contact.vars.\*]]). For A/B testing, a variant can have a random split (split_percent) so that it is only used for a random percentage of recipients, e.g. a single variant with split_percent 50 is used for about half of the recipients, and the default message body for the others. A random split can be combined with other conditions to run separate A/B tests for different routes or contacts. Since the first matching variant is used, list more specific variants before more general ones. For example, a variant with a condition `[[contact.vars.language]] is 'fr'` and split_percent 50 must be listed before a variant with only the condition `[[contact.vars.language]] is 'fr'`. Up to 10 variants are supported, each with up to 5 conditions.
            - `content` string: Text content of the message.
            - `media` object[]: Array of media attachments.
              - …
            - `route_params` object: Route-specific parameters for the message. See <a href="#route_params">Route-Specific Parameters</a>.
            - `track_clicks` boolean: Whether to shorten links and track link clicks in this message.
            - `short_link_params` object: Parameters for short links when track_clicks is enabled.
              - …
            - `conditions` object[]: Conditions for using this variant (up to 5). Required unless the variant has a <code>split_percent</code>.
              - …
            - `op` string: Operator to join multiple conditions: <code>and</code> (all conditions must match) or <code>or</code> (any condition must match). Must be <code>and</code> if the variant has a <code>split_percent</code>. Default: <code>and</code>.
            - `split_percent` integer: For A/B testing, the approximate percentage of recipients (1-100) matching the variant's other conditions that are randomly selected for this variant. Variants with the same conditions and a split_percent are used for separate random groups of recipients, and the remaining recipients receive the default message body (or the next matching variant). For example, a single variant with a split_percent of 50 is used for about half of the recipients. Since each recipient is selected randomly, the actual percentage of recipients receiving each variant may differ slightly from split_percent, especially for small numbers of recipients. Recipients are assigned to groups deterministically, so that each contact is in the same group for all messages in the same broadcast or campaign. The total split_percent of all variants with the same conditions can be at most 100. Variants with different conditions are separate A/B tests (e.g. one for each contact language), so their split_percent values do not count toward the same total. If split_percent is omitted, the variant is used for all recipients that match its conditions.
        - `content` string: Question text (alternative to body.content for backwards compatibility).
        - `choices` PollChoice[]: Array of response choices (for multiple_choice questions).
          - `code` string: Value stored in the response table when this choice is selected.
          - `conditions` object[]: Array of conditions that match this choice. A response matches if any condition is satisfied.
            - `type` 'is' | 'is_not' | 'has_word' | 'does_not_have_word' | 'contains' | 'does_not_contain' | 'starts_with' | 'does_not_start_with' | 'ends_with' | 'does_not_end_with' | 'alpha_before' | 'alpha_after' | 'equals' | 'does_not_equal' | 'less_than' | 'greater_than' | 'less_or_equal' | 'greater_or_equal', required: Condition type for matching the response.
            - `value` string, required: Value to match against the response content.
          - `actions` MessagingPollAction[]: Array of rule actions to execute when this choice is selected. See <a href="https://telerivet.com/api/rules_engine#actions">Actions</a>.
            - union: An action available for `messaging_poll` service type.
              - …
        - `none_choice` PollNoneChoice
          - `code` string: Value stored in the response table when no other choice matches.
          - `actions` MessagingPollAction[]: Array of rule actions to execute when no other choice matches. See <a href="https://telerivet.com/api/rules_engine#actions">Actions</a>.
            - union: An action available for `messaging_poll` service type.
              - …
        - `actions` MessagingPollAction[]: Array of rule actions to execute after the question is answered. See <a href="https://telerivet.com/api/rules_engine#actions">Actions</a>.
          - union: An action available for `messaging_poll` service type.
            - object: Within a poll service, skips to a question outside the normal order.
              - …
            - object: Within a poll service, skips to the end of the survey.
              - …
            - object: Within a poll service, repeats the current question again.
              - …
            - object: Within a poll service, ignores the current message.
              - …
            - object: Sends a text reply to the sender (simple version without labels, schedule, or route configuration).
              - …
            - object: Sends a text reply to the sender. Optionally, the reply can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a text message to any phone number. Optionally, the message can be scheduled after a predefined delay, or sent via a different phone than the one that received the message.
              - …
            - object: Sends a SMS message to a group defined on your Contacts page. Optionally, you can exclude the message sender from receiving the message (common when implementing a group chat system).
              - …
            - object: Adds the current contact to a group. If the group doesn't exist yet, Telerivet will create it. If you want to add a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Removes the current contact from a group. If you want to remove a contact other than the one who sent the message, add a "Use another contact" rule before this rule.
              - …
            - object: Creates or retrieves a contact with a particular phone number, and sets that as the "current" contact for subsequent rules. This rule is often used to allow your organization's workers to register other people via SMS, and is typically combined with other rules to add the contact to a group and update their contact information.
              - …
            - object: Updates the name of the current contact in Telerivet.
              - …
            - object: Updates custom contact information for the current contact (for example, email address or birthdate). The rules editor lists the current variable names available for your project. You can also use a new variable name consisting of letters, numbers, and underscores.
              - …
            - object: Blocks the current contact.
              - …
            - object: Sends a plain-text email with custom subject line and body. Each rule can only send to a single email address; if you need multiple recipients, we recommend setting up a mailing list on your own server. When receiving MMS and chat messages, you can optionally send the multimedia files as email attachments. To prevent abuse, it isn't possible to change the 'From' name or email address of the email, although these settings can be configured when using Telerivet on a custom domain.
              - …
            - object: Sends airtime to the current contact if they are on a particular mobile network. Acts like a condition, and allows running other actions if the contact is on one of the supported networks. An 'else' condition can be added below this action to handle contacts that are not on the supported mobile networks.
              - …
            - object: Adds a label to the current message. This makes it easy to segment certain types of messages on your Messages page.
              - …
            - object: Adds a star to the current message. This makes it easy to segment important messages on your Messages page.
              - …
            - object: Updates the value of any writable variable within the Rules Engine. Optionally, you can use this rule to perform simple numeric operations between two variables such as addition, subtraction, multiplication and division. Read-only variables cannot be updated via this rule. [See available variables](#message_variables)
              - …
            - object: Cancels all scheduled messages to the current contact. Note this doesn't cancel messages that are scheduled to an entire group. In this case, the contact would need to be removed from the group in order to cancel the message.
              - …
            - object: Makes a HTTP POST request to a URL on your server, passing several POST parameters with information about the current message and contact. Your webhook script may optionally return a JSON response with a 'messages' property containing an array of messages to send, and a 'variables' property containing variable names and values to update. For details, see the [Webhook API documentation](/api/webhook).
              - …
            - object: Adds a log message to Telerivet's [service log](/dashboard/service_logs). To view the service log, open your [Services page](/dashboard/services) and click More > View logs. When using the "Test Service" feature, log messages will be displayed directly in the simulated phone dialog.
              - …
            - object: Runs custom JavaScript code on Telerivet's servers using Telerivet's Cloud Script API. This makes it possible to define custom actions such as calling the Telerivet REST API or third-party APIs, or parsing structured data from incoming messages. For more details, see the [Cloud Script API documentation](/api/script).
              - …
            - object: A rule that only matches if a certain condition is true (e.g. the message has a particular keyword or sender). Always combined with one or more other rules. "If ... then ..." rules can use the following types of conditions: * is * is not * has word * does not have word * contains * does not contain * starts with * does not start with * ends with * does not end with * alphabetically before * alphabetically after * equals * does not equal * less than * greater than * less than or equal to * greater than or equal to * contact is in group * contact is not in group A single "If ... then ..." rule can contain multiple conditions, joined together with either 'and' or 'or'.
              - …
            - object: Triggers another service for the current contact.
              - …
            - object: Triggers another service for the current message.
              - …
            - object: Triggers another service for the current project.
              - …
            - object: Stops processing rules for this message (for this service only).
              - …
            - object: Copies the current incoming message to another project within the same organization. This is useful for routing messages to different projects based on message content or contact information, while keeping the original message in the current project.
              - …
            - object: Updates a custom variable for the current message. When triggered from a service that has a response data table (such as a poll service or custom actions with response handlers), custom message variables set via this action are automatically copied as custom variables on the corresponding response data table row. This is the recommended way to store derived or computed values in the response data table.
              - …
        - `timeouts` PollTimeout[]: Array of timeout configurations.
          - `schedule` object, required: Timeout schedule configuration.
            - `interval` 'minutes' | 'days', required: Time interval type.
            - `minutes` number: Number of minutes (when interval is "minutes").
            - `days` number: Number of days (when interval is "days").
          - `actions` MessagingPollAction[]: Array of rule actions to execute when the timeout occurs. See <a href="https://telerivet.com/api/rules_engine#actions">Actions</a>.
            - union: An action available for `messaging_poll` service type.
              - …
    - object: Configuration for voice_poll service type
      - `incoming_call_mode` 'any' | 'recipients' | 'none': Controls how incoming calls trigger the poll. "any" runs the poll for any incoming call. "recipients" runs the poll only for contacts in the sample group. "none" disables incoming calls (only outgoing). Setting any value other than "none" also sets the service direction to handle incoming calls.
      - `multiple_action` 'allow' | 'ignore': Action when a contact tries to respond multiple times.
      - `start_actions` VoiceAction[]: Array of rule actions to execute when the call starts, before the first question, e.g. playing a welcome message. Replaces the deprecated `start_audio` parameter (a VoiceAudio object), which is still accepted when `start_actions` is not provided. See <a href="https://telerivet.com/api/rules_engine#actions">Actions</a>.
        - union: An action available for `voice_actions` service type.
          - object: Plays an audio file in WAV or MP3 format in the voice call, which may be uploaded, linked, or recorded via the Telerivet web app. Alternatively, can use text-to-speech to speak a message.
            - `type` 'play_audio', required: Action type identifier
            - `mode` 'file' | 'tts', required: Audio source mode.
            - `audio_url` string: URL of the audio file to play (WAV or MP3). Required when mode is "file".
            - `audio_title` string: Title for the audio file displayed in the web app (not played to the caller). Used when mode is "file".
            - `text` string: Text to speak using text-to-speech. Required when mode is "tts". If mode is "file", the text is not used in the actual call but is displayed as the transcript of the file within the web app.
            - `language` string: Language code for text-to-speech (e.g., "en-US"). Used when mode is "tts".
            - `voice` string: Voice for text-to-speech (e.g., "man", "woman"). Used when mode is "tts".
            - `repeat` boolean: If true, repeat the audio once after a short pause.
          - object: Plays an audio file in WAV or MP3 format in the voice call, which may be uploaded, linked, or recorded via the Telerivet web app. Alternatively, can use text-to-speech to speak a message.
            - `type` 'play_audio', required: Action type identifier
            - `mode` 'file' | 'tts', required: Audio source mode.
            - `audio_url` string: URL of the audio file to play (WAV or MP3). Required when mode is "file".
            - `audio_title` string: Title for the audio file displayed in the web app (not played to the caller). Used when mode is "file".
            - `text` string: Text to speak using text-to-speech. Required when mode is "tts". If mode is "file", the text is not used in the actual call but is displayed as the transcript of the file within the web app.
            - `language` string: Language code for text-to-speech (e.g., "en-US"). Used when mode is "tts".
            - `voice` string: Voice for text-to-speech (e.g., "man", "woman"). Used when mode is "tts".
            - `repeat` boolean: If true, repeat the audio once after a short pause.
- … truncated; see the full OpenAPI document linked below

## Response `200`

Successful response

- Service: Represents an automated service on Telerivet, for example a poll, auto-reply, webhook service, etc. A service, generally, defines some automated behavior that can be invoked/triggered in a particular context, and may be invoked either manually or when a particular event occurs. Most commonly, services work in the context of a particular message, when the message is originally received by Telerivet.
  - `id` string: ID of the service
  - `name` string: Name of the service
  - `service_type` string: Type of the service.
  - `active` boolean: Whether the service is active or inactive. Inactive services are not automatically triggered and cannot be invoked via the API.
  - `priority` integer: A number that determines the order that services are triggered when a particular event occurs (smaller numbers are triggered first). Any service can determine whether or not execution "falls-through" to subsequent services (with larger priority values) by setting the return_value variable within Telerivet's Rules Engine.
  - `contexts` object: A key/value map where the keys are the names of contexts supported by this service (e.g. message, contact), and the values are themselves key/value maps where the keys are event names and the values are all true. (This structure makes it easy to test whether a service can be invoked for a particular context and event.)
  - `vars` object: Custom variables stored for this service. Variable names may be up to 32 characters in length and can contain the characters a-z, A-Z, 0-9, and _. Values may be strings, numbers, or boolean (true/false). String values may be up to 4096 bytes in length when encoded as UTF-8. Up to 100 variables are supported per object. Setting a variable to null will delete the variable.
  - `url` string: URL to this service in the Telerivet web app
  - `url_edit` string: URL to edit the service in the Telerivet web app
  - `project_id` string: ID of the project this service belongs to
  - `response_table_id` string: ID of the data table where responses to this service will be stored
  - `phone_ids` string: IDs of phones (basic routes) associated with this service, or null if the service is associated with all routes. Only applies for service types that handle incoming messages, voice calls, or USSD sessions.
  - `message_types` string[]: Types of messages that this service handles. Only provided for service types that handle incoming messages.
  - `table_ids` string: IDs of data tables that this service applies to, or null if this service applies to all data tables. Only provided for data row services (`data_row_script` and `data_row_actions`).
  - `message_statuses` string[]: Message statuses that this service handles. Only provided for `message_status_actions` services.
  - `tags` string[]: Tags used to organize this service. Each tag can be up to 32 characters in length.
  - `apply_mode` 'always' | 'unhandled': If apply_mode is `unhandled`, the service will not be triggered if another service has already handled the incoming message. If apply_mode is `always`, the service will always be triggered regardless of other services. Only applies to services that handle incoming messages.
  - `contact_number_filter` 'long_number' | 'all': If contact_number_filter is `long_number`, this service will only be triggered if the contact phone number has at least 7 digits (ignoring messages from shortcodes and alphanumeric senders). If contact_number_filter is `all`, the service will be triggered for all contact phone numbers. Only applies to services that handle incoming messages.
  - `show_action` boolean: Whether this service is shown in the 'Actions' menu within the Telerivet web app when the service is active. Only provided for service types that are manually triggered.
  - `direction` 'incoming' | 'outgoing' | 'both': Determines whether the service handles incoming voice calls, outgoing voice calls, or both. Only applies to services that handle voice calls.
  - `webhook_url` string: URL that a third-party can invoke to trigger this service. Only provided for services that are triggered by a webhook request.
  - `is_custom_template` boolean: Whether this service was created from a custom service template
  - `solution_id` string, nullable: ID of the solution that this service belongs to, if any

## Other responses

- `400`: Invalid request parameters
- `401`: Invalid or missing API key or Bearer token
- `404`: Resource not found

---

[API](https://skmtc.dev/telerivet/apis/telerivet-api.md) · [All operations](https://skmtc.dev/telerivet/apis/telerivet-api/llms.txt) · [OpenAPI document](https://skmtc.dev/telerivet/apis/telerivet-api/revisions/4e14b1c8d917?raw)
