Justin Van
Justin Van

Reputation: 307

Bot Framework Prompt Dialog with Image

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

Upvotes: 2

Views: 1844

Answers (1)

Ezequiel Jadib
Ezequiel Jadib

Reputation: 14787

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.

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.

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.

Upvotes: 4

Related Questions