Dynamic array indexing using user input in AI Agents (Dialog) | The place for Zendesk users to come together and share
Skip to main content
Question

Dynamic array indexing using user input in AI Agents (Dialog)

  • April 30, 2026
  • 1 reply
  • 15 views

Today, when working with Zendesk AI Agents and JSONata, it is possible to retrieve and display data from APIs (including large arrays), but there is no way to dynamically reference an array position based on user input during the conversation.

A very common use case is displaying a numbered list to the user, for example:

 
1 - Option A  
2 - Option B
3 - Option C
...

The user then replies with a number (e.g., “84”), and the expected behavior would be to map this input back to the corresponding item in the array and retrieve its attributes (such as an ID).

However, today it is not possible to perform something like:

 
var_array[user_input - 1].id

This creates a significant limitation when building scalable conversational flows that rely on dynamic data from APIs.

Why this matters

  • Many APIs return large and dynamic datasets (100+ items, growing over time)
  • Index-based selection is a simple and intuitive UX pattern for users
  • There is currently no native way to map user input back to stored array data
  • JSONata cannot be re-evaluated dynamically during the conversation using user input

As a result, developers are forced to:

  • Use external middleware (e.g., APIs, automation tools) to resolve the selection
  • Or redesign the experience (e.g., forcing buttons or embedding IDs), which is not always feasible

Limitations of current workarounds

  • Creating individual variables for each item does not scale and breaks as data grows
  • External processing adds latency, complexity, and dependency on additional infrastructure
  • UX alternatives are sometimes restrictive or not suitable for all channels

Suggested improvement

Enable dynamic evaluation of variables using user input within the conversation context.

For example:

  • Allow expressions like var_array[user_input - 1]
  • Support runtime evaluation of JSONata (or similar) using variables collected during the dialogue
  • Provide safe handling for invalid indexes (out-of-range, non-numeric input, etc.)

Expected benefits

  • Fully dynamic and scalable conversational flows
  • Reduced dependency on external systems
  • Simpler implementations for common patterns (lists, selections, lookups)
  • Better developer experience when working with APIs
  • More natural and flexible user interactions

1 reply

This!

I’m working with a API and the only way to show this to the user is by creating a carousel.

What also would be very much appreciated is a dynamic user input based on a API response.
E.g.

[
{
"uuid": "ca9411af-67b9-443e-b99b-948d23ff7086",
"title": "option 1"
},
{
"uuid": "dd0a087b-ba15-4e8d-8ec9-f1d7da4afdad",
"title": "option 2",
}
]

 Could show dropdown/list of buttons/radio buttons, where selecting set’s a value from the item.

I want the users to see:

  • [Option 1]
  • [Option 2]

And when they click the button an action should be triggered to set the value of the uuid so I can fetch the data of option 1 and respond to the user.