I am working on BOT Framework(C#), I am facing one issue and need your help. Below code is for showing the carousel of Hero card and on the selection of one of Hero Card I want to call a callback method, in below example you can see OnCardSelection is the method which I want to call on Card selection, but on execution of line context.Wait(onCardSelection) i am getting below error
invalid need: expected Call, have Wait
and may be due to this it is ending the conversation and consider further action (Click on Hero card) as a new conversation. Also, I want to access details of the card in OnCardSelection method. How to achieve this. Thank you.
[LuisModel("your sub key", "secret")]
[Serializable]
public class BotManager : LuisDialog<object>
{
public async Task RaiseTicket(IDialogContext context, LuisResult result)
{
PromptDialog.Confirm(
context: context,
resume: ResumeAndHandleConfirmRaiseTicketAsync,
prompt: "It looks like you want to raise a ticket. Do you want to continue?",
retry: "I didn't understand. Please try again.");
}
private async Task ResumeAndHandleConfirmRaiseTicketAsync(IDialogContext context, IAwaitable<bool> argument)
{
bool choicesAreCorrect = await argument;
if (choicesAreCorrect)
{
RaiseTicket objRaiseTicket = new RaiseTicket();
await objRaiseTicket.StartAsync(context);
}
else
{
await context.PostAsync("Okay");
}
}
}
[Serializable]
public class RaiseTicket
{
public async Task StartAsync(IDialogContext context)
{
TypeOfTicket typeOfTicket;
context.UserData.TryGetValue("TypeOfTicket", out typeOfTicket);
if (typeOfTicket == TypeOfTicket.None)
{
//RaiseTicket
}
else
{
await PickExactCategory(context);
}
}
public async Task PickExactCategory(IDialogContext context)
{
var message = context.MakeMessage();
message.AttachmentLayout = AttachmentLayoutTypes.Carousel;
message.Attachments = GetCardsAttachments(categoryList);
await context.PostAsync(message);
context.Wait(OnCardSelection);
}
protected async Task OnCardSelection(IDialogContext context, IAwaitable<IMessageActivity> result)
{
var answer = await result;
context.Done(new object());
}
private IList<Attachment> GetCardsAttachments(Categorylist[] categoryList)
{
List<Attachment> lstAttachment = new List<Attachment>();
foreach (Categorylist item in categoryList)
{
lstAttachment.Add(GetHeroCard(
item.Title, item.SubTitle,item.Text,
new CardAction(ActionTypes.ImBack, "Select", value: item.Tier3)));
}
return lstAttachment;
}
private static Attachment GetHeroCard(string title, string subtitle, string text, CardAction cardAction)
{
var heroCard = new HeroCard
{
Title = title,
Subtitle = subtitle,
Text = text,
Buttons = new List<CardAction>() { cardAction },
};
return heroCard.ToAttachment();
}
}