SangramMCP
Posts: 57
Joined: Wed Jul 26, 2017 7:41 pm

Re: Prompt

Tue Aug 08, 2017 10:18 pm

Hi Lessie,

This is the error we get(in attachment).

Moreover, if we write this directly in ChatService.aspx, it works.

User avatar
Leslie
Lead Software Architect
Posts: 353
Joined: Fri Sep 14, 2012 12:20 pm
Contact: Website

Re: Prompt

Tue Aug 08, 2017 10:38 pm

I am sorry but I don't see any attachment in the post. Possibly a restricted file format. If it's a screenshot you could just upload it to ImgBB and share the link if that's feasible.

SangramMCP
Posts: 57
Joined: Wed Jul 26, 2017 7:41 pm

Re: Prompt

Wed Aug 09, 2017 1:03 am

Hi Lessie,

Please have a look on this.

https://ibb.co/csGfEv

Thanks,
Sangram

User avatar
Leslie
Lead Software Architect
Posts: 353
Joined: Fri Sep 14, 2012 12:20 pm
Contact: Website

Re: Prompt

Wed Aug 09, 2017 1:16 am

At the top of my head it looks like a dependency mismatch. Try to check if the same version of Syn.Bot is being referenced across all your projects.

SangramMCP
Posts: 57
Joined: Wed Jul 26, 2017 7:41 pm

Re: Prompt

Wed Aug 09, 2017 9:14 pm

Hi Lessie,

The same seems to be working.

But I have landed up into different problem.

I have 3 layers.
1. Data(Class Library) : It Contains all the entity recognizers.
2. Core(Class Library) : It Contains dialogs and constants.
3. Chanel(ASP.NET UI): References Core & Data, and creates the instances of Oscova. It contains the channel as well.

In this scenaio, the context is not working:
If I type salary slip, it asks for Emp Name. Even if we give a name out of added entity.
It prompts again for the emp name.


Please suggest for the same.

Thanks,
Sangram

User avatar
Fantom
Help & Support
Posts: 304
Joined: Fri Oct 25, 2013 9:20 pm

Re: Prompt

Wed Aug 09, 2017 10:48 pm

a context lasts for like 5 minutes. You could specify "1" as the context lifespan and try.

CSharp Code

