I have a question that I feel is probably really simple to do, but I can’t figure it out.
My process is: I have a Hubspot form submission for a “Call me back” form, that enters a phone number into a Scenario using a Webhook. I then make an API call to Aircall to get the availability of agents. This returns a JSON with agent IDs and a value for availability: available, unavailable or offline.
Now I want to randomly pick one of the available agents, so that I can put their ID into another API call to Aircall to start an outbound call.
I’m at the point where I have:
- An Iterator to turn the JSON into separate agent bundles
- A filter that runs right after the iterator to only pass agents that have availability = Available.
…but now I need to randomize the selection of the agent somehow. And I’m lost
I’ve tried putting them in a data store first, along with an incremented [i] for a key, then using a Set Variable to generate a random number between 1 and [i] after the last iteration, to decide which record to retrieve from the database. But I reached a dead end there because I couldn’t find a way to stop the iteration without also losing access to the [i]. That’s probably way too convoluted…
This is what I had:
Any ideas? I feel like this should be relatively easy but I can’t figure it out.