httpRequest

The httpRequest Rule will make an HTTP request to a specified URL during the Call Flow. This can be used to send real-time call information to your system.

Structure

The httpRequest Rule below has the element called "params" which is required.

  • params: It has all the parameters which will be sent on the request. The param attributes are described below:
Attribute Description Mandatory
name This will be the name of the variable we will send YES
value This will be the possible value we will send. This can be a fixed value which is a string or a variable value which will start with $_ YES

The structure for this rule is as follows:

<httpRequest id="httpRequest_1" label="httpRequest" url="http://yourplatform.com" requestMethod="POST">
    <params>
        <!-- Multiple param -->
    </params>
</httpRequest>

There are only two attributes for this rule

Attribute Description Mandatory
url The URL to which we will make the request YES
requestMethod The HTTP method to use for the request. Either POST or GET. YES

Examples

httpRequest with a fixed parameter

The basic example will be to send a fixed value to a URL. The complete URL we will hit will be as follows: http://yourplatform.com/yourpage.php?greeting=hello

You could also use POST as requestMethod and then the POST data would contain your sent parameters.

<httpRequest id="httpRequest_1" label="httpRequest" url="http://yourplatform.com/yourpage.php" requestMethod="GET">
    <params>
        <param name="greeting" value="hello"/>
    </params>
</httpRequest>

httpRequest with a variable parameter

In the following case we will send the caller's phone number in the request params. The HTTP request will be like http://yourplatform.com/yourpage.php?callorigin=447723456666

A full list of available variables that are available to teh Call Flow, and can be sent, can be found here: Internal variables

You could also use POST as requestMethod and then the POST data would contain your sent parameters.

<httpRequest id="httpRequest_1" label="httpRequest" url="http://yourplatform.com/yourpage.php" requestMethod="GET">
    <params>
        <param name="callorigin" value="$_callOrigin"/>
    </params>
</httpRequest>

httpRequest with multiple parameters

Below you have an example of a httpRequest request with multiple parameters. The HTTP request will be like http://yourplatform.com/yourpage.php?callorigin=447723456666&greeting=hello

You could also use POST as requestMethod and then the POST data would contain your sent parameters.

<httpRequest id="httpRequest_1" label="httpRequest" url="http://yourplatform.com/yourpage.php" requestMethod="GET">
    <params>
        <param name="callorigin" value="$_callOrigin"/>
        <param name="greeting" value="hello"/>
    </params>
</httpRequest>

Error Result

HTTP Code Error String Resolution
400 Rule ID Empty Set the value of the id attribute
400 Rule Label Empty Set the value of the label attribute
400 Rule ID Not Unique in httpRequest The value of the id attribute is used for another rule, change it to be unique
400 HTTP REQUEST Request URL Empty Insert url as an atribute of the httpRequest element
400 Request URL Invalid Change the URL to this format: http://domain.tld:port/page or https://domain.tld:port/page