microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.5k stars 2.44k forks source link

InputHint #4429

Closed saikatbh94 closed 6 years ago

saikatbh94 commented 6 years ago

Hi, I am building a bot where whenever the user is giving any input through speech, the bot will automatically open the microphone to go to the listening mode. Basically, I have to give expecting inputhint i know that. But i don't know whether it applies to all the dialog files as well when i am going from messagescontroller to some other files. Please help me MessagesController.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Connector;
using System.Web.Http.Description;
using System.Speech;
using Microsoft.Bot.Builder.History;
using Autofac;
using System.IO;

namespace POSBot
{
    [BotAuthentication]
    public class MessagesController : ApiController
    {
        /// <summary>
        /// POST: api/Messages
        /// receive a message from a user and send replies
        /// </summary>
        /// <param name="activity"></param>
        [ResponseType(typeof(void))]
        public virtual async Task<HttpResponseMessage> Post([FromBody] Activity activity)
        {
            // check if activity is of type message
            if (activity.GetActivityType() == ActivityTypes.Message)
            {
                var connector = new ConnectorClient(new Uri(activity.ServiceUrl));
                Activity isTypingReply = activity.CreateReply();
                isTypingReply.Type = ActivityTypes.Typing;
                await connector.Conversations.ReplyToActivityAsync(isTypingReply);
                await Conversation.SendAsync(activity, () => new RootDialog());
            }
            else
            {
                await HandleSystemMessageAsync(activity);
            }
            return new HttpResponseMessage(System.Net.HttpStatusCode.Accepted);
        }

        private async Task<Activity> HandleSystemMessageAsync(Activity message)
        {
            if (message.Type == ActivityTypes.DeleteUserData)
            {
                // Implement user deletion here
                // If we handle user deletion, return a real message
            }
            else if (message.Type == ActivityTypes.ConversationUpdate)
            {
                // Handle conversation state changes, like members being added and removed
                // Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info
                // Not available in all channels
                if (message.MembersAdded.Any(o => o.Id == message.Recipient.Id))
                {
                    ConnectorClient client = new ConnectorClient(new Uri(message.ServiceUrl));
                    var reply = message.CreateReply();
                    reply.Text = "Hi, are you having a POS or EID issue.";
                    reply.Speak = "Hi, are you having a P O S or E I D issue.";
                    reply.InputHint = InputHints.ExpectingInput;
                    await client.Conversations.ReplyToActivityAsync(reply);
                }
            }
            else if (message.Type == ActivityTypes.ContactRelationUpdate)
            {
                // Handle add/remove from contact lists
                // Activity.From + Activity.Action represent what happened
            }
            else if (message.Type == ActivityTypes.Typing)
            {
                // Handle knowing tha the user is typing
            }
            else if (message.Type == ActivityTypes.Ping)
            {
            }
            return null;
        }
    }
}

RootDialog.cs

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Connector;

namespace POSBot
{
    public class RootDialog : IDialog<object>
    {
        public Task StartAsync(IDialogContext context)
        {
            context.Wait(MessageReceivedAsync);
            return Task.CompletedTask;
        }

        public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
        {
            var activity = await result as Activity;
            await context.Forward(new BasicLuisDialog(), ResumeAfterBasicLuisDialog, activity, CancellationToken.None);
        }

        public async Task ResumeAfterBasicLuisDialog(IDialogContext context, IAwaitable<object> result)
        {
            context.Wait(MessageReceivedAsync);
        }
    }
}

BasicLuisDialog.cs

using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Luis;
using Microsoft.Bot.Builder.Luis.Models;
using Microsoft.Bot.Connector;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Threading.Tasks;

