Reputation: 788
I'm developing a bot with BotFramework 4 where I prompt the user with a choice of a few dynamic dollar amounts for example like:
please choose an amount 1) total statement balance $29.99 2) total outstanding balance $35.00
and currently I get back the answer with the whole text value and I need to parse out the value. my question is is there a way to add some underlying metadata to the choice object, for my example I'd add the dollar amount so when the user chooses an option I'll get back the dollar amount for that choice
Upvotes: 0
Views: 208
Reputation: 12153
Maybe using adaptive cards here will be a workaround, try the code below :
protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
if (turnContext.Activity.Text.Equals("give me a choice"))
{
var adaptiveJsonString = "{\"$schema\":\"https://adaptivecards.io/schemas/adaptive-card.json\",\"type\":\"AdaptiveCard\",\"version\":\"1.0\",\"body\":[{\"type\":\"TextBlock\",\"text\":\"choose an amount\",\"size\":\"large\"}],\"actions\":[{\"type\":\"Action.Submit\",\"title\":\"total statement balance $29.99\",\"data\":\"29.99\"},{\"type\":\"Action.Submit\",\"title\":\"total outstanding balance $35.00\",\"data\":\"35.00\"}]}";
var adaptiveCardAttachment = new Attachment()
{
ContentType = "application/vnd.microsoft.card.adaptive",
Content = JsonConvert.DeserializeObject(adaptiveJsonString),
};
await turnContext.SendActivityAsync(MessageFactory.Attachment(adaptiveCardAttachment), cancellationToken);
}
else {
await turnContext.SendActivityAsync(MessageFactory.Text("You inputed : " + turnContext.Activity.Text), cancellationToken);
}
}
Result :
If you want to know more about adaptive cards, this official blog will be helpful.
Hope it helps.
Upvotes: 1