private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> argument) { var message = await argument; using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message)) { var service = scope.Resolve <IStandardCommandsAppService>(); var commands = service.HelpCommand(); var cardButtons = new List <CardAction>(); foreach (var item in commands.options.Select(x => new ButtonsHelp { Title = x.Title, Trigger = x.Trigger })) { cardButtons.Add(new CardAction { Value = item.Trigger, Type = Mapper.Map <TypeButton, string>(TypeButton.PostBack), Title = item.Title }); } var card = new HeroCard { Buttons = cardButtons }; var forwardMessage = context.MakeMessage(); forwardMessage.Attachments.Add(card?.ToAttachment()); context.Done(forwardMessage); } }
private static Attachment FillHeroCard(Holiday holiday) { var heroCard = new HeroCard { Title = holiday.Title, Text = holiday.Date.ToString("dd/MM/yyyy"), Images = new List <CardImage> { new CardImage("https://gothinkbig.co.uk/wp-content/uploads/2015/06/holiday.png") }, Subtitle = holiday.Description, Buttons = new List <CardAction> { new CardAction { Type = ActionTypes.PostBack, DisplayText = "Congratulations you have opted in for a flexible holiday", Title = "Opt In", Value = $"Opt In {holiday.Id}" } } }; return(heroCard.ToAttachment()); }
private Attachment CreateHeroCard() { var heroCard = new HeroCard(); heroCard.Title = "Planeta"; heroCard.Subtitle = "Universo"; heroCard.Images = new List <CardImage> { new CardImage("https://upload.wikimedia.org/wikipedia/commons/thumb/c/c2/Gnome-stock_person_bot.svg/1024px-Gnome-stock_person_bot.svg.png", "Bot", new CardAction(ActionTypes.OpenUrl, value: "htttps://www.google.com")) }; heroCard.Buttons = new List <CardAction> { new CardAction { Text = "Texto", Title = "Titulo", DisplayText = "Display", Type = ActionTypes.PostBack, Value = "Aqui vai um valor" } }; return(heroCard.ToAttachment()); }
private Attachment GetHeroCard() { var heroCard = new HeroCard() { Title = "Splatoon 2", Text = "Happy New Year. by Puck", Images = new List <CardImage>() { new CardImage("https://imgur.com/hwylGzp.jpg") }, Buttons = new List <CardAction>() { new CardAction() { Type = ActionTypes.OpenUrl, Title = "Open", Value = "https://imgur.com/hwylGzp.jpg" } } }; return(heroCard.ToAttachment()); }
public static IMessageActivity CreateGetLocationFromGoogleMapsReply() { var attachments = new List <Attachment>(); var reply = MessageFactory.Attachment(attachments); var cardAction = new CardAction(ActionTypes.OpenUrl, "Open Google Maps App", value: "https://maps.google.com"); var buttons = new List <CardAction> { cardAction }; var heroCard = new HeroCard { Title = "Facebook's removing the Send Location button", Text = "Maps→Longpress & drop pin→Share to Messenger→Randonauts→Back to chat", Tap = cardAction, Buttons = buttons, }; reply.Attachments.Add(heroCard.ToAttachment()); return(reply); }
private static async Task SendIntroCardAsync(ITurnContext turnContext, CancellationToken cancellationToken) { var card = new HeroCard(); card.Title = "Welcome to Bot Framework!"; card.Text = @"Welcome to Welcome Users bot sample! This Introduction card is a great way to introduce your Bot to the user and suggest some things to get them started. We use this opportunity to recommend a few next steps for learning more creating and deploying bots."; card.Images = new List <CardImage>() { new CardImage("https://aka.ms/bf-welcome-card-image") }; card.Buttons = new List <CardAction>() { new CardAction(ActionTypes.OpenUrl, "Get an overview", null, "Get an overview", "Get an overview", "https://docs.microsoft.com/en-us/azure/bot-service/?view=azure-bot-service-4.0"), new CardAction(ActionTypes.OpenUrl, "Ask a question", null, "Ask a question", "Ask a question", "https://stackoverflow.com/questions/tagged/botframework"), new CardAction(ActionTypes.OpenUrl, "Learn how to deploy", null, "Learn how to deploy", "Learn how to deploy", "https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-howto-deploy-azure?view=azure-bot-service-4.0"), }; var response = MessageFactory.Attachment(card.ToAttachment()); await turnContext.SendActivityAsync(response, cancellationToken); }
private static Activity CreateButtonConfirmation() { var reply = MessageFactory.Text("¿Te he sido de ayuda?"); var confirmacion = new HeroCard { Text="<b>¿Te he sido de ayuda?</b>", Buttons = new List<CardAction>() { new CardAction(){Title = "Si", Value= "1", Type=ActionTypes.PostBack}, new CardAction(){Title = "No", Value= "0", Type=ActionTypes.PostBack} } }; var optionAttachments = new List<Attachment>() { confirmacion.ToAttachment() }; var reply2 = MessageFactory.Attachment(optionAttachments); reply.AttachmentLayout = AttachmentLayoutTypes.Carousel; return reply2 as Activity; }
public static Attachment BuildAction() { var herocard = new HeroCard() { Buttons = new List <CardAction>() { new CardAction() { Title = "Previous", Value = "Previous", Type = ActionTypes.ImBack }, new CardAction() { Title = "Next", Value = "Next", Type = ActionTypes.ImBack }, new CardAction() { Title = "Exit", Value = "Exit", Type = ActionTypes.ImBack } } }; return(herocard.ToAttachment()); }
private static async Task SendIntroCardAsync(ITurnContext turnContext, CancellationToken cancellationToken) { var card = new HeroCard(); card.Title = "Welcome to Bot Framework!"; card.Text = @"Selct one of the below menu to proceed"; card.Images = new List <CardImage>() { new CardImage("https://aka.ms/bf-welcome-card-image") }; card.Buttons = new List <CardAction>() { new CardAction(ActionTypes.ImBack, "Active Directory Search", null, "Active Directory Search", "Active Directory Search", "ActiveDirectory Help"), new CardAction(ActionTypes.ImBack, "ServiceNow", null, "ServiceNow", "ServiceNow", "ServiceNow"), new CardAction(ActionTypes.ImBack, "Management Tools", null, "Management Tools", "Management Tools", "Management Tools"), new CardAction(ActionTypes.ImBack, "Search Analytics", null, "Search Analytics", "Search Analytics", "Search Analytics"), new CardAction(ActionTypes.ImBack, "Sharepoint Search", null, "Sharepoint Search", "Sharepoint Search", "Sharepoint Search"), new CardAction(ActionTypes.ImBack, "Comment/Feedback", null, "Comment/Feedback", "Comment/Feedback", "Feedback"), }; var response = MessageFactory.Attachment(card.ToAttachment()); await turnContext.SendActivityAsync(response, cancellationToken); }
private async Task BeginMenu(IDialogContext context) { const string imageUrl = "https://dev.botframework.com/Client/Images/ChatBot-BotFramework.png"; const string learnMoreUrl = "https://dev.botframework.com/"; var reply = ((Activity)context.Activity).CreateReply(); var card = new HeroCard("Make a choice!") { Buttons = new List <CardAction> { new CardAction(ActionTypes.OpenUrl, "Learn More", value: learnMoreUrl), new CardAction(ActionTypes.PostBack, "Tell a Joke", value: "joke"), new CardAction(ActionTypes.PostBack, "Play Trivia", value: "trivia") }, Images = new List <CardImage> { new CardImage(imageUrl) } }; reply.Attachments.Add(card.ToAttachment()); await context.PostAsync(reply); }
private async Task ResumeAfterWorkClarification(IDialogContext context, IAwaitable <string> result) { var company = await result; if (company.ToLowerInvariant().Equals("infosupport")) { var reply = context.MakeMessage(); var heroCard = new HeroCard() { Title = "InfoSupport", Subtitle = "InfoSupport is an IT-company based in Veenendaal, The Netherlands. We specialize in building, hosting and maintaining custom software solutions.", Images = new List <CardImage> { new CardImage(url: "https://innovationprojects.infosupport.com/wp-content/uploads/2015/12/Info-Support-30cm-300DPI-PNG.png") }, Buttons = new List <CardAction> { new CardAction() { Value = "https://www.infosupport.com/", Type = "openUrl", Title = "Visit website" } } }; reply.Attachments = new List <Attachment> { heroCard.ToAttachment() }; await context.PostAsync(reply); await context.PostAsync($"I've been told you're a *manager*, but you prefer yourself to be called a *Code Monkey*, correct?"); } await RestartAsync(context); }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result) { var activity = await result as Activity; // calculate something for us to return //int length = (activity.Text ?? string.Empty).Length; // return our reply to the user //await context.PostAsync($"You sent {activity.Text} which was {length} characters"); var message = activity.CreateReply(); if (activity.Text.Equals("animationcard", StringComparison.InvariantCultureIgnoreCase)) { var animationCard = new AnimationCard(); animationCard.Title = "Título do Animation Card"; animationCard.Subtitle = "Subtítulo do Animation Card"; animationCard.Autostart = true; animationCard.Autoloop = false; animationCard.Media = new List <MediaUrl> { new MediaUrl("https://78.media.tumblr.com/8b4fbc136beb037c31a2f95a0fb71b51/tumblr_otho3igenw1toamj8o1_400.gif") }; message.Attachments.Add(animationCard.ToAttachment()); } else if (activity.Text.Equals("herocard", StringComparison.InvariantCultureIgnoreCase)) { var heroCard = new HeroCard(); heroCard.Title = "Título"; heroCard.Text = "Esse é o texto do meu HeroCard. Bla bla bla bla bla bla."; message.Attachments.Add(heroCard.ToAttachment()); } await context.PostAsync(message); context.Wait(MessageReceivedAsync); }
public async Task StartAsync(IDialogContext context) { var helper = new Helpers.SomeHelpers(); if (_textAnalyticsDocumentSentimentModel?.Score != null) { var txtAnalyticsResult = $@"Score de sentiment : {_textAnalyticsDocumentSentimentModel?.Score.Value:0.0} KeyWords : { _textAnalyticsDocumentSentimentModel.KeyWords } Langage : {_textAnalyticsDocumentSentimentModel.DetectedLanguage}"; var heroCard = new HeroCard { Title = "", Subtitle = "", Text = "", Images = new List <CardImage> { new CardImage(helper.GetImgByScore(_textAnalyticsDocumentSentimentModel.Score)), }, Buttons = new List <CardAction>() }; heroCard.Text = txtAnalyticsResult; var message = context.MakeMessage(); message.Attachments.Add(heroCard.ToAttachment()); await context.PostAsync(_qnaAnswerModel.Answer); if (_textAnalyticsDocumentSentimentModel.Score != null) { await context.PostAsync(message); } } context.Done <object>(null); }
//Creates the herocard for responses with more than one answer protected IMessageActivity CreateHeroCard(IDialogContext context, QuestionResponse.QnaAnswer[] options) { var reply = context.MakeMessage(); reply.Attachments = new List <Attachment>(); List <CardAction> cardButtons = new List <CardAction>(); foreach (var ans in options) { CardAction cardAction = new CardAction() { Type = "postBack", Title = ans.Questions[0], Value = ans.Questions[0] }; cardButtons.Add(cardAction); } CardAction none = new CardAction() { Type = "postBack", Title = Resource.noneOfTheAboveOption, Value = Resource.noneOfTheAboveOption }; cardButtons.Add(none); HeroCard card = new HeroCard() { Title = "Did you mean?", Buttons = cardButtons }; Attachment atch = card.ToAttachment(); reply.Attachments.Add(atch); return(reply); }
public static Attachment GetGeneral(string location, string vehical, string vehicalClass) { WebClient webClient = new WebClient(); webClient.Headers.Set("content-type", "application/json"); Dictionary <string, string> myvalues = new Dictionary <string, string>(); myvalues.Add("location", location); myvalues.Add("class", vehicalClass); DataContractJsonSerializer myserializer = new DataContractJsonSerializer(typeof(Dictionary <string, string>)); string myJsonString = (new JavaScriptSerializer()).Serialize(myvalues); string result2 = webClient.UploadString("http://localhost:8081/api2/", "POST", myJsonString); dynamic parsedArrayTwo = JsonConvert.DeserializeObject(result2); //JObject jo = JObject.Parse(result2); //JArray ab = JArray.Parse(parsedArrayTwo); var text = parsedArrayTwo[0].text; // var title = parsedArrayTwo[0].ttitle; // var subtitle = parsedArrayTwo[0].subtitle; var link = parsedArrayTwo[0].link; var button = parsedArrayTwo[0].button; var General = new HeroCard { Title = "General class", Subtitle = $"", Text = $"{text}", Images = new List <CardImage> { new CardImage($"{link}") }, Buttons = new List <CardAction> { new CardAction(ActionTypes.OpenUrl, "Book Ticket", value: $"{ button} ") } }; return(General.ToAttachment()); }
protected override Task <MessagingExtensionResponse> OnTeamsMessagingExtensionQueryAsync(ITurnContext <IInvokeActivity> turnContext, MessagingExtensionQuery query, CancellationToken cancellationToken) { //Note: The Teams manifest.json for this sample also includes a Search Query, in order to enable installing from App Studio. switch (query.CommandId) { // These commandIds are defined in the Teams App Manifest. case "searchQuery": var card = new HeroCard { Title = "This is a Link Unfurling Sample", Subtitle = "It will unfurl links from *.BotFramework.com", Text = "This sample demonstrates how to handle link unfurling in Teams. Please review the readme for more information.", }; return(Task.FromResult(new MessagingExtensionResponse { ComposeExtension = new MessagingExtensionResult { AttachmentLayout = "list", Type = "result", Attachments = new List <MessagingExtensionAttachment> { new MessagingExtensionAttachment { Content = card, ContentType = HeroCard.ContentType, Preview = card.ToAttachment(), }, }, }, })); default: throw new NotImplementedException($"Invalid CommandId: {query.CommandId}"); } }
/// <summary> /// Метод, определяющий роль пользователя по площадке "Электронный магазин ЗМО" /// </summary> /// <param name="context"></param> /// <param name="activity"></param> /// <param name="checkParametrs"></param> public static void RoleCardRTS(IDialogContext context, Activity activity, string checkParametrs) { var replyToConversation = activity.CreateReply(); replyToConversation.Attachments = new List <Attachment>(); var cardButton = new List <CardAction>(); var card1 = new CardAction() { Value = "Заказчик", Title = "Заказчик" }; var card2 = new CardAction() { Value = "Поставщик", Title = "Поставщик" }; cardButton.Add(card1); cardButton.Add(card2); var hero = new HeroCard() { Buttons = cardButton, Text = checkParametrs }; var attach = hero.ToAttachment(); if (attach == null) { throw new ArgumentNullException(nameof(attach)); } replyToConversation.Attachments.Add(attach); context.PostAsync(replyToConversation); }
public async Task List(IDialogContext context, LuisResult result) { var cucas = await _cucaService.ListNext(); Activity replyToConversation = ((Activity)context.Activity).CreateReply($"Os próximos \"dia da cuca\" são... {EmojiType.Smiley}"); replyToConversation.AttachmentLayout = AttachmentLayoutTypes.Carousel; replyToConversation.Attachments = new List <Attachment>(); foreach (var cuca in cucas) { var cardButtons = new List <CardAction> { new CardAction() { Value = $"participar da cuca {cuca.Id}", Type = ActionTypes.PostBack, Title = "Participar" } }; decimal valueByParticipant = cuca.Participants.Any() ? cuca.Value / cuca.Participants.Count : cuca.Value; var card = new HeroCard() { Title = $"Cuca nº {cuca.Id} - {cuca.Date.ToShortDateString()}", Subtitle = $"Total: R$ {cuca.Value} / R$ {valueByParticipant} por pessoa / {cuca.Participants.Count} participantes", Buttons = cardButtons, }; replyToConversation.Attachments.Add(card.ToAttachment()); } await context.PostAsync(replyToConversation); context.Wait(MessageReceived); }
private Activity Opciones() { var ListaPeliculas = DatabaseServices.GetPiliculas(); var listAttachments = new List <Attachment>(); foreach (var item in ListaPeliculas) { var card = new HeroCard() { Title = item.nombre, Subtitle = $"Precio: {item.precio}", Images = new List <CardImage>() { new CardImage(item.imagen) }, Buttons = new List <CardAction>() { new CardAction() { Title = "Comprar", Value = item.nombre, Type = ActionTypes.ImBack }, new CardAction() { Title = "Ver información", Value = item.informacion, Type = ActionTypes.OpenUrl } } }; listAttachments.Add(card.ToAttachment()); } var reply = MessageFactory.Attachment(listAttachments); reply.AttachmentLayout = AttachmentLayoutTypes.Carousel; return(reply as Activity); }
public static Activity GetCurrencyExchangeInfo(Activity message) { WebRequest request = WebRequest.Create(@"http://api.fixer.io/latest?base=NZD&symbols=AUD,USD,GBP,RUB"); var response = (HttpWebResponse)request.GetResponse(); StreamReader streamReader = new StreamReader(response.GetResponseStream()); string responceData = streamReader.ReadToEnd(); streamReader.Close(); response.Close(); RatesRootObject r = JsonConvert.DeserializeObject <RatesRootObject>(responceData); DateTime rateDate; if (!DateTime.TryParse(r.date, out rateDate)) { rateDate = DateTime.Today; } Activity result = message.CreateReply(); result.Recipient = message.From; result.Type = "message"; result.Attachments = new List <Attachment>(); HeroCard plCard = new HeroCard() { Title = "Foreign currency exchange rates", Subtitle = rateDate.ToString("d"), Text = $"1 NZD = {r.rates.USD} USD\n {r.rates.AUD} AUD\n {r.rates.GBP} GBP\n {r.rates.RUB} RUB" }; Attachment plAttachment = plCard.ToAttachment(); result.Attachments.Add(plAttachment); return(result); }
public async Task StartAsync(IDialogContext context) { var reply = context.MakeMessage(); HeroCard card = new HeroCard(); var query = @"query { viewer{ name repositories(first: 100) { nodes { name } } } }"; var client = new GraphQLClient(); string data = client.Query(query, null); AllRepository obj = Newtonsoft.Json.JsonConvert.DeserializeObject <AllRepository>(data); List <CardAction> button = new List <CardAction>(); CardAction cardAction; foreach (Node1 rep in obj.data.viewer.repositories.nodes) { cardAction = new CardAction(ActionTypes.ImBack, rep.name, value: rep.name); button.Add(cardAction); } card.Title = "Below are your repositories"; card.Subtitle = "To get detail click on it"; card.Buttons = button; Attachment attachment = card.ToAttachment(); reply.Attachments.Add(attachment); await context.PostAsync(reply); context.Wait(RepositoryDetailData); }
public static void SatisfyingAnswer(IDialogContext context, Activity activity) { var replyToConversation = activity.CreateReply(); replyToConversation.Attachments = new List <Attachment>(); var cardButton = new List <CardAction>(); var card1 = new CardAction() { Value = "Да", Title = "Да" }; var card2 = new CardAction() { Value = "Нет", Title = "Нет" }; cardButton.Add(card1); cardButton.Add(card2); var hero = new HeroCard() { Buttons = cardButton, Text = "Удовлетворил ли Вас ответ?" }; var attach = hero.ToAttachment(); if (attach == null) { throw new ArgumentNullException(nameof(attach)); } replyToConversation.Attachments.Add(attach); context.PostAsync(replyToConversation); }
public async Task GetPeople(IDialogContext context, LuisResult result) { try { var replyMessage = context.MakeMessage(); replyMessage.Text = "This is our most popular tent in this capacity range -"; List <CardImage> cardImages = new List <CardImage>(); cardImages.Add(new CardImage(url: "https://botdemostorage.blob.core.windows.net/botcontainer/Tent.PNG")); HeroCard heroCard = new HeroCard() { Images = cardImages, Buttons = new List <CardAction>() { new CardAction() { Title = "REI Kingdom 8 Tent", Type = ActionTypes.OpenUrl, Value = $"https://www.rei.com/product/894017/rei-kingdom-8-tent" } } }; replyMessage.Attachments.Add(heroCard.ToAttachment()); await context.PostAsync(replyMessage); await context.PostAsync("Would you like to go with this tent or look at more options?"); context.Wait(this.MessageReceived); } catch (Exception) { await context.PostAsync("Sorry, I did not understand.Type 'help' if you need assistance."); } }
public async Task ContinueAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { var message = await result; i = i + 1; var _lastQuestion = Questions.ElementAt(i).Content; var _expr = mathEngine.Calc(_lastQuestion); var _result = _expr; if (_result.ToLower() == message.Text.ToLower()) { await context.PostAsync($"Đúng"); } else { await context.PostAsync($"Sai"); } await context.PostAsync($"Câu hỏi {i} tiếp theo: "); if (i < n) { var question = Questions.ElementAt(i); var resultMessage = context.MakeMessage(); resultMessage.AttachmentLayout = AttachmentLayoutTypes.Carousel; resultMessage.Attachments = new List <Attachment>(); HeroCard heroCard = CreateCard(question); resultMessage.Attachments.Add(heroCard.ToAttachment()); await context.PostAsync(resultMessage); } else { IsContinue = false; } }
protected async Task ShowSummaryCardAsync(IDialogContext context) { int subsno; context.ConversationData.TryGetValue("SubsNumber", out subsno); var reply = context.MakeMessage(); var collection = _database.GetCollection <BsonDocument>("images"); var filter = Builders <BsonDocument> .Filter.Eq("Anon_Subsno", subsno) & Builders <BsonDocument> .Filter.Eq("Name", "SUMMARY"); //await context.PostAsync($"Querying collection [{subsno}]"); using (var cursor = await collection.FindAsync(filter)) { while (await cursor.MoveNextAsync()) { var batch = cursor.Current; foreach (var document in batch) { var image = document.GetElement("Image").Value; //await context.PostAsync($"Read name[{name}] and image[{image}]"); var Card = new HeroCard { Title = "Analysis Summary", Text = "Here is a high level summary of my analysis of the way you use your phone. If you'd like to see more detail, click on Show Analysis in the plan list.", Images = new List <CardImage> { new CardImage((string)image) }, }; reply.Attachments.Add(Card.ToAttachment()); } } } await context.PostAsync(reply); }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { if (activity.Type == ActivityTypes.Message) { ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); var heroCard = new HeroCard { Title = "Sample Hero Card", Subtitle = "Smart Cards — Learning Bot Framework", Text = "The Hero card is a multipurpose card; it primarily hosts a single large image, a button, and a tap action.", Images = new List <CardImage> { new CardImage("https://sec.ch9.ms/ch9/7ff5/e07cfef0-aa3b-40bb-9baa-7c9ef8ff7ff5/buildreactionbotframework_960.jpg") }, Buttons = new List <CardAction> { new CardAction(ActionTypes.ImBack, "Get Started", value: "Ritesh") } }; Activity reply = activity.CreateReply(); Attachment attach = new Attachment(); attach = heroCard.ToAttachment(); reply.Attachments = new List <Attachment> { attach }; await connector.Conversations.ReplyToActivityAsync(reply); } else { HandleSystemMessage(activity); } var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result) { var activity = await result as Activity; var image = "https://assets.windowsphone.com/5cc1895e-5148-4700-856f-eb49d4bf28dc/Smarter_448x252_InvariantCulture_Default.png["; var reply = ((Activity)context.Activity).CreateReply(); var card = new HeroCard { Title = "DOF FAQ Bot", Text = $"Welcome to DoF, {activity.Text}!" }; card.Images.Add(new CardImage(image)); reply.Attachments.Add(card.ToAttachment()); var replyCheckMode = ((Activity)context.Activity).CreateReply(); var cardModes = new HeroCard { Title = "Choose your search mode", Text = $"Please select a method to search for content" }; cardModes.Buttons = new List <CardAction> { new CardAction(ActionTypes.ImBack, "Select categories to search FAQ", value: "category"), new CardAction(ActionTypes.ImBack, "Ask a question now", value: "questions"), }; replyCheckMode.Attachments.Add(cardModes.ToAttachment()); await context.PostAsync(reply); await context.PostAsync(replyCheckMode); context.Done <object>(null); }
private static async Task <DialogTurnResult> MenuStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken = default(CancellationToken)) { // Present the user with a set of "suggested actions". //List<string> menu = new List<string> { "Reserve Table", "Wake Up" }; //await stepContext.Context.SendActivityAsync(MessageFactory.SuggestedActions(menu, "How can I help you?"), cancellationToken: cancellationToken); //return Dialog.EndOfTurn; var reply = stepContext.Context.Activity.CreateReply(); // Create a HeroCard with options for the user to choose to interact with the bot. var card = new HeroCard { Text = "Welcome to the Demo bot!", Subtitle = "Select an option below to get started:", Buttons = new List <CardAction>() { new CardAction(ActionTypes.PostBack, title: "1. Cards Example", value: "1"), new CardAction(ActionTypes.PostBack, title: "2. Conversation & User State Example", value: "2"), new CardAction(ActionTypes.PostBack, title: "3. Waterfall Dialog Example", value: "3"), new CardAction(ActionTypes.PostBack, title: "4. (LUIS) Language Understanding Example", value: "4"), new CardAction(ActionTypes.PostBack, title: "4. Cognitive Services Example", value: "5"), }, }; // Add the card to our reply. reply.Attachments = new List <Attachment>() { card.ToAttachment() }; await stepContext.Context.SendActivityAsync(reply, cancellationToken); return(Dialog.EndOfTurn); }
private async Task OptionSelected(IDialogContext context, IAwaitable <string> result) { try { string optionSelected = await result; switch (optionSelected) { case "Confirm": context.Call(new Node42(), this.ResumeAfterOptionDialog); break; case "Reject": var Card = new HeroCard { Title = "That's OK.", Text = "If you have changed your mind then I will save this order so you can access it later, or just start again next time you want to chat.", Images = new List <CardImage> { new CardImage("http://www.madcalm.com/wp-content/uploads/2018/06/MADCALM-PROCESSING.png") }, }; var msg = context.MakeMessage(); msg.Attachments.Add(Card.ToAttachment()); await context.PostAsync(msg); context.Done(2); break; } } catch (TooManyAttemptsException ex) { await context.PostAsync($"Ooops! Too many attemps :(. But don't worry, I'm handling that exception and you can try again!"); context.Done(0); } }
private static Attachment GetHeroCard() { var heroCard = new HeroCard { // title of the card Title = "Suthahar Jegatheesan", //subtitle of the card Subtitle = "Microsoft certified solution developer", // navigate to page , while tab on card Tap = new CardAction(ActionTypes.OpenUrl, "Learn More", value: "http://www.devenvexe.com"), //Detail Text Text = "Suthahar J is a Technical Lead and C# Corner MVP. He has extensive 10+ years of experience working on different technologies, mostly in Microsoft space. His focus areas are Xamarin Cross Mobile Development ,UWP, SharePoint, Azure,Windows Mobile , Web , AI and Architecture. He writes about technology at his popular blog http://devenvexe.com", // list of Large Image Images = new List <CardImage> { new CardImage("http://csharpcorner.mindcrackerinc.netdna-cdn.com/UploadFile/AuthorImage/jssuthahar20170821011237.jpg") }, // list of buttons Buttons = new List <CardAction> { new CardAction(ActionTypes.OpenUrl, "Learn More", value: "http://www.devenvexe.com"), new CardAction(ActionTypes.OpenUrl, "C# Corner", value: "http://www.c-sharpcorner.com/members/suthahar-j"), new CardAction(ActionTypes.OpenUrl, "MSDN", value: "https://social.msdn.microsoft.com/profile/j%20suthahar/") } }; return(heroCard.ToAttachment()); }