namespace POSBot
{
    [Serializable]
    public class BasicLuisDialog : LuisDialog<object>
    {
        public int noneattempt = 0;
        public int issueattempt = 0;
        public int posattempt = 0;
        public int eidattempt = 0;
        public BasicLuisDialog() : base(new LuisService(new LuisModelAttribute(
            ConfigurationManager.AppSettings["LuisAppId"],
            ConfigurationManager.AppSettings["LuisAPIKey"],
            domain: ConfigurationManager.AppSettings["LuisAPIHostName"])))
        {
        }
        public List<string> none = new List<string>
        {
            "Sorry, I cannot understand your query",
            "Sorry, I am unbale to handle that",
            "Sorry, I am not trained for that",
            "Sorry, I did not get you",
            "Sorry, I did not follow"
        };
        public List<string> issue = new List<string> { "POS Open Fail", "Merge EID" };
        public string myissue;
        public string theissue;
        [LuisIntent("None")]
        public async Task NoneIntent(IDialogContext context, LuisResult result)
        {
            noneattempt++;
            string mynone = new GlobalHandler().GetRandomString(none);
            if (noneattempt >= 2)
            {
                await context.SayAsync(text: mynone+"...", speak: mynone);
                await new TransferToAPerson().StartAsync(context);
            }
            else
            {
                await context.SayAsync(text: mynone+"...", speak: mynone);
                context.Wait(this.MessageReceived);
            }
        }
        [LuisIntent("Issue")]
        public async Task IssueIntent(IDialogContext context, LuisResult result)
        {
            string prompt = "Okay, tell me what is your issue?";
            string retryprompt = "Please try again";
            var promptOptions = new PromptOptions<string>(prompt: prompt, options: issue, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler());
            PromptDialog.Choice(context, Issue, promptOptions);
        }
        public async Task Issue(IDialogContext context, IAwaitable<string> result)
        {
            this.myissue = await result;
            if (myissue.ToLower().Contains("pos") || myissue.ToLower().Contains("open") || myissue.ToLower().Contains("fail"))
            {
                await new POSOpenFail().StartAsync(context);
            }
            else if (myissue.ToLower().Contains("eid") || myissue.ToLower().Contains("merge") || myissue.ToLower().Contains("id"))
            {
                await new EIDMerge().StartAsync(context);
            }
        }
        [LuisIntent("ReportOpenFailError")]
        public async Task ReportOpenFailErrorIntent(IDialogContext context, LuisResult result)
        {
            List<string> choices = new List<string> { "Yes", "No" };
            string prompt = "Are you calling for POS Open Fail?";
            string retryprompt = "Please try again";
            string promptspeak = "Are you calling for p o s open fail?";
            var promptOptions = new PromptOptions<string>(prompt: prompt, options: choices, retry: retryprompt, speak: promptspeak, retrySpeak: retryprompt, promptStyler: new PromptStyler());
            PromptDialog.Choice(context, ConfirmPOS, promptOptions);
        }
        public async Task ConfirmPOS(IDialogContext context, IAwaitable<string> result)
        {
            string confirm = await result;
            if (confirm.ToLower() == "yes")
            {
                await new POSOpenFail().StartAsync(context);
            }
            else
            {
                posattempt++;
                if (posattempt == 2)
                {
                    await new TransferToAPerson().StartAsync(context);
                }
                else
                {
                    await context.SayAsync(text: "Let's try again", speak: "Let's try again");
                    await POS(context);
                }
            }
        }
        public async Task POS(IDialogContext context)
        {
            List<string> choices = new List<string> { "Yes", "No" };
            string prompt = "Are you calling for POS Open Fail?";
            string retryprompt = "Please try again";
            string promptspeak = "Are you calling for p o s open fail?";
            var promptOptions = new PromptOptions<string>(prompt: prompt, options: choices, retry: retryprompt, speak: promptspeak, retrySpeak: retryprompt, promptStyler: new PromptStyler());
            PromptDialog.Choice(context, ConfirmPOS, promptOptions);
        }
        [LuisIntent("EIDMerge")]
        public async Task EIDMergeIntent(IDialogContext context, LuisResult result)
        {
            List<string> choices = new List<string> { "Yes", "No" };
            string prompt = "Are you calling for Merge EID";
            string retryprompt = "Please try again";
            string promptspeak = "Are you calling for merge e i d?";
            var promptOptions = new PromptOptions<string>(prompt: prompt, options: choices, retry: retryprompt, speak: promptspeak, retrySpeak: retryprompt, promptStyler: new PromptStyler());
            PromptDialog.Choice(context, ConfirmEID, promptOptions);
        }
        public async Task ConfirmEID(IDialogContext context, IAwaitable<string> result)
        {
            string confirm = await result;
            if (confirm.ToLower() == "yes")
            {
                await new EIDMerge().StartAsync(context);
            }
            else
            {
                eidattempt++;
                if (eidattempt == 2)
                {
                    await new TransferToAPerson().StartAsync(context);
                }
                else
                {
                    await context.SayAsync(text: "Let's try again", speak: "Let's try again");
                    await EID(context);
                }
            }
        }
        public async Task EID(IDialogContext context)
        {
            List<string> choices = new List<string> { "Yes", "No" };
            string prompt = "Are you calling for Merge EID";
            string retryprompt = "Please try again";
            string promptspeak = "Are you calling for merge e i d?";
            var promptOptions = new PromptOptions<string>(prompt: prompt, options: choices, retry: retryprompt, speak: promptspeak, retrySpeak: retryprompt, promptStyler: new PromptStyler());
            PromptDialog.Choice(context, ConfirmEID, promptOptions);
        }
    }
}

EIDMerge.cs

using Microsoft.Bot.Builder.Dialogs; using System; using System.Collections.Generic; using System.Threading.Tasks;

