Response rules

Creating response rules

To create a new response rule you can use the /responserules endpoint.

The following fields can be used within the request:

High-level request elements



Specifies the name of the response rule.



Specifies the description of the response rule for others to understand its purpose.



This object contains the responseTemplatePattern array, which contains each of the response rule elements.

Response template patterns

Each response rule has a series of patterns that allow the creator to specify what textual content should be matched in the response SMS or email, and a number that should be entered when IVR (voice) is being used.

The patterns specify the information shown in the table below.

Response template pattern elements



The name of the response category.



Specifies the mechanism for matching the textPrompt.

The following options are available:

  • startsWith
  • contains
  • exactmatch



Specifies the textual string that should be matched using the pattern (specified above) within the email, SMS or web response.



The character (0–9, * or #) that the recipient of the voice call should enter to select a response option.



The text-to-speech content that is dynamically read out when describing to the user what a particular response option is.



The hexadecimal colour code that is used in the Message Response Report to differentiate the groups of responses.

Each response rule can specify as many response template patterns as required.

Each of the patterns specified will also dynamically create buttons within any rich message that is associated with the response rule.

This provides an out-of-the-box capability to quickly gather feedback from the field using a rich user interface, and leveraging SMS as the delivery mechanism.

For more information about using rich messages see Creating templates.

  • JSON
  • XML

Creating response rules

The following API calls allow users to create new response rules using the Whispir API:


HTTP 1.1 POST https://api.<region>[your_key]

Authorization: Basic am9obi5zbWl0aDpteXBhc3N3b3Jk

x-api-key: your_api_key

Content-Type: application/vnd.whispir.responserule-v1+json


"name" : "Response Rule 1",

"description" : "",

"responseTemplatePatterns" : {

"responseTemplatePattern" : [ {

"name" : "Yes Rule",

"textPrompt" : "YES",

"voicePrompt" : "1",

"spokenVoicePrompt" : "to select YES",

"pattern" : "startswith",

"colour" : "#00947d"

} ]




The sample code above will create a simple response rule with a single rule within the default workspace.

The expected response to this call is a HTTP 201 - Created response.