Using the HTTP Request node in the RingCX Workflow Studio
=========================================================

The HTTP Request node in Workflow Studio lets you make HTTP requests to external web services during an interaction, allowing the IVR to send or retrieve data in real time.

For example, you can use this node to access account information, provide order statuses, or update records based on caller input. The HTTP Request node lets you connect your IVR with web-based services to create flexible and interactive call experiences.

Note  
* The HTTP Request node can retrieve, send, create, or update information by sending HTTP requests to external web services using REST protocols. For some integrations, you may need to provide additional details.
* Using the HTTP Request node requires a working knowledge of API integrations.

Adding an HTTP Request node
---------------------------

* In the [<var class="keyword">
  <div style="display: inline;">
  Admin Portal
  </div></var>](https://service.ringcentral.com ""), click **Contact Center** , then select *Admin*. Sign in to [<var class="keyword">
  <div style="display: inline;">
  RingCX
  </div></var>](https://ringcx.ringcentral.com/ "") and click the **Admin** tile.
* In the left navigation bar, click the **Categorization** icon (A), then click **Workflows** (B).

  ![](https://assets.ringcentral.com/content/dam/xml-assets/doc_team/en_us/ringcentral/RingCX/Using-the-WWW-node-in-the-RingCX-IVR-Studio/images/workflows.png)

* Expand the workflow group, then click the **Workflow** you want to build.
* In the left navigation, click **Workflow Studio**.
* Drag and drop the HTTP Request node from the palette onto the background.
* Hover over the HTTP Request node, then click **Edit** .

  ![](https://assets.ringcentral.com/content/dam/xml-assets/doc_team/en_us/ringcentral/RingCX/Using-the-WWW-node-in-the-RingCX-IVR-Studio/images/2-edit.png)

  Interaction context data can be used in multiple areas when configuring nodes in RingCX. For details on using interaction context for the HTTP Request node, visit[Managing data with interaction context support](https://support.ringcentral.com/article-v2/managing-data-with-interaction-context-support.html?brand=RingCentral&product=RingCX&language=en_US "").

  ![](https://assets.ringcentral.com/content/dam/xml-assets/doc_team/en_us/ringcentral/RingCX/Using-the-WWW-node-in-the-RingCX-IVR-Studio/images/3-context.png)

* Type a **Node ID** for the node.
* Select the type of web integration from the **Type** dropdown. You have the following options:
  * *HTTP Get*: Retrieves information about a REST API resource.
  * *HTTP Patch*: Updates a REST API resource.

* Type the **URL** the workflow will use for the web integration.
* Select an**Audio File** to play while the workflow communicates with the external resource. You have the following options:
  * Click the **Manual Entry** pencil and paper icon and provide the exact audio file name in the field that appears.
  * Click the **Open Audio Library** table icon, select an audio file from a list of global or account-level audio files, then click **OK**.

* Enter a **Timeout** in seconds that determines how long the workflow waits for communication with the external resource before timing out.
* Complete the additional fields as needed depending on the type you selected.
* Click **OK**.

### Additional node properties

Additional HTTP type-specific properties appear depending on the web integration you select from the Type field. Most of these settings depend on the specific system you are communicating with. Some familiarity with web services and APIs may be necessary to configure this section.

* **Format** (*HTTP Post and HTTP Put only*): Determines the HTTP content to be included in a request. You can include URL values, XML, JSON, or Plain Text.
* **Name**: The customer-defined name of the variable. This is generally set by the system receiving the data.
* **Type** : Specifies the options for the *Mapping* field.
  * *Call Data*: Values that pertain to the current workflow.
  * *Workflow Variable*: The name of a variable defined in Workflow Studio (prefixed by the '$').
  * *Fixed Value*: A constant alphanumeric string.

* **Mapping**: The data value to send for the current variable or header.
* **Variables** : Click **Add New** to add new variables used for an *HTTP Get request*.
* **Custom HTTP Headers** : Click **Add New** to add new headers used for an *HTTP Get request*.
* **Authentication** : Select external credentials from the dropdown or click **New credential**to add credentials for the external web service.

Configuring authentication
--------------------------

If your external system requires authentication, you can either select existing external credentials from the dropdown (A) or create a new credential by clicking the **New Credential**button (B).

For more information, visit [Setting up external credentials for authentication with RingCX Web Services](https://support.ringcentral.com/article-v2/Setting-up-external-credentials-for-authentication-with-RingCX-Web-Services.html?brand=RingCentral&product=RingCX&language=en_US "").

![](https://assets.ringcentral.com/content/dam/xml-assets/doc_team/en_us/ringcentral/RingCX/Using-the-WWW-node-in-the-RingCX-IVR-Studio/images/4-new-credential.png)

Accessing HTTP Request node results
-----------------------------------

After the HTTP Request node runs, its response, including the response body, headers, and status code, can be accessed differently depending on the interaction type and trigger. To access the results, use the JavaScript node.

|----------------------|---------------------------------|----------------------------|------------------------------------------------------|
| **Interaction type** | **Trigger type**                | **How to access results**  | **Example**                                          |
| Voice or digital     | Any other trigger besides Start | localData.Node_ID.property | localData.MyHTTPNode.body                            |
| Voice                | Start                           | ivr.getData("Node_ID")     | var respObj = JSON.parse(ivr.getData("MyHTTPNode")); |

### Digital interactions or non-Start triggers

For digital interactions (like chat or messaging) or voice workflows triggered by events other than the Start trigger (for example, On Agent Connected), the HTTP Request node results are stored automatically in the localData object.

You can use localData to access the response directly, and do not need to parse to a JSON object before accessing its fields.

* **Access Syntax**: localData.Node_ID.property
* **Response Body**: localData.Node_ID.body (JSON object, no parsing needed)
* **Status Code**: localData.Node_ID.statusCode
* **Headers**: localData.Node_ID.headers (an array of objects)

#### Response Example

After a HTTP request node runs GetCustomerInfo, the localData.GetCustomerInfo object would look like the following. Notice the body is already parsed into a JSON object.

```
{  
"body": {  
"user": {  
"id": "u-12345",  
"name": "Jane Doe",  
"accountStatus": "Active",  
"ticketCount": 5  
},  
"lastLogin": "2025-10-29T10:30:00Z"  
},  
"statusCode": 200,  
"headers": [  
{ "name": "Content-Type", "value": "application/json" },  
{ "name": "Date", "value": "Wed, 29 Oct 2025 11:45:00 GMT" },  
{ "name": "X-Request-ID", "value": "abc-123-xyz" }  
]  
}
```

#### Error handling

The following is an example of the code you may use in the JavaScript node following your HTTP request node (for example, GetCustomerInfo).

```
try {  
// First, check if the response object exists. A timeout or network error could prevent it from being created.  
if (localData.GetCustomerInfo && localData.GetCustomerInfo.statusCode) {  

  // --- Success Path (Status Code 200) ---  
  if (localData.GetCustomerInfo.statusCode === 200) {  
      // The response body is already a parsed object.  
      var responseBody = localData.GetCustomerInfo.body;  
 
      // Extract and store data  
      // We can access properties directly without JSON.parse()  
      sessionData.customerName = responseBody.user.name;  
      sessionData.accountStatus = responseBody.user.accountStatus;  
      workflow.debug("Successfully retrieved data for: Screen-reader: " + sessionData.customerName);  
 
  }  
  // --- Error Path (Status Code is not 200) ---  
  else {  
      var statusCode = localData.GetCustomerInfo.statusCode;  
      workflow.error("API request failed with status code: " + statusCode);  
      sessionData.apiCallFailed = true;  
 
      // Handle different HTTP error codes with specific user-facing messages  
      switch (statusCode) {  
          case 404:  
              sessionData.errorMessage = "Sorry, we could not find your record.";  
              break;  
          case 503:  
              sessionData.errorMessage = "The service is temporarily unavailable. Please try again later.";  
              break;  
          default:  
              sessionData.errorMessage = "We're sorry, an unexpected system error occurred.";  
              break;  
      }  
  }  
} else {  
  // Handle cases where the HTTP node timed out or failed to execute, so no response was stored.  
  workflow.error("HTTP node did not return a response. It may have timed out.");  
  sessionData.apiCallFailed = true;  
  sessionData.errorMessage = "We're sorry, our system is experiencing delays. Please call back later.";  
}  
} catch (scriptError) {  
// Catch any other unexpected script errors  
workflow.error("An unexpected error occurred in the script: " + scriptError.message);  
sessionData.apiCallFailed = true;  
sessionData.errorMessage = "We're sorry, a critical system error occurred.";  
}
```

### Voice interactions with a Start trigger

For voice workflows that begin with a **Start** trigger, the HTTP Request node results are stored in the IVR data context and must be retrieved using the ivr.getData() function. The entire response is returned as a single JSON string, which requires two levels of parsing: the first for the response wrapper, the second for the response body itself.

The response structure includes the following:

|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Property**     | **Description**                                                                                                                                                 |
| response_body    | The main content of the response (usually JSON or text)                                                                                                         |
| response_headers | An array of response headers in plain string. Each header includes a name and value field, for example: { "name": "Content-Type", "value": "application/json" } |
| status_code      | The HTTP status code (for example, 200 for success, 404 for not found)                                                                                          |

#### Response example

The function ivr.getData ("GetCustomerInfo") returns a single string in this format. Notice the response_body is an escaped string.

```
{  
"status_code": 200,  
"reason_phrase": "OK",  
"response_body": "{\n  "user": {\n    "id": "u-12345",\n    "name": "Jane Doe",\n    "accountStatus": "Active",\n    "ticketCount": 5\n  },\n  "lastLogin": "2025-10-29T10:30:00Z"\n}",  
"response_headers": [  
  { "name": "Content-Type", "value": "application/json" },  
  { "name": "Date", "value": "Wed, 29 Oct 2025 11:45:00 GMT" },  
  { "name": "X-Request-ID", "value": "abc-123-xyz" }  
]  
}
```

#### Error handling

The following is an example of the code you may use in the JavaScript node following your HTTP request node (for example, GetCustomerInfo).

```
try {  
  // 1. Get the raw response string from the IVR context  
  var rawResponse = ivr.getData("GetCustomerInfo");  
 
  if (rawResponse) {  
      // 2. Parse the outer response wrapper  
      var respObj = JSON.parse(rawResponse);  
 
      // --- Success Path (Status Code 200) ---  
      if (respObj.status_code === 200) {  
          // Use a try...catch block for parsing the inner response body  
          try {  
              // 3. Parse the inner response_body string to get the actual data  
              var responseBody = JSON.parse(respObj.response_body);  
 
              // Extract and store data  
              sessionData.customerName = responseBody.user.name;  
              sessionData.accountStatus = responseBody.user.accountStatus;  
              workflow.debug("Successfully retrieved data for: " + sessionData.customerName);  
 
          } catch (parseError) {  
              // Handle JSON parsing errors for the response_body  
              workflow.error("Failed to parse JSON response body: " + parseError.message);  
              sessionData.apiCallFailed = true;  
              sessionData.errorMessage = "Sorry, we encountered a data format error.";  
          }  
      }  
      // --- Error Path (Status Code is not 200) ---  
      else {  
          var statusCode = respObj.status_code;  
          workflow.error("API request failed with status code: " + statusCode);  
          sessionData.apiCallFailed = true;  
 
          // Handle different HTTP error codes with specific user-facing messages  
          switch (statusCode) {  
              case 404:  
                  sessionData.errorMessage = "Sorry, we could not find your record.";  
                  break;  
              case 503:  
                  sessionData.errorMessage = "The service is temporarily unavailable. Please try again later.";  
                  break;  
              default:  
                  sessionData.errorMessage = "We're sorry, an unexpected system error occurred.";  
                  break;  
          }  
      }  
  } else {  
      // Handle cases where the HTTP node timed out or failed to execute.  
      workflow.error("HTTP node did not return a response. It may have timed out.");  
      sessionData.apiCallFailed = true;  
      sessionData.errorMessage = "We're sorry, our system is experiencing delays. Please call back later.";  
  }  
} catch (scriptError) {  
  // Catch any other unexpected script errors (e.g., the first JSON.parse)  
  workflow.error("An unexpected error occurred in the script: " + scriptError.message);  
  sessionData.apiCallFailed = true;  
  sessionData.errorMessage = "We're sorry, a critical system error occurred.";  
}
```

Using the response data in your workflow
----------------------------------------

Once you have processed the HTTP response data, and stored the values in sessionData, you can use these variables to route the interaction in your workflow.

### Branching based on the results

Use a [**Branch** node](https://support.ringcentral.com/article-v2/What-nodes-can-do-in-RingCX-IVR-Studio-.html?brand=RingCentral&product=RingCX&language=en_US "") to create different paths for success and failure scenarios.

* In Workflow Studio, drag and drop a **Branch** node after your **JavaScript** node.
* Hover over the **Branch** node, then click **Edit** . Define your conditions as follows:
  * **Success Condition** : sessionData.apiCallFailed !== true \&\& sessionData.accountStatus === 'Active'
    * **Path**: Connect this to your standard flow for active customers.
  * **Failure Condition** : sessionData.apiCallFailed === true
    * **Path** : Connect this to an error-handling flow. For example, you could use a [**Say Variable**](https://support.ringcentral.com/article-v2/Using-the-Say-Var-node-in-the-RingCX-IVR-Studio.html?brand=RingCentral&product=RingCX&language=en_US "") node to play the sessionData.errorMessage and then transfer the interaction to an agent queue.
  * **Else**: Create a default path for any other outcomes (for example, an inactive account).

### Playing data back

In your success path, you can provide personalized information to play the response back to the customer.

* In Workflow Studio, drag and drop a [**Say Variable**](https://support.ringcentral.com/article-v2/Using-the-Say-Var-node-in-the-RingCX-IVR-Studio.html?brand=RingCentral&product=RingCX&language=en_US "") node onto the background.
* Hover over the **Say Variable** node, then click **Edit**.
* From the **Type** dropdown, select **Text-to-Speech**.
* Enter the text to say in the **Say Value** field. For example, enter

  Hello, ${sessionData.customerName}. I see your account is active. How can I help you today?

In your failure path, you can provide a helpful error message.

* In Workflow Studio, drag and drop a [**Say Variable**](https://support.ringcentral.com/article-v2/Using-the-Say-Var-node-in-the-RingCX-IVR-Studio.html?brand=RingCentral&product=RingCX&language=en_US "") node onto the background.
* Hover over the **Say Variable** node, then click **Edit**.
* From the **Type** dropdown, select **Text-to-Speech**.
* Enter the text to say in the **Say Value** field. For example, enter

  ${sessionData.errorMessage}

This approach ensures your workflow handles both successful and failed API calls gracefully, regardless of the workflow type.

**Additional resources**  
[Using Workflow Studio in RingCX](https://support.ringcentral.com/article-v2/Intro-to-IVR-Studio-in-RingCX.html?brand=RingCentral&product=RingCX&language=en_US "")  
[Intro to workflows in RingCX](https://support.ringcentral.com/article-v2/Intro-to-IVR-Designer-in-RingCX.html?brand=RingCentral&product=RingCX&language=en_US "")  
[Intro to workflow triggers in RingCX](https://support.ringcentral.com/article-v2/Intro-to-workflow-triggers-in-RingCX.html?brand=RingCentral&product=RingCX&language=en_US "")  
[What nodes can do in RingCX IVR Studio](https://support.ringcentral.com/article-v2/What-nodes-can-do-in-RingCX-IVR-Studio-.html?brand=RingCentral&product=RingCX&language=en_US "")  
[Creating a workflow in RingCX](https://support.ringcentral.com/article-v2/Creating-an-IVR-in-RingCX.html?brand=RingCentral&product=RingCX&language=en_US "")

