Thank you for the quick response. I'm realizing now that in my attempt to simplify my example I removed some necessary context for how the data is gathered and being used.
As I mentioned, we are building dynamic menu prompts based on information pulled from a Data Table, but that is incomplete.
The full workflow is like this
- customer enters their information as they navigate the menu.
- that information is used for an API call into our CRM to return data on an active claim.
- That data follows logic checks to select the needed prompt. (i.e. Appointment Scheduled)
- The needed prompt is looked up in the Data Table.
- The data table includes a mix of Prompt Names and Variable Names that need to be constructed into the Final Prompt.
- PromptName1: Appointment_pt1
- VariableName1: MonkeyType
- PromptName2: Appointment_pt2
- VariableName2: AppointmentDate
- PromptName3: Appointment_p3
- VariableName3: OfficePhone
- PromptName4: RepeatMenu
- The Prompt Names and Variable Names can differ from prompt to prompt (i.e. Item, Service Date, Tech's Name/Phone Number, etc.)
- The results from that look up are used to play a sequence of pre-recorded prompts and TTS of the contents of the Variables.
A final prompt might look like this (variable values in bold):
Our records indicate that the checkup appointment for your Capuchin is scheduled for February 10th. If you are unable to make this appointment, please contact the office at 888-555-1212. To hear this message again, press 1.
The original solution involves a lot a Switch/Decision branches and multiple Play Audio actions - and the final Menu Action does not include the entire prompt. It's not pretty, but it works. (side effect: the built-in repeat menu counter would not play the entire message, only the tail end)
I am looking to streamline and leverage the TTS to build out a String that could be used in the Menu so it can be repeated properly, and was thinking that a Variable reference as I was trying to describe above could be cleaner than calling a multi-layered Switch statement that has a branch for each possible variable name.
Hoping something like that exists.
------------------------------
Peter DeMarco
na
------------------------------
Original Message:
Sent: 02-05-2025 19:14
From: Robert Wakefield-Carl
Subject: Using returned field from Data Table to get value of Variable
You could consider creating collections with the names and the values and writing the values to a JSON object and then use JSONPARSE with $.items[*].value.max(). If that does not work, you could use a custom code like below to get the highest and then do a finditem on your collection and use that value with a GetAt on the names.
const jsonpath = require('jsonpath');const data = { "items": [ {"value": 10}, {"value": 20}, {"value": 30}, {"value": 40}, {"value": 50} ]};const values = jsonpath.query(data, '$.items[*].value');const maxValue = values.reduce((max, val) => Math.max(max, val), -Infinity);console.log(maxValue);
------------------------------
Robert Wakefield-Carl
ttec Digital
Sr. Director - Innovation Architects
Robert.WC@ttecdigital.com
https://www.ttecDigital.com
https://RobertWC.Blogspot.com
------------------------------