Service

Invoke a service

Manually invoke this service in a particular context.

For example, to send a poll to a particular contact (or resend the current question), you can invoke the poll service with context=contact, and contact_id as the ID of the contact to send the poll to. (To trigger a service to multiple contacts, use project.sendBroadcast. To schedule a service in the future, use project.scheduleMessage.)

Or, to manually apply a service for an incoming message, you can invoke the service with context=message, event=incoming_message, and message_id as the ID of the incoming message. (This is normally not necessary, but could be used if you want to override Telerivet's standard priority-ordering of services.)

post/v1/projects/{project_id}/services/{id}/invoke

Request

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

Path parameters

project_idstring required

ID of the Project

idstring required

ID of the Service

Request body

context'message' | 'call' | 'ussd_session' | 'row' | 'contact' | 'project' | 'airtime_transaction' required

The name of the context in which this service is invoked

eventstring

The name of the event that is triggered (must be supported by this service)

message_idstring

The ID of the message this service is triggered for

contact_idstring

The ID of the contact this service is triggered for (either contact_id or phone_number is required if context is 'contact')

phone_numberstring

The phone number of the contact this service is triggered for (either contact_id or phone_number is required if context is 'contact'). If no contact exists with this phone number, a new contact will be created.

row_idstring

The ID of the data row this service is triggered for

variablesobject

Object containing up to 25 temporary variable names and their corresponding values to set when invoking the service. Values may be strings, numbers, or boolean (true/false). String values may be up to 4096 bytes in length. Arrays and objects are not supported. Within Custom Actions, each variable can be used like [[$name]] (with a leading $ character and surrounded by double square brackets). Within a Cloud Script API service or JavaScript action, each variable will be available as a global JavaScript variable like $name (with a leading $ character).

route_idstring

The ID of the phone or route that the service will use for sending messages by default

asyncboolean

If set to true, the service will be invoked asynchronously. By default, queued services will be invoked one at a time for each project.

Example request

{
  "context": "contact",
  "contact_id": "@{sigil}contact{dot}id"
}

Response

Successful response

return_valuestring

Return value of the service. May be any JSON type (boolean, number, string, array, object, or null). (Undefined if async=true.)

log_entriesstring[]

Array of log entry strings generated by the service. (Undefined if async=true.)

errorsstring[]

Array of error message strings generated by the service. (Undefined if async=true.)

sent_messagesobject[]

Array of messages sent by the service.

airtime_transactionsobject[]

Array of airtime transactions sent by the service (Undefined if async=true.)

Changes

No recorded changes to this operation across all 1 revision of this API.