Reputation: 1
I have a chatbot that sends an adaptive card asking a question that looks like this. Adaptive Card
When an option is pressed, I want to be able to use the data from this card inside of my code. The JSON file for my card is this:
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"speak": "Somone is trying to take your session.",
"body": [
{
"type": "TextBlock",
"text": "Someone is taking your session!"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Allow",
"data": {
"Value": "allow"
}
},
{
"type": "Action.Submit",
"title": "Deny",
"data": {
"Value": "deny"
}
}
]
}
I know the bot is receiving something from the card as the event OnMessageActivityAsync
is being raised. When I use this bot in the bot framework emulator, it shows here that it IS returning a value.
JSON Response
How can I use this data in my program for a task such as deciding whether the session can be taken in C#?
Upvotes: 0
Views: 448
Reputation: 1
I solved It by using
var val = turnContext.Activity.Value;
string value = Convert.ToString(val);
return value;
I was using strings and because of the conversion issue I could not find how to access this. By switching it to var
solved the issue.
Upvotes: 0