namespace POSBot { [Serializable] public class EIDMerge : BasicLuisDialog, IDialog { static GlobalHandler.EID eid = new GlobalHandler.EID(); List assistance = eid.assistance; List level = eid.level; List support = eid.support; List merge = eid.merge; public async Task StartAsync(IDialogContext context) { List choices = new List { "Yes", "No" }; string prompt = new GlobalHandler().GetRandomString(merge); string retryprompt = "Please try again"; var promptOptions = new PromptOptions(prompt: prompt, options: choices, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler()); PromptDialog.Choice(context, MergeConfirm, promptOptions); } public async Task MergeConfirm(IDialogContext context, IAwaitable result) { string confirm = await result; if (confirm.ToLower() == "yes") { await new CreateLMSTicket().StartAsync(context); } else { await context.SayAsync(text: "A Person Merge needs to be completed.", speak: "A Person Merge needs to be completed."); string help = "Do you need assistance with the Person Merge Process, information about what Person Merge is, or training and instructions for Global Account Manager?"; await context.SayAsync(text: help, speak: help); string prompt = "Please select one option"; string retryprompt = "Please try again"; var promptOptions = new PromptOptions(prompt: prompt, options: assistance, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler()); PromptDialog.Choice(context, Assistance, promptOptions); } } public async Task Assistance(IDialogContext context, IAwaitable result) { string assistance = await result; if (assistance.ToLower().Contains("person merge assistance")) { string prompt = "Is the Person Merge needed for a store level employee or staff level employee?"; string retryprompt = "Please try again"; var promptOptions = new PromptOptions(prompt: prompt, options: level, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler()); PromptDialog.Choice(context, Level, promptOptions); } else if (assistance.ToLower().Contains("person merge information")) { await context.SayAsync(text: "A Person Merge is required whenever an employee who has training associated with a prior EID acquires a new EID.The Person Merge process transfers all learning transcripts to the new EID to ensure the employee's records include all past training. This allows employees to have one training transcript with their entire training history.", speak: "A Person Merge is required whenever an employee who has training associated with a prior E I D acquires a new E I D. The Person Merge process transfers all learning transcripts to the new E I D to ensure the employee's records include all past training. This allows employees to have one training transcript with their entire training history. A store was acquired by a new O/O and the new O/O created new e i ds for managers."); await context.SayAsync(text: "An employee may require a Person Merge in a number of situations, including the following:
• The employee has transferred to a new organization and a new EID was created for them
• The employee left the company and came back and new EID was created for them
• EIDs can be disabled manually when an employee leaves the company
• EIDs are disabled automatically after 6 months of inactivity
• The employee was promoted from crew trainer to manager
• A store was acquired by a new O/ O and the new O/ O created new EIDs for managers", speak: "An employee may require a Person Merge in a number of situations, including the following. The employee has transferred to a new organization and a new e i d was created for them. The employee left the company and came back and new e i d was created for them. E i ds can be disabled manually when an employee leaves the company. E i ds are disabled automatically after 6 months of inactivity. The employee was promoted from crew trainer to manager. A store was acquired by a new O/O and the new O/O created new EIDs for managers."); List choices = new List { "Yes", "No" }; string prompt = "Do you need assistance with a Person Merge now?"; string retryprompt = "Please try again"; var promptOptions = new PromptOptions(prompt: prompt, options: choices, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler()); PromptDialog.Choice(context, InfoResume, promptOptions); } else if (assistance.ToLower().Contains("global account manager")) { string gam = "For training, instructions, and additional information on Global Account Manager, please see the Global Account Manager Launch and Learn presentation on Access, or contact GAM Support at GlobalAMSupport@us.com"; await context.SayAsync(text: gam, speak: gam); await context.SayAsync(text: "Press this link to see the presentation: https://www.canva.com", speak: "Press this link to see the presentation"); await context.SayAsync(text: "Press this link to contact us: https://www.canva.com", speak: "Press this link to contact us"); var incidentNumber = "E" + new Random().Next(1000, 9999); await new CloseContact().Start(context, incidentNumber); } } public async Task InfoResume(IDialogContext context, IAwaitable result) { string confirm = await result;

        if (confirm.ToLower() == "yes")
        {
            await PersonAssist(context);
        }
        else
        {
            await context.SayAsync(text: "So you do not need assistance.", speak: "So you do not need assistance.");
            var incidentNumber = "E" + new Random().Next(1000, 9999);
            await new CloseContact().Start(context, incidentNumber);
        }
    }
    public async Task PersonAssist(IDialogContext context)
    {
        string prompt = "Is the Person Merge needed for a store level employee or staff level employee?";
        string retryprompt = "Please try again";
        var promptOptions = new PromptOptions<string>(prompt: prompt, options: level, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler());
        PromptDialog.Choice(context, Level, promptOptions);
    }
    public async Task Level(IDialogContext context, IAwaitable<string> result)
    {
        string level = await result;
        if (level.ToLower().Contains("staff"))
        {
            await context.SayAsync("Contact the Corporate help desk through service cafe or at 555-555-5555 to assist with the eid merge.", speak: "Contact the Corporate help desk through service cafe or at 555-555-5555 to assist with the e i d merge.");

            var incidentNumber = "E" + new Random().Next(1000, 9999);
            await new CloseContact().Start(context, incidentNumber);
        }
        else if (level.ToLower().Contains("store"))
        {
            await new CreateLMSTicket().StartAsync(context);
        }
    }
}

}

CreateLMSTicket.cs

using Microsoft.Bot.Builder.Dialogs; using Microsoft.Bot.Connector; using System; using System.Collections.Generic; using System.Diagnostics; using System.Text; using System.Threading; using System.Threading.Tasks;

namespace POSBot { [Serializable] public class CreateLMSTicket : BasicLuisDialog, IDialog { static GlobalHandler.LMS lms = new GlobalHandler.LMS(); string f = lms.firstname; string fr = lms.freceive; string l = lms.lastname; string lr = lms.lreceive; string ph = lms.phonenumber; string phr = lms.phreceive; string str = lms.storenumber; string strr = lms.strreceive; string petxt = lms.previouseidtext; string pespk = lms.previouseidspeak; string petxtr = lms.ptxtreceive; string pespkr = lms.pspkreceive; string netxt = lms.neweidtext; string nespk = lms.neweidspeak; string netxtr = lms.ntxtreceive; string nespkr = lms.nspkreceive; string pos = lms.position; string posr = lms.posreceive; string complete = lms.fcom; string pf = lms.pfirstname; string pl = lms.plastname; string pph = lms.pphone; string pstr = lms.pstore; string ppetxt = lms.ppetxt; string ppespk = lms.ppespk; string pnetxt = lms.pnetxt; string pnespk = lms.pnespk; string ppos = lms.ppos; List choices = new List { "Yes", "No" }; public List option = new List { "Redo the form fill up", "Change any field", "Cancel the operation" }; public List details = new List { "First Name", "Last Name", "Phone Number", "Store Number", "Previous EID", "New EID", "Position", "No change" }; public string FirstName; public string LastName; public string PhoneNumber; public string StoreNumber; public string Store; public string Previouseid; public string PreviousEID; public string Neweid; public string NewEID; public string Position; public async Task StartAsync(IDialogContext context) { await context.SayAsync(text: "A ticket needs to be created to send to LMS.", speak: "A ticket needs to be created to send to LMS."); await context.SayAsync(text: "Please provide all the required information on the screen.", speak: "Please provide all the required information on the screen."); string prompt = "Do you want to Proceed?"; string retryprompt = "Please try again"; var promptOptions = new PromptOptions(prompt: prompt, options: choices, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler()); PromptDialog.Choice(context, Submission, promptOptions); } public async Task Submission(IDialogContext context, IAwaitable result) { string choice = await result; if (choice.ToLower() == "yes") { await First(context); } else { await context.SayAsync(text: "You have cancelled the operation. You can again start a New conversation by asking me things like 'Error in POS Open', 'EID Merge', etc", speak: "You have cancelled the operation. You can again start a new conversation by asking me things like 'Error in P O S open', 'e i d merge', etc"); context.Wait(this.MessageReceived); } } public async Task First(IDialogContext context) { await context.SayAsync(text: f, speak: f); context.Wait(FirstNameReceived); } public async Task FirstNameReceived(IDialogContext context, IAwaitable activity) { var FN = await activity; this.FirstName = FN.Text; await context.SayAsync(text: fr + this.FirstName, speak: fr + this.FirstName); await Last(context); } public async Task Last(IDialogContext context) { await context.SayAsync(text: l, speak: l); context.Wait(LastNameReceived); } public async Task LastNameReceived(IDialogContext context, IAwaitable activity) { var LN = await activity; this.LastName = LN.Text; await context.SayAsync(text: lr + this.LastName, speak: lr + this.LastName); await Phone(context); } public async Task Phone(IDialogContext context) { await context.SayAsync(text: ph, speak: ph); context.Wait(PhoneNumberReceived); } public async Task PhoneNumberReceived(IDialogContext context, IAwaitable activity) { var PH = await activity; int flag = 0; foreach (var c in PH.Text.ToCharArray()) { if (!char.IsNumber(c) && c!='-') { flag = 1; break; } } if (flag == 1) { await context.SayAsync(text: "Phone number cannot contain any characters. Try again...", speak: "Phone number cannot contain any character. Try again"); await Phone(context); } else { if (PH.Text.Replace("-","").Length!=10) { await context.SayAsync(text: "Phone number should be of length 10. Try again...", speak: "Phone number should be of length 10. Try again..."); await Phone(context); } else { this.PhoneNumber = PH.Text.Replace("-",""); await context.SayAsync(text: phr + this.PhoneNumber, speak: phr + this.PhoneNumber); await context.SayAsync(text: str, speak: str); context.Wait(StoreNumberReceived); } } } public async Task StoreNumberReceived(IDialogContext context, IAwaitable activity) { var SN = await activity; this.StoreNumber = SN.Text.Replace(" ", string.Empty); StringBuilder sb = new StringBuilder(); foreach (char c in this.StoreNumber.ToCharArray()) { if (char.IsNumber(c)) sb.Append(" ").Append(c).Append(" "); else sb.Append(c); } this.Store = sb.ToString().Trim(); await context.SayAsync(text: strr+this.StoreNumber, speak: strr + this.Store); await context.SayAsync(text: petxt, speak: pespk); context.Wait(PeidReceived); } public async Task PeidReceived(IDialogContext context, IAwaitable activity) { var PE = await activity; this.Previouseid = PE.Text.Replace(" ", string.Empty); StringBuilder sb = new StringBuilder(); foreach (char c in this.Previouseid.ToCharArray()) { if (char.IsNumber(c)) sb.Append(" ").Append(c).Append(" "); else sb.Append(c); } this.PreviousEID = sb.ToString().Trim(); await context.SayAsync(text: petxtr+this.Previouseid, speak: pespkr + this.PreviousEID); await context.SayAsync(text: netxt, speak: nespk); context.Wait(NeidReceived); } public async Task NeidReceived(IDialogContext context, IAwaitable activity) { var NE = await activity; this.Neweid = NE.Text.Replace(" ", string.Empty); StringBuilder sb = new StringBuilder(); foreach (char c in this.Neweid.ToCharArray()) { if (char.IsNumber(c)) sb.Append(" ").Append(c).Append(" "); else sb.Append(c); } this.NewEID = sb.ToString().Trim(); await context.SayAsync(text: netxtr+this.Neweid, speak: nespkr + this.NewEID); await context.SayAsync(text: pos, speak: pos); context.Wait(PositionReceived); } public async Task PositionReceived(IDialogContext context, IAwaitable activity) { var POS = await activity; this.Position = POS.Text; await context.SayAsync(text: posr+this.Position, speak: posr + this.Position); await context.SayAsync(text: complete, speak: complete); await ShowDetails(context); } public async Task ShowDetails(IDialogContext context) { await context.SayAsync(text: "Your details are as follows:
First Name: "+this.FirstName+"."+"
Last Name: "+this.LastName+"."+"
Phone Number: "+this.PhoneNumber+"."+"
Store Number: "+this.StoreNumber+"."+"
Previous EID: "+this.Previouseid+"."+"
New EID: "+this.Neweid+"."+"
Position: "+this.Position+".", speak: "Your details are as follows: First name: " + this.FirstName + ". Last name: " + this.LastName + ". Phone number: " + this.PhoneNumber + ". Store number: " + this.Store + ". Previous e i d: " + this.PreviousEID + ". New e i d: " + this.NewEID + ". Position: " + this.Position); string prompt = "Do you want to Proceed?"; string retryprompt = "Please try again"; var promptOptions = new PromptOptions(prompt: prompt, options: choices, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler()); PromptDialog.Choice(context, SubmissionForm, promptOptions); } public async Task SubmissionForm(IDialogContext context, IAwaitable result) { string choice = await result; if (choice.ToLower() == "yes") { await context.SayAsync(text: "Your message was registered.", speak: "Your message was registered."); await context.SayAsync(text: "Once we resolve it, We will get back to you.", speak: "Once we resolve it, we will get back to you.");

            string prompt = "Do you want to Merge another employee?";
            string retryprompt = "Please try again";
            var promptOptions = new PromptOptions<string>(prompt: prompt, options: choices, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler());
            PromptDialog.Choice(context, Confirmed, promptOptions);
        }
        else
        {
            string prompt = "Please select one of the following options.";
            string retryprompt = "Please try again";
            var promptOptions = new PromptOptions<string>(prompt: prompt, options: option, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler());
            PromptDialog.Choice(context, SubmissionNotComplete, promptOptions);
        }
    }
    public async Task SubmissionNotComplete(IDialogContext context, IAwaitable<string> result)
    {
        string option = await result;
        if (option.ToLower().Contains("change"))
        {
            string prompt = "Okay, Tell me which field do you want to change?";
            string retryprompt = "Please Try again";
            var promptOptions = new PromptOptions<string>(prompt: prompt, options: details, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler());
            PromptDialog.Choice(context, Change, promptOptions);
        }
        else if (option.ToLower().Contains("cancel"))
        {
            await context.SayAsync(text: "You have cancelled the operation", speak: "You have cancelled the operation.");
            await context.SayAsync(text: "You can again start a new conversation by asking me things like 'POS Error', 'EID Merge', etc.", speak: "You can again start a new conversation by asking me things like 'P O S Error', 'E I D Merge', etc");
            context.Wait(this.MessageReceived);
        }
        else if (option.ToLower().Contains("redo"))
        {
            await context.SayAsync(text: "You requested to start the form fill up again", speak: "You requested to start the form fill up again.");
            await First(context);
        }
    }
    public async Task Change(IDialogContext context, IAwaitable<string> result)
    {
        string details = await result;
        if (details.ToLower() == "first name")
        {
            await context.SayAsync(pf + this.FirstName, speak: pf + this.FirstName);
            await FirstRepeat(context);
        }
        else if (details.ToLower() == "last name")
        {
            await context.SayAsync(pl+this.LastName, speak: pl + this.LastName);
            await LastRepeat(context);
        }
        else if (details.ToLower() == "phone number")
        {
            await context.SayAsync(pph+this.PhoneNumber, speak: pph + this.PhoneNumber);
            await PhoneRepeat(context);
        }
        else if (details.ToLower() == "store number")
        {
            await context.SayAsync(pstr+this.StoreNumber, speak: pstr + this.StoreNumber);
            await context.SayAsync(text: str, speak: str);
            context.Wait(StoreNumberRepeat);
        }
        else if (details.ToLower().Contains("previous"))
        {
            await context.SayAsync(ppetxt+this.Previouseid, speak: ppespk + this.Previouseid);
            await context.SayAsync(text: petxt, speak: pespk);
            context.Wait(PEIDRepeat);
        }
        else if (details.ToLower().Contains("new"))
        {
            await context.SayAsync(pnetxt+this.Neweid, speak: pnespk + this.Neweid);
            await context.SayAsync(text: netxt, speak: nespk);
            context.Wait(NEIDRepeat);
        }
        else if (details.ToLower() == "position")
        {
            await context.SayAsync(ppos+this.Position, speak: ppos+this.Position);
            await context.SayAsync(text: pos, speak: pos);
            context.Wait(PositionRepeat);
        }
        else
        {
            await ShowDetails(context);
        }
    }
    public async Task FirstRepeat(IDialogContext context)
    {
        await context.SayAsync(text: f, speak: f);
        context.Wait(FirstNameRepeat);
    }
    public async Task FirstNameRepeat(IDialogContext context, IAwaitable<IMessageActivity> activity)
    {
        string fname = this.FirstName;
        var fn = await activity;
        this.FirstName = fn.Text;
        await context.SayAsync(text: $"First name is changed form {fname} to {this.FirstName}.", speak: $"First name is changed form {fname} to {this.FirstName}.");
        string prompt = "Do you want to change any other fields?";
        string retryprompt = "Please try again";
        var promptOptions = new PromptOptions<string>(prompt: prompt, options: choices, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler());
        PromptDialog.Choice(context, ConfirmChange, promptOptions);
    }
    public async Task LastRepeat(IDialogContext context)
    {
        await context.SayAsync(text: l, speak: l);
        context.Wait(LastNameRepeat);
    }
    public async Task LastNameRepeat(IDialogContext context, IAwaitable<IMessageActivity> activity)
    {
        string lname = this.LastName;
        var ln = await activity;
        this.LastName = ln.Text;
        await context.SayAsync(text: $"Last name is changed from {lname} to {this.LastName}.", speak: $"Last name is changed from {lname} to {this.LastName}.");
        string prompt = "Do you want to change any other field?";
        string retryprompt = "Please try again";
        var promptOptions = new PromptOptions<string>(prompt: prompt, options: choices, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler());
        PromptDialog.Choice(context, ConfirmChange, promptOptions);
    }
    public async Task PhoneRepeat(IDialogContext context)
    {
        await context.SayAsync(text: ph, speak: ph);
        context.Wait(PhoneNumberRepeat);
    }
    public async Task PhoneNumberRepeat(IDialogContext context, IAwaitable<IMessageActivity> activity)
    {
        string phone = this.PhoneNumber;
        var ph = await activity;
        int flag = 0;
        foreach (var c in ph.Text.ToCharArray())
        {
            if (!char.IsNumber(c) && c != '-')
            {
                flag = 1;
                break;
            }
        }
        if (flag == 1)
        {
            await context.SayAsync(text: "Phone number cannot contain any characters. Try again...", speak: "Phone number cannot contain any character. Try again");
            await Phone(context);
        }
        else
        {
            if (ph.Text.Replace("-", "").Length != 10)
            {
                await context.SayAsync(text: "Phone number should be of length 10. Try again...", speak: "Phone number should be of length 10. Try again...");
                await Phone(context);
            }
            else
            {
                this.PhoneNumber = ph.Text.Replace("-","");
                await context.SayAsync(text: $"Phone number is changed from {phone} to {this.PhoneNumber}.", speak: $"Phone number is changed form {phone} to {this.PhoneNumber}.");
                string prompt = "Do you want to change any other field?";
                string retryprompt = "Please try again";
                var promptOptions = new PromptOptions<string>(prompt: prompt, options: choices, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler());
                PromptDialog.Choice(context, ConfirmChange, promptOptions);
            }
        }
    }
    public async Task StoreNumberRepeat(IDialogContext context, IAwaitable<IMessageActivity> activity)
    {
        string store = this.StoreNumber;
        var st = await activity;
        this.StoreNumber = st.Text.Replace(" ", string.Empty);
        StringBuilder sb = new StringBuilder();
        foreach (char c in this.StoreNumber.ToCharArray())
        {
            if (char.IsNumber(c))
                sb.Append(" ").Append(c).Append(" ");
            else
                sb.Append(c);
        }
        this.Store = sb.ToString().Trim();
        await context.SayAsync(text: $"Store number is changed form {store} to {this.StoreNumber}.", speak: $"Store number is changed form {store} to {this.Store}.");
        string prompt = "Do you want to change any other field?";
        string retryprompt = "Please try again";
        var promptOptions = new PromptOptions<string>(prompt: prompt, options: choices, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler());
        PromptDialog.Choice(context, ConfirmChange, promptOptions);
    }
    public async Task PEIDRepeat(IDialogContext context, IAwaitable<IMessageActivity> activity)
    {
        string peid = this.Previouseid;
        var pe = await activity;
        this.Previouseid = pe.Text.Replace(" ", string.Empty);
        StringBuilder sb = new StringBuilder();
        foreach (char c in this.Previouseid.ToCharArray())
        {
            if (char.IsNumber(c))
                sb.Append(" ").Append(c).Append(" ");
            else
                sb.Append(c);
        }
        this.PreviousEID = sb.ToString().Trim();
        await context.SayAsync(text: $"Previous EID is changed from {peid} to {this.Previouseid}.", speak: $"Previous e i d is changed from {peid} to {this.PreviousEID}");

        string prompt = "Do you want to change any other field?";
        string retryprompt = "Please try again";
        var promptOptions = new PromptOptions<string>(prompt: prompt, options: choices, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler());
        PromptDialog.Choice(context, ConfirmChange, promptOptions);
    }
    public async Task NEIDRepeat(IDialogContext context, IAwaitable<IMessageActivity> activity)
    {
        string neid = this.Neweid;
        var ne = await activity;

        this.Neweid = ne.Text.Replace(" ", string.Empty);
        StringBuilder sb = new StringBuilder();
        foreach (char c in this.Neweid.ToCharArray())
        {
            if (char.IsNumber(c))
                sb.Append(" ").Append(c).Append(" ");
            else
                sb.Append(c);
        }
        this.NewEID = sb.ToString().Trim();
        await context.SayAsync(text: $"New EID is changed from {neid} to {this.Neweid}.", speak: $"New e i d is changed from {neid} to {this.NewEID}");

        string prompt = "Do you want to change any other field?";
        string retryprompt = "Please try again";
        var promptOptions = new PromptOptions<string>(prompt: prompt, options: choices, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler());
        PromptDialog.Choice(context, ConfirmChange, promptOptions);
    }
    public async Task PositionRepeat(IDialogContext context, IAwaitable<IMessageActivity> activity)
    {
        string position = this.Position;
        var pos = await activity;
        this.Position = pos.Text;
        await context.SayAsync(text: $"Position is changed from {position} to {this.Position}.", speak: $"Position is changed form {position} to {this.Position}.");
        string prompt = "Do you want to change any other field?";
        string retryprompt = "Please try again";
        var promptOptions = new PromptOptions<string>(prompt: prompt, options: choices, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler());
        PromptDialog.Choice(context, ConfirmChange, promptOptions);
    }
    public async Task ConfirmChange(IDialogContext context, IAwaitable<string> result)
    {
        string confirm = await result;
        if (confirm.ToLower() == "yes")
        {
            string prompt = "Okay, what would you like to change?";
            string retryprompt = "Please try again";
            var promptOptions = new PromptOptions<string>(prompt: prompt, options: details, retry: retryprompt, speak: prompt, retrySpeak: retryprompt, promptStyler: new PromptStyler());
            PromptDialog.Choice(context, Change, promptOptions);
        }
        else
        {
            await ShowDetails(context);
        }
    }
    public async Task Confirmed(IDialogContext context, IAwaitable<string> result)
    {
        string confirm = await result;
        if (confirm.ToLower() == "yes")
        {

            await new CreateLMSTicket().StartAsync(context);
        }
        else
        {
            var ticketNumber = "L"+new Random().Next(1000,9999);
            await context.SayAsync(text: "A LMSTicket is provided to you and your message has been registered.", speak: "L M S Ticket is provided to you and your message has been registered.");

            await new CreateServiceRequest().Start(context, ticketNumber);

        }
    }
}

}

GlobalHandler.cs

using System; using System.Collections.Generic;

namespace POSBot { [Serializable] public class GlobalHandler { public string GetRandomString(List stringList) { Random random = new Random(); int idx = random.Next(0, 1000) % stringList.Count; return stringList[idx]; } public class Close { public List HelpMessage = new List { "Is there any additional help required?", "Do you need any additional help?", "Can I be of some more help?" }; public List RestartMessage = new List { "Okay, tell me what can I do for you.", "Please, tell me what can I do for you.", "I request you to tell me what to do.", "Tell me what else do you want." }; } public class Confirm { public List ready = new List { "Yes, I am ready", "No, I am not ready" }; public List proceed = new List { "Yes, I want to proceed", "No, I want to stop here" }; public List status = new List { "Yes, It was successful", "No, it was not successful" }; public List readyMessage = new List { "Are you ready?", "Ready to do it?", "Ready for this?" }; public List proceedMessage = new List { "Do you want to proceed?", "Proceed?", "Want to proceed?", "Proceed to next step?" }; public string Step1 = "Step 1: Click on Manager Menu from POS screen."; public string Step2 = "Step 2: Press Support Button."; public string Step3 = "Step 3: Again press Support Button."; public string Step4 = "Step 4: Enter Password(Last digit of Year, Last digit of Month, Last Digit of Date)."; public string Step5 = "Step 5: Press the Cashless Maintenance Button."; public string Step6 = "Step 6: Press Open PED."; public string Step7 = "Step 7: Reset the Cashless Device."; public string Step8 = "Step 8: Select Manager Menu > Special Functions > Reset Cashless device."; public string Step9 = "Step 9: Image will come up: Please be sure there are no cards inserted in the PED before continuing, then Press OK."; public string Step10 = "Step 10: If successful the following message will come up: PED communication is working."; } public class EID { public List assistance = new List { "Person Merge Assistance", "Person Merge Information", "Global Account Manager" }; public List level = new List { "Staff level", "Store level" }; public List support = new List { "I want to see presentation", "I want to contact" }; public List merge = new List { "Has a person merge been completed?", "Have you completed a person merge?", "Is a person merge complete?" }; } public class LMS { public string firstname = "Enter your First Name:"; public string lastname = "Enter your Last Name:"; public string phonenumber = "Enter your Phone Number:"; public string storenumber = "Enter your store Number:"; public string previouseidtext = "Enter your Previous EID:"; public string previouseidspeak = "Enter your previous e i d:"; public string neweidtext = "Enter your New EID:"; public string neweidspeak = "Enter your new e i d:"; public string position = "Enter your position:"; public string freceive = "First name is received as: "; public string lreceive = "Last name is received as: "; public string phreceive = "Phone number is received as: "; public string strreceive = "Store number is received as: "; public string ptxtreceive = "Previous EID is received as: "; public string pspkreceive = "Previous e i d is received as: "; public string ntxtreceive = "New EID is received as: "; public string nspkreceive = "New e i d is received as: "; public string posreceive = "Position is received as: "; public string fcom = "Form fill up completed."; public string pfirstname = "Your last entered first name was: "; public string plastname = "Your last entered last name was: "; public string pphone = "Your last entered phone number was: "; public string pstore = "Your last entered store number was: "; public string ppetxt = "Your last entered Previous EID was: "; public string ppespk = "Your last entered previous e i d was: "; public string pnetxt = "Your last entered New EID was: "; public string pnespk = "Your last entered new e i d was: "; public string ppos = "Your last entered position was: "; } public class POS { public string Step1 = "Log into a register and confirm when you are ready for the next step."; public string Step2 = "If you do not have a POS ID and password, please have a store manager log in."; } } }

I want the input hint to work in the createlmsticket.cs file.. Please help me. Whenever the bot says Enter your first name, the microphone should automatically open.

fanidamj-zz commented 6 years ago

Have you tested the code? Meanwhile I'll be reproducing the issue and get back to you shortly.

saikatbh94 commented 6 years ago

Okay friends, this issue has been resolved already. Thank you anyway. I just had to use the 'options' in the context.SayAsync() to incorporate inputhint. I mean: await context.SayAsync(text: ... , speak: ... , options: new MessageOptions() { InputHint = InputHints.expectingInput});

fanidamj-zz commented 6 years ago

Thanks for the update.