带有图像的Bot框架提示对话框 [英] Bot Framework Prompt Dialog with Image

查看:68
本文介绍了带有图像的Bot框架提示对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Bot Framework,我想显示使用方法 PromptDialog.Choice 附加了图像的选项列表,以便利用 ResumeAfterChoose >控制我的业务逻辑的方法.但是,我只看到在

I'm working with the Bot Framework and I want to display list of choices which have image attached by using method PromptDialog.Choice in order to take advantage of the ResumeAfterChoose method to control my business logic. However, I've only seen the Attachment Dialog which has written in EchoBot Sample and it only creates list of messages that make me difficult to handle my business logic after client choose one of the list. Please show me the way to implement that. Thanks

推荐答案

开箱即用,您无法做到.不过,有几种方法可以实现.

Out of the box, you can't do that. There are a few ways to achieve that though.

首先,您是说使用附件对您不起作用,因为您将无法处理业务逻辑.这是部分正确的;但并非出于您提及的原因.

First of all, you are saying that using attachments won't work for you because you won't be able to handle your business logic. That's partially true; but not for the reason you are mentioning.

您可以将带有按钮的HeroCards列表放在一起,并为附件使用轮播布局(请参见

You could put together a list of HeroCards with buttons and use the carousel layout for the attachments (see the RichCards and the CarouselCards samples). Then, you can just perform a context.Wait to a different method (similar to the ResumeAfterChoose method in the PromptDialog) and handle the logic there. That method will get the value of the button clicked and then you can perform your business logic. Now... the caveat with that is that if the user writes anything not aligned to the options you still will hit this method.

猜猜是什么?我刚刚描述的内容与PromptDialog.Choice在后台执行的操作极为相似...唯一的区别是,它添加了Retry逻辑来处理我提到的警告,并且所使用的布局是列表列表,因为它只是呈现单个HeroCard带有多个按钮(选项)

Guess what? What I just described is extremely similar to what the PromptDialog.Choice does behind the scenes... with the only difference that it adds a Retry logic to handle the caveat I mentioned and that the layout used is a list one because it just render a single HeroCard with multiple buttons (the options)

在这种情况下,我将尝试将自定义

The way I would go in this case, is trying to put together a custom PromptStyler, override the Apply<T> method and add your logic to render the Choice options in the way you want based on the PromptStyle used.

默认情况下,

By default the PromptDialog.Choice uses PromptStyle.Auto, that at the end of the game (in the PromptStyler) converts the options into a HeroCard with multiple buttons. You could easily change that logic to create multiple cards and also uses images for them.

这篇关于带有图像的Bot框架提示对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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