dx111ge
(Sven Andreas)
July 13, 2021, 3:16pm
1
Hello,
i just did try to send a simple adaptive card to MS Teams. I did try the following way:
action Server
class Welcome(Action):
def name(self) → Text:
return “action_welcome”
async def run(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[EventType]:
message ={ "type": "AdaptiveCard", "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "version": "1.3", "body": [{ "type": "TextBlock", "text": "New TextBlock","wrap": True }]}
dispatcher.utter_message(json_message = message)
return []
which ends up with the error:
2021-07-13 17:04:33 INFO root - Rasa server is up and running.
2021-07-13 17:04:51 ERROR rasa.core.channels.botframework - Exception when trying to handle message.‘str’ object has no attribute ‘setdefault’
Is there any working example of MS Teams cards in action Server?
dx111ge
(Sven Andreas)
July 14, 2021, 5:40am
2
content of the message send to MS Teams:
{‘type’: ‘AdaptiveCard’, ‘$schema’: ‘http://adaptivecards.io/schemas/adaptive-card.json ’, ‘version’: ‘1.3’, ‘body’: [
{‘type’: ‘TextBlock’, ‘text’: ‘New TextBlock’, ‘wrap’: True}], ‘recipient’: {‘id’: ‘xxxg’}, ‘from’: {‘id’: ‘2xxx2’, ‘name’: ‘xxxTest’}, ‘channelData’: {‘notification’: {‘alert’: ‘true’}}, ‘text’: ‘’}
dx111ge
(Sven Andreas)
July 14, 2021, 5:49am
3
correct code:
class Welcome(Action):
def name(self) → Text:
return “action_welcome”
async def run(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[EventType]:
newmessage = {
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Hello World!",
"size": "large"
},
{
"type": "TextBlock",
"text": "*Sincerely yours,*"
},
{
"type": "TextBlock",
"text": "Adaptive Cards",
"separation": "none"
}
],
"actions": [
{
"type": "Action.OpenUrl",
"url": "http://adaptivecards.io",
"title": "Learn More"
}
]
}
}
]
}
dispatcher.utter_message(json_message = newmessage)
return []
panrish
(Rishabh Pandey)
August 17, 2021, 7:52am
5
Hi Sven, please help out with an issue! Been stuck for over days now!
In the same code you shared, if I create buttons using “type”: “Action.Submit”. Then how am I supposed to attach respective intent(s) to the buttons, so that next action can be triggered!
For more clarification on this, refer to the link to my query:
HI Forum,
Please help on how to record ‘INTENTS’ from Buttons in Custom_json_payload from Rasa actions? To rephrase how to record the ‘Intent’, when a user presses the buttons in the Adaptive cards in Teams!
I could easily do that with defining ‘Intent’ value to ‘payload’ using below code-
dispatcher.utter_message(text="Please make your selection-", buttons = [
{type: 'messageBack', **"payload": "/Intent1",** "title": "Button1"},
{type: 'messageBack', **"payload…
Please suggest! You would really help a lot!
dx111ge
(Sven Andreas)
August 17, 2021, 8:06am
6
intents are done with the following syntax /intent
panrish
(Rishabh Pandey)
August 17, 2021, 8:34am
7
Where do I attach this syntax- /intent, in the “newmessage”! Can you please correct my code and send the same back to me! Really grateful to you for reaching back! Appreciate your time, @dx111ge !
newmessage = {
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Please select your choice!"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Button1" # Where to attach "/intent1" ?
},
{
"type": "Action.Submit",
"title": "Button2" # Where to attach "/intent2" ?
}
]
}
}
]
}
dispatcher.utter_message(json_message = newmessage)
return []
dx111ge
(Sven Andreas)
August 17, 2021, 8:50am
8
{
“type”: “Action.Submit”,
“title”: “abbrechen”,
“data”: {
“msteams”: {
“type”: “imBack”,
“value”: “/restart”
}
},
“style”: “positive”
}
panrish
(Rishabh Pandey)
August 17, 2021, 9:23am
9
That works! Thanks mate! @dx111ge