How to call a specifc callback when clicking in Card Action - Bot Framework

痞子三分冷 提交于 2019-12-22 08:21:38

问题


I'm showing a carousel with a few products that have a button in each one with a code. the Card Action Type is 'ImBack' but the click in button will call the root dialog again once the carousel is showed by postAsync method.

Is there a way to define a callback for the button click or to show the same carousel but using PromptDialog ?


回答1:


There is no way to define a callback on Card Action button. When the Card Action is defined as ImBack, after you click on it; it will basically post a message to the bot and thus it will be handled by the method that you defined when you called to context.Wait after posting your carousel.

The way to go here is have another method (different than your MessageReceivedAsync), just to keep your code clean, and do a context.Wait on that method. Then on that method you will basically have to based on the message the bot receives (which will be the value of the card action) decide what to do.

In the ContosoFlowers sample you will find an example of this. See the ContosoFlowersCategoriesDialog and the PagedCarouselDialog.



来源:https://stackoverflow.com/questions/40808192/how-to-call-a-specifc-callback-when-clicking-in-card-action-bot-framework

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