Caio Franco Barreiro Caio Franco Barreiro - 2 months ago 38
C# Question

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

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 ?


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.