private async Task HeroCard(IDialogContext context, List <string> List) { try { var resultMessage = context.MakeMessage(); resultMessage.AttachmentLayout = AttachmentLayoutTypes.Carousel; resultMessage.Attachments = new List <Attachment>(); foreach (var message in List) { HeroCard heroCard = new HeroCard() { Title = message, Images = new List <CardImage>() { new CardImage() { Url = StateKeys.Img } }, //Buttons = new List<CardAction>() //{ // new CardAction() // { // Title = "Ready To Hepl", // Type = ActionTypes.ImBack, // Value = "", // } //} }; resultMessage.Attachments.Add(heroCard.ToAttachment()); } await context.PostAsync(resultMessage); await context.PostAsync("How can I Help you"); RootDialog rootDialog = new RootDialog(); await rootDialog.StartAsync(context); } catch (Exception e) { ExceptionLog.LogFile(e); } }
private async Task MessageReceivedAsync(IDialogContext context) { try { if (Intents.SmallTalkHelpWhatCanYouDo == Luis.intent) { SqlOperations.ForConversationLog(RootDialog.message, "Carousel"); List <string> List = new List <string>(); List = SqlOperations.GetList("OptionsForThingsDoneByBot"); string message = List[0].Replace("{Name}", RootDialog.Name); List.RemoveAt(0); await context.PostAsync(message); await HeroCard(context, List); } else { RootDialog.BotResponse = SqlOperations.ForBotReply(Luis.intent); if (RootDialog.message == "Morning" || RootDialog.message == "Afternoon" || RootDialog.message == "Evening" || RootDialog.message == "Night") { await context.PostAsync(RootDialog.message + " " + RootDialog.BotResponse); SqlOperations.ForConversationLog(RootDialog.message, RootDialog.BotResponse); } else if (RootDialog.BotResponse.Contains("{Name}")) { string message = RootDialog.BotResponse.Replace("{Name}", RootDialog.Name); await context.PostAsync(message); } else { await context.PostAsync(RootDialog.BotResponse); SqlOperations.ForConversationLog(RootDialog.message, RootDialog.BotResponse); } RootDialog rootDialog = new RootDialog(); await rootDialog.StartAsync(context); } } catch (Exception e) { ExceptionLog.LogFile(e); } }
private async Task AdaptiveCards(IDialogContext context) { ListOfAnswer.Clear(); ListOfQusetions.Clear(); ListOfUnAnsweredQuestion.Clear(); AdditionalInfo = string.Empty; NosOfUserImpacted = string.Empty; DisplayedErrorMessage = string.Empty; TaskAttemptedWhileIssue = string.Empty; PinAndFullName = string.Empty; ListOfQusetions = SqlOperations.GetList("OptionsForFaultWiser"); { try { var replyActivity = context.MakeMessage(); replyActivity.Attachments.Add(new Microsoft.Bot.Connector.Attachment() { ContentType = "application/vnd.microsoft.card.adaptive", Content = JObject.Parse($@" {{ ""$schema"": ""http://adaptivecards.io/schemas/adaptive-card.json"", ""type"": ""AdaptiveCard"", ""version"": ""1.0"", ""body"": [ {{ ""type"": ""ColumnSet"", ""columns"": [ {{ ""type"": ""Column"", ""items"": [ {{ ""type"": ""TextBlock"", ""size"": ""Medium"", ""weight"": ""Bolder"", ""text"": ""{ListOfQusetions[0]}"" }}, {{ ""type"": ""TextBlock"", ""text"": ""{ ListOfQusetions[1] }"", }}, {{ ""type"": ""Input.Text"", ""id"": ""PinAndFullName"", ""placeholder"": "" * required"", }}, {{ ""type"": ""TextBlock"", ""text"": ""{ListOfQusetions[2]}"", }}, {{ ""type"": ""Input.Text"", ""id"": ""TaskAttemptedWhileIssue"", ""placeholder"": "" * required"", }}, {{ ""type"": ""TextBlock"", ""text"": ""{ListOfQusetions[3]}"", }}, {{ ""type"": ""Input.Text"", ""id"": ""DisplayedErrorMessage"", ""placeholder"": "" * required"", }}, {{ ""type"": ""TextBlock"", ""text"": ""{ListOfQusetions[4]}"", }}, {{ ""type"": ""Input.Text"", ""id"": ""NosOfUserImpacted"", ""placeholder"": "" * required"", }}, {{ ""type"": ""TextBlock"", ""text"": ""{ListOfQusetions[5]}"", }}, {{ ""type"": ""Input.Text"", ""id"": ""AdditionalInfo"", ""placeholder"": ""optional"", }}, ] }} ] }} ], ""actions"": [ {{ ""type"": ""Action.Submit"", ""title"": ""Submit"", ""Id"": ""submit"" }}, ] }}") }); await context.PostAsync(replyActivity); context.Wait(ReadDataFromAdaptiveCard); } catch (Exception e) { ExceptionLog.LogFile(e); } } }