private void ShowOptions(IDialogContext context) { var descriptions = new List <string>() { "Buyer", "Seller", "Cancel" }; var choices = new Dictionary <string, IReadOnlyList <string> >() { { "buyers", new List <string> { "Buyers", "Buyer", "only buyer", "buyer" } }, { "sellers", new List <string> { "Sellers", "Seller", "only celler", "seller" } }, { "cancel", new List <string> { "cancel", "don't want it", "Cancel", "None", "None of them", "No" } } }; var promptOptions = new PromptOptionsWithSynonyms <string> ( "Please select one of the Option", choices: choices, descriptions: descriptions, speak: SsmlWrapper.Wrap("Would you like to have more information about Buyer or Seller") ); //PromptStyle style = PromptStyle.Keyboard; // PromptDialog.Choice(context, this.OnOptionSelected, new List<string>() { BuyerOption, SellerOption,CancelOption }, "Would you like to have more information about Buyer or Seller?", "Not a valid option", 3); PromptDialog.Choice(context, this.OnOptionSelected, promptOptions); }
public static string CombineAudioAndTextForSSML(Uri audioStream, string text) { StringBuilder sb = new StringBuilder(); const string ssmlPrefix = @"<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' " + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + "xsi:schemaLocation='http://www.w3.org/2001/10/synthesis " + "http://www.w3.org/TR/speech-synthesis/synthesis.xsd' " + "xml:lang='en-us'>"; const string ssmlSuffix = "</speak>"; sb.Append(ssmlPrefix); sb.Append($"<audio src='{audioStream.AbsoluteUri}'/>"); sb.Append(GetInnerSsmlContents(SsmlWrapper.Wrap(text))); sb.Append(ssmlSuffix); return(sb.ToString()); }
private static IMessageActivity CreateResponse ( IDialogContext context, IMessageActivity message, string displayText, string speakText, MessageType messageType, string audioToPlay = null, IList <string> optionsToAdd = null, string inputHint = InputHints.AcceptingInput ) { var activityToSend = context.MakeMessage(); if (displayText != null) { activityToSend.Text = displayText; } var ssml = (string)null; if (speakText != null) { var escapedSpeakText = speakText.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "'"); ssml = SsmlWrapper.Wrap(escapedSpeakText); if (audioToPlay != null && message.ChannelId != "cortana") { var assetPath = "http://" + System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + "/Assets/"; var uri = new Uri(assetPath + audioToPlay); ssml = CombineAudioAndTextForSSML(uri, ssml); } } activityToSend.Speak = ssml; activityToSend.InputHint = inputHint; var appEntities = new AppEntities { MessageType = messageType, TriviaAnswerOptions = optionsToAdd?.Count > 0 ? optionsToAdd : null }; if (optionsToAdd != null) { List <CardAction> cardButtons = new List <CardAction>(); bool numberOptions = optionsToAdd.Count > 2; for (int i = 0; i < optionsToAdd.Count; i++) { var display = numberOptions ? $"{(i + 1).ToString()}: {optionsToAdd[i]}" : optionsToAdd[i]; cardButtons.Add(new CardAction() { Value = optionsToAdd[i], Type = "postBack", Title = display }); } var plCard = new ThumbnailCard() { // Title = "Pick an answer", Buttons = cardButtons, }; activityToSend.Attachments.Add(plCard.ToAttachment()); } var entity = new Entity(); entity.SetAs <AppEntities>(appEntities); activityToSend.Entities.Add(entity); return(activityToSend); }