How to rewrite a Adaptive Card Submit Action for MSTeams also working in Web Chat?

对着背影说爱祢 提交于 2021-01-07 02:40:00

问题


Hi i'm using adaptive Cards and want to generate a Submit Action which works in MS Teams as well as in Webchat.

In Emulator this works fine. After i'm clicking the Button its like the user would type in "Test" in the chat.

"actions": [
    {
      "type": "Action.Submit",
      "title": "Test",
      "data": "Test"
    }

This doesnt work in MS Teams. How to bring this to work?


回答1:


My blog post explains that if you want to use a string submit action you will need to do it differently in Web Chat and Teams: https://blog.botframework.com/2019/07/02/using-adaptive-cards-with-the-microsoft-bot-framework/

If you want to have the same submit action work the same way in both channels, it will need to be an object submit action. If you want a string submit action to work on both channels then your bot will need to check which channel the activity came from and react accordingly.




回答2:


Please try the following sample adaptive card Json,

{"type":"AdaptiveCard","version":"1.0","body":[{"type":"TextBlock","text":"Imback Button"}],"$schema":"http://adaptivecards.io/schemas/adaptive-card.json","actions":[{"type":"Action.Submit","title":"Can you Help me","data":{"msteams":{"type":"imBack","value":"Can you help me"}}}]}

you can test adaptive cards in App studio app in Teams.

Hope this will help you. Thanks.



来源:https://stackoverflow.com/questions/61523621/how-to-rewrite-a-adaptive-card-submit-action-for-msteams-also-working-in-web-cha

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!