Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Dialogflow

Tip

Before you start: make sure your MARBEL agent is connected to Dialogflow.

...

Tip

Check that your greeting intent is working by using the microphone button in the test console on the DIalogflow console page. Try various phrases also using the test console and check whether what you say is recognized as a greeting intent.

Prolog and Patterns

...

Patterns

Greeting pattern without self-introduction

We shall start by considering how a typical greeting pattern looks like. When the agent does not introduce itself, a very common greeting pattern could like look this:

...

We have used the same name or label greeting that we used for the user’s move also for the agent’s move in the pattern that we defined. This makes sense conceptually because the moves are the same type of move, i.e. a greeting from one actor to another. The same intent label, however, should be handled very differently for the agent than for a user. Dialogflow should handle the natural language understanding (NLU) of a user’s move first by (transcribing the speech and then) classifying the move as an intent. In contrast, the MARBEL agent should handle the agent intent and make sure the agent generates natural language (NLG) text as output for a speech synthesizer. A user’s intent thus can be viewed as an input label whereas agent intents can be viewed as output or response labels. Below, we will see how we can provide texts for the agent to make its move in the responseresponses.pl file. Because the same intent label for a user and for an agent are handled in very different places, there is no harm in using the same label either, and we can keep things conceptually simple.

Greeting with self-introduction

Pattern C1.1: Opening Self-Identification (Agent)

Example:

A: hello

A: I'm _____

U: hi

This pattern will be quite similar to the one above, but should include the intent label ​​'selfIdentification'. Add a list [_,_] predicate in the pattern list above for the new rule that tells the agent to self-identify. Also, note that the agent must have a name in order to self-identify.

...

Specifying the agent’s greeting

In the Prolog file responses.pl we determine how what exactly the agent will say to initiate a move in the conversation or how it will respond to something a user said, using the intent label from a pattern that indicates what type of response the agent should give. This is done using . The basic idea is to add natural language phrases, sentences, or text for each type of move the agent can make. In other words, we need to specify phrases for all the intent labels that occur in dialog moves in all patterns that are made by the agent. If there is no phrase specified at all for one of the agent’s possible dialog moves, the agent will not be able to perform that move…!

We will use the predicate text(Intent, Text) for specifying how the agent will greet a user. The first argument Intent of the text/2 predicate should be instantiated with an intent label in a dialog move of the agent, and the second argument Text should be a string atom with the text you want your agent to say. So, for example, in the case of the c10 pattern, we use the agent intent used in the pattern 'greeting' pattern([c10, [agent, greeting], ___]). Add the new For the greeting intent we thus need to specify at least one phrase by adding a text(greeting, "YOURPHRASEHERE") fact to the responses.pl file. Now add such a text/2 fact for the intent label greeting under the % Intent: greeting comment. An example fact that you can add. for example, is text(greeting, "hi").

Next, we need to build the rule for selfIdentification.

The head of the rule should be as follows: text(selfIdentification, Txt) :- 

Place it under % Intent: self-identification in responses.pl

This rule should produce a response that is returned as Txt and should include the agent's name.

Info

If you add only one text/2 fact for an intent label to the responses.pl file, your agent will quickly become boring (if not to your users it will soon enough start to bore you and your team members when you repeatedly need to test your agent!). To enable your agent to vary in what exactly it says when it makes a particular type of dialog move, all you need to do is to add more text/2 facts for an intent. The text_generator/2 predicate defined at the top of the responses.pl file will then randomly select one of these prhases for the agent to say.

Greeting with a self-introduction

Pattern C1.1: Opening Self-Identification (Agent)

Example:

A: Hello.

A: I'm _____.

U: Hi!

This pattern will be quite similar to the one above, but should include the intent label ​​'selfIdentification'. Add a list [_,_] predicate in the pattern list above for the new rule that tells the agent to self-identify. Also, note that the agent must have a name in order to self-identify.

Specifying the agent’s self-introduction

You and your team should think of a name for your agent. Feel free to be creative. We need to tell our agent its name somewhere. In dialog_init.mod2g, on line 40 you can add the name you came up with for your agent. Change the empty string in insert(agentName(''), for example, to insert(agentName('Bellabot').

FirstNext, we need to define the agent name so we can access it later. The agent’s name is initialized at the start of the session. Find where you need to define the agent name somewhere in a .mod2g filebuild the rule for selfIdentification.

The head of the rule should be as follows: text(selfIdentification, Txt) :- 

Place it under % Intent: self-identification in responses.pl

This rule should produce a response that is returned as Txt and should include the agent's name.

Once you have defined your agent you can utilize the predicate that you inserted into its memory.

You should then return a sentence including the agent’s name as Txt.

Visuals

Opening Page (visuals for the c10 pattern)

...