[Expression("some expression")]
[Context("some-context",1")]
public void SomeIntent(Context con, Result res)

SangramMCP
Posts: 57
Joined: Wed Jul 26, 2017 7:41 pm

Re: Prompt

Thu Aug 10, 2017 4:40 pm

Thanks FranzZ,

It worked. Now I have 1 more question, wrt. the example given by Lessie.

[Expression("Salary Slip")]
with respect to the above expression, we are building a context.

What about the expression where the user types "My Salary Slip for the month of March 17".
Actually both does the same work, but in the 1st example, the conversation is build, and other, the user keys in the requirement directly.

How this scenario can be handled?

Thanks,
Sangram

User avatar
Fantom
Help & Support
Posts: 304
Joined: Fri Oct 25, 2013 9:20 pm

Re: Prompt

Thu Aug 10, 2017 5:37 pm

its very simple, you can just conditionally add context and shared entities instead of create new intents. I edited Leslie's code

CSharp Code

internal class SalarySlipDialog : Dialog
    {
        [Expression("I need the {salary slip}")]
        [Expression("Please give me my {salary slip}")]
        [Expression("Can you provide me my {salary slip}")]
        [Expression("My Salary Slip for the month of @sys.date")]
        [Entity("slip")]
        public void NeedSalarySlip(Context context, Result result)
        {
            var response = new Response
            {
                Text = "Can you confirm your Emp Name",
                Hint = "Your Full Name" //Provide some hint in any GUI if applicable.
            };

            //Send response.
            result.SendResponse(response);

            if (result.Entities.Contains(Sys.Date))
            {
                context.SharedEntities.Add(result.Entities.OfType(Sys.Date));
            }

            //Add new context for follow-up intent.
            context.Add(Constants.EmpNameInput, 1);
        }

        [Expression("@emp-name")]
        [Context(Constants.EmpNameInput)]
        public void EmpNameProvided(Context context, Result result)
        {
            var response = new Response
            {
                Text = "For which month do you require the salary Slip",
                Hint = "Enter Month or Date" //Provide some hint in any GUI if applicable.
            };

            //Remove this intent's context to avoid recall.
            context.Remove(Constants.EmpNameInput);

            //Collect Employee Name here.
            context.SharedEntities.Add(result.Entities.OfType("emp-name"));

            if (!context.SharedEntities.Contains(Sys.Date))
            {
                //Send response.
                result.SendResponse(response);

                //Add new context for follow-up intent.
                context.Add(Constants.SlipDateProvider, 1);
            }
            else
            {
                var date = context.SharedEntities.OfType(Sys.Date);
                var empName = context.SharedEntities.OfType("emp-name").ToString();
                result.SendResponse($"Thanks {empName}. Here is your salary slip for {date.Value}");

                context.SharedEntities.Clear();
            }   
        }

        [Expression("@sys.date.month:month")]
        [Context(Constants.SlipDateProvider)]
        public void SlipDate(Context context, Result result)
        {
            var date = result.Entities.OfType("month").ToString();
            var empName = context.SharedEntities.OfType("emp-name").ToString();
            result.SendResponse($"Thanks {empName}. Here is your salary slip for the month of {date}");

            context.SharedEntities.Clear();
        }
    }
also in the above I am clearing all shared entities after the final response is sent to make sure that they are not re-used.

SangramMCP
Posts: 57
Joined: Wed Jul 26, 2017 7:41 pm

Re: Prompt

Thu Aug 24, 2017 3:24 pm

Leslie wrote:Follow-up or slot fillings would make use of Oscova's context procedures. Below is a sample of how one would achieve what you've mentioned:

Just to add, our statistics showed that mostly January and February are shortened to Jan and Feb by most users. So Mar would be rendered invalid. Instead you would expect March as the general response. In case you really intend to add shortened words for months you could do that by provide synonyms for recognizer entries or creating custom filters.

Coming back to the scenario you've provide. Ensure that you add an employee name entity recognizer if possible. You can also avoid loading of all employee names by enumerating over database entries as shown in the NLI to Database sample in our GitHub repository.

CSharp Code

var empNameRecognizer = bot.CreateRecognizer("emp-name");
empNameRecognizer.Entries.Add("Sangram");
empNameRecognizer.Entries.Add("Maneesh");

CSharp Code

internal class Constants
{
	public const string EmpNameInput = "emp-name-input";
	public const string SlipDateProvider = "slip-date-provided";
}
internal class SalarySlipDialog : Dialog
{
	[Expression("I need the {salary slip}")]
	[Expression("Please give me my {salary slip}")]
	[Expression("Can you provide me my {salary slip}")]
	[Entity("slip")]
	public void NeedSalarySlip(Context context, Result result)
	{
		var response = new Response
		{
			Text = "Can you confirm your Emp Name",
			Hint = "Your Full Name" //Provide some hint in any GUI if applicable.
		};

		//Send response.
		result.SendResponse(response);

		//Add new context for follow-up intent.
		context.Add(Constants.EmpNameInput, 1);
	}

	[Expression("@emp-name")]
	[Context(Constants.EmpNameInput)]
	public void EmpNameProvided(Context context, Result result)
	{

		var response = new Response
		{
			Text = "For which month do you require the salary Slip",
			Hint = "Enter Month or Date" //Provide some hint in any GUI if applicable.
		};

		//Send response.
		result.SendResponse(response);

		//Remove this intent's context to avoid recall.
		context.Remove(Constants.EmpNameInput);

		//Collect Employee Name here.
		context.SharedEntities.Add(result.Entities.OfType("emp-name"));

		//Add new context for follow-up intent.
		context.Add(Constants.SlipDateProvider, 1);
	}

	[Expression("@sys.date.month:month")]
	[Context(Constants.SlipDateProvider)]
	public void SlipDate(Context content, Result result)
	{
		var date = result.Entities.OfType("month").ToString();
		var empName = content.SharedEntities.OfType("emp-name").ToString();
		result.SendResponse($"Thanks {empName}. Here is your salary slip for the month of {date}");
	}
}
The above is just my interpretation, your actual code would differ.
Hi, It was working till date,
but now it behaves wired.

Its asks for Empoyee Name : once i give input
It asks for date, if I provide month
It doesn't go to the required intent.
Is there any cause for the same?

User avatar
Fantom
Help & Support
Posts: 304
Joined: Fri Oct 25, 2013 9:20 pm

Re: Prompt

Fri Aug 25, 2017 8:06 pm

if it was working till now then it should continue working unless something has been changed.

please compare your previous code with the current code and see what differences have been made. probably some new configuration was added? It is highly unlikely that a software code that previously worked would stop working at a later point in time without some external reasons.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest