单击Card Action时如何调用特定的回调-Bot Framework [英] How to call a specifc callback when clicking in Card Action - Bot Framework

查看:63
本文介绍了单击Card Action时如何调用特定的回调-Bot Framework的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在展示一种带有一些产品的轮播,每个产品中的每个按钮都带有一个代码.卡片操作类型为"ImBack",但一旦通过postAsync方法显示轮播后,单击按钮将再次调用根对话框.

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.

是否可以使用PromptDialog为按钮单击定义回调或显示相同的轮播?

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

推荐答案

无法在卡片操作"按钮上定义回调.当卡片操作"定义为"ImBack"时,单击它;它基本上会向机器人发布消息,因此将由您调用上下文时定义的方法处理.发布轮播后等待.

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.

这里的方法是使用另一种方法(不同于MessageReceivedAsync),只是为了保持代码干净并执行上下文,请等待该方法.然后,使用该方法,您基本上必须根据机器人收到的消息(这将是卡片操作的值)来决定要做什么.

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.

ContosoFlowers 中进行采样会找到一个例子.请参见 ContosoFlowersCategoriesDialog PagedCarouselDialog .

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

这篇关于单击Card Action时如何调用特定的回调-Bot Framework的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