HTTP Request
    • 18 Apr 2024
    • 7 Minutes to read
    • Dark
      Light
    • PDF

    HTTP Request

    • Dark
      Light
    • PDF

    Article Summary

    Who should read this article: Administrators

    The HTTP Request node allows you to send HTTP requests and receive data in JSON format, then process the data in the flow. It enables you to integrate external data into Voiso contact center interactions as custom variables.

    Introduction

    Use the HTTP Request node to send either a GET or a POST request to a web service. You can chain HTTP requests together. Use the request response to retrieve data from an endpoint and pass the data as a custom variable to the next node, such as another HTTP Request node or a Send Message node.

    Connections

    The HTTP Request node supports unlimited input connection and up to 2 output connections.

    Important

    The HTTP Request node requires at least one input connection and one output connection from either the Done or Error connection.

    Use Case: Self-service contact center

    You can use the HTTP Request node to build a self-service IVR for your contact center. For example, you can use a GET request to obtain various data from one or more web services, then pass the data as variables to the Send Message node to create an SMS or WhatsApp message and send it to the caller.

    Use Case: Third-party system notification

    The HTTP Request node can be used to collect caller information, such as the ANI (Caller ID) at the start of a flow and, using the POST method, send it to a third-party application, such as a CRM, which can then screen pop the contact's record.

    Use Case: Authorization

    While a contact is browsing your website, you can present them with a phone number to call to verify their identity. When the call enters the flow, you can obtain the ANI and compare it with a phone number stored in your contact list for the person.

    Using the HTTP Request node

    To add an HTTP Request node to your interaction flow, click the HTTP Request icon:

    Flow Builder HTTP Request Node

    The HTTP Request node allows an unlimited number of input connections and up to two output connections.

    Flow Builder HTTP Request Node Blank

    To make an input connection, drag a link to the HTTP Request node from any node supporting an output connection. To make an output connection, drag a link from the HTTP Request node to any node supporting an input connection.

    Flow Builder HTTP Request Node Making Connections

    Important

    You may have an unlimited number of HTTP Request nodes in a call flow; however, the total number of HTTP requests that may be executed during a call flow is 100.

    The HTTP Request node has two output connections: Done and Error. At least one of these connections must be set. These connections represent one of the two possible outcomes for the node when an HTTP request is made to a web service URL.

    Done

    If the URL is accessible and the request receives a response with a 2xx status code and a variable, if any, is successfully mapped, the flow is routed to the Done connection.

    Error

    If the URL is not accessible, does not respond within 5 seconds, or returns a non-2xx status code, the flow is routed to the Error connection.

    Variables

    The HTTP Request node supports system and custom variables that you can use when building requests and when passing data to the next node.

    System variables

    The following four system (global) variables are available:

    VariableDescriptionExample
    {{start_time}}The time the interaction started.2023-08-21T04:02:18Z
    {{ani}}The calling number (ANI).443336006114
    {{dnis}}The number dialed (DNIS).380631234567
    {{phone_type}}The type of phone for the ANI.fixed_line

    Custom variables

    You can include dynamic content in your HTTP requests by leveraging custom variables in the URL field. Click "{ }" to display the Variables menu or manually enter a variable by typing its name enclosed in double brace brackets like this: {{variableName}}.

    You can use the variable to contain a complete, correctly formatted URL, or you can mix text with variables to define the URL based on the values contained in the variables. Variable names must be enclosed in double brace brackets like this: {{variableName}}.

    Here are a few examples for how you can use variables in the URL field:

    • GET {{balanceURL}}, where balanceURL contains a complete URL like this: https://mybankingservice.com/checkbalance?q=39ryw7e
    • https://mybankingservice.com/checkbalance?q={{balanceVariable}}
    • https://mybankingservice.com/{{customerRequest}}?q={{customerVariable}}
    • https://{{serviceBaseURL}}/{{service}}?q={{customerVariable}}

    The HTTP Request node enables you to define and use custom variables that you can use to store a data key from a request response using the JSONPath expression.

    Custom variables enable you to reuse data from a request response elsewhere in your interaction flow. For example, if you have an endpoint response like this:

    {
      "contact": {
        "name": "Richard Sanchez",
        "age": 30
      }
    }
    

    You can specify an expression in the JSONPath field to extract and reference the "name" value, Richard Sanchez, like this:

    $.contact.name
    

    Flow Builder HTTP Request Using Custom Variables

    In this example, the value of the new customer string variable {{customerName}} is $.contact.name. The retrieved data value is Richard Sanchez.

    Tip

    The JSONPath field supports up to 128 characters.

    Passing data to other nodes

    You can reference the custom variable from an HTTP Request node in the following nodes:

    Send messages

    For example, the value for customerName from the previous example can be passed to a Send Message node and used to populate a message with the contact name. Enter {{customerName}} in the body of a message. When the message is sent to the contact, the value stored in customerName is inserted into the message.

    Flow Builder HTTP Request Node JSONPath Pass Value Sample Revised

    Conditions

    Refer to the Introduction in the Conditions node article.

    Configuring the HTTP Request node

    To configure an HTTP Request node in your interaction flow, click the HTTP Request node to display the HTTP Request node panel.

    Method

    The HTTP Request node supports two methods, GET and POST. Different configuration options are available, depending on which method you select from the Method menu.

    GET Request

    To configure a GET request, select GET from the Method menu.

    Flow Builder HTTP Request Node Blank GET Revised

    URL

    Enter the URL of the web service to which you are going to send the request. The URL can include system and custom variables.

    Test request

    When you enter a URL in the URL field, the Test Request button becomes available. Click the button to verify the URL and see a preview of the response.

    If the request fails, the Test request field displays [].

    If the request is successful, a JSON response is displayed. For example:

    {
      "account": 54321000
      "balance": 684415.39
    }
    

    Mapping settings

    In the Mapping settings section, specify a value from the response to be assigned to a custom variable you define or specify.

    Use the custom variable in other nodes, such as another HTTP Request or Send Message. For more information about using variables with the HTTP Request node, refer to Using the HTTP Request node above.

    In the following example, the value for the id parameter, the contact's ID number, is assigned to the customerName variable.

    Flow Builder HTTP Request Node GET JSONPath Example Revised

    POST Request

    To configure a POST request, select POST from the Method menu.

    Flow Builder HTTP Request Node Blank POST Revised

    URL

    Enter the URL of the web service to which you are going to send the request. The request URL can include variables.

    Request body

    Enter the body of the request as a JSON object. The request can include system and custom variables, including custom variables from other HTTP Request nodes. Click "{ }" to display the Variables menu or manually enter a variable by typing its name enclosed in double brace brackets like this: {{variableName}}. This example uses the {{ani}} system variable and the {{contactID}} custom variable:

    {
      "contacts": [
        {
          "phoneNumber": "{{ani}}",
          "contactID": "{{contactID}}",
          "contactSource": "",
          "contactURL": "",
          "priority": ""
        }
      ]
    }
    

    Test request

    When you enter the request body, the Test Request button becomes available. Click the button to verify the URL and request and see a preview of the response.

    Tip

    To test a request with a variable, enter a test value instead of the variable name. Once the request returns the expected result, replace the test value with the variable. For example, use a phone number value to test the {{ani}} variable.

    If the request fails, the Test request field displays [].

    If the request is successful, the expected response is displayed in the Test request field.

    Flow Builder HTTP Request Node POST Success Example Revised

    Mapping settings

    In the Mapping settings section, specify a value from the response to be assigned to the custom variable, such as {{customerName}}.

    Use the custom variable in other nodes, such as another HTTP Request or Send Message. For more information about using variables with the HTTP Request node, refer to Using the HTTP Request node above.


    Was this article helpful?


    What's Next