Is there a way to read the value of a content variable by programmatically creating the name of the content variable?
For example:
var state = context.entities.NameOfState;
var taxRateVar = “content.” + state + “.taxrate”;
var taxRate = BotContent.get(taxRateVar);
Here is the use case:
I have a list of 50 content variables with names of states:
- content.alabama .taxrate = 7
- content.alaska.taxrate = 6
… - content.wyoming.taxrate = 4
I have a single dialog task that reads the state through an entity variable. Instead of creating a switch case statement with 50 choices, or an if … else if structure with 50 branches, I would like to read the appropriate content variable using BotContent.get(taxRateVar) which would be similar to reading variables from
BotContext, UserSession or UserContext
UserContext.get(“firstName”);