Use the IVR Loop Node to Process API Returned Lists

Updated 

Sprinklr's Interactive Voice Response (IVR) system enables admins to loop through values within lists returned by APIs. This guide covers how to leverage the Loop node to iterate over each item in a list and dynamically perform actions on each value, such as sending individualized messages.

APIs enable data exchange between different systems. They can be used to retrieve data from various sources, such as CRM systems holding customer information or secure banking servers managing account details. In the context of Sprinklr IVR, some APIs may return lists, such as lists of accounts or transactions, which can then be processed item-by-item using the Loop node.

Usage Scenario

In IVR workflows, businesses may encounter scenarios where an API response includes a list of items needing further action. For instance, a banking API might return a list of credit card numbers, and the IVR could send an SMS for each card. The Loop node allows this type of iteration without manually handling each list item individually.

Solution: Use the Loop Node

The Loop node iterates through each element of an array returned by an API and applies specified actions. Here’s how it works:

1. Collection Variable: This variable represents the list or array returned by the API. The Loop node will perform actions on each item in this collection.

2. Loop Direction: This setting controls the order in which list items are processed. Selecting "First to Last" will start the iteration from the first item.

3. Loop Variable Name: Define a name for the loop variable to be used in subsequent nodes for easier reference.

The Loop node executes each iteration within the “Each Item” path, processing each array item in sequence. For example, if the objective is to send SMS messages for each item in an array, you can use the loop variable in a "Send SMS" node. The loop will automatically terminate once all items have been processed.

Configuration Steps

1. Name: Name the Loop node

2. Configure the Collection Variable: This should match the array provided by the API.

3. Set Loop Direction: Choose the processing order, such as “First to Last.”

4. Define Loop Variable Name: This name is referenced in subsequent actions.

Visual Representation of the Loop Node

On the IVR builder canvas, the Loop node includes two main paths:

Each Item: Executes actions on every array element. For instance, you can connect nodes such as "Send SMS" to this path for each array item.

• After Last Item: Moves the workflow forward once all items have been processed.


Note:

  • The loop automatically follows the “Each Item” path for every list item.

  • Upon reaching the last item in the list, the path completes.

  • The loop must conclude on “Add Item” or through Break Loop.

  • Avoid using an IVR node within the loop until a Break Loop is applied.

Break Loop: Conditional Exit

In some cases, you may need to exit the loop before reaching the end of the list based on a specific condition. To do this, place a Break Loop node along the “Each Item” path and connect it back to the Loop node. This configuration will exit the loop upon meeting the specified condition, moving the workflow directly to the “After Last Item” path.

Using the IVR Loop node effectively enables dynamic operations on each element of an array returned by an API. This approach helps streamline actions like sending multiple SMS messages and can be customized based on conditions for flexible workflows in the IVR Builder.