11

I'm trying to use the FormBuilder in combination with my intents as I created them in Luis. I just can't find the documentation to do this.

I would like to do the following things:

  1. A user would enter a phrase which is interpreted with Luis.
  2. If not all entities are given in the phrase the form builder will fill in the gaps.

How do I do this? Is there a tutorial? I see people talking about LuisDialogs, but I just don't know where to start.

OmG
  • 18,337
  • 10
  • 57
  • 90
Aldentev
  • 490
  • 2
  • 6
  • 18
  • I found this is a good article: http://www.c-sharpcorner.com/article/an-interactive-bot-application-with-luis-using-microsoft-bot/ – PhuocLe Oct 18 '16 at 08:18

1 Answers1

16

In a nutshell :

Here are some steps (but you should definitely follow the guide I linked):

Basically it is a class which inherits LuisDialog<object> and you have to put an attribute on top of it with your Luis id and secret

[LuisModel("c413b2ef-382c-45bd-8ff0-f76d60e2a821", "6d0966209c6e4f6b835ce34492f3e6d9")]
[Serializable]
public class SimpleAlarmDialog : LuisDialog<object>
{ [...]

Then you add method to your class and decorate them with the LuisIntent(...) attribute.

 [LuisIntent("builtin.intent.alarm.turn_off_alarm")]
 public async Task TurnOffAlarm(IDialogContext context, LuisResult result)
 { [...]

Inside the method, you can search if an entity was found using a code like this :

EntityRecommendation title;
if (result.TryFindEntity(Entity_Alarm_Title, out title))
{
    what = title.Entity;
}
else
{
    what = DefaultAlarmWhat;
}

Finally, to start the dialog, you have to call this Inside your controller:

public async Task<Message> Post([FromBody]Message message)
    {
        if (message.Type == "Message")
        {
            // return our reply to the user
            return await Conversation.SendAsync(message, () => new EchoDialog());
        }
        else
        {
            return HandleSystemMessage(message);
        }
    }
  • Thank you! I've looked at the PizzaBot example and I managed to get my code working :-) – Aldentev May 02 '16 at 11:44
  • Perfect! can you mark the answer as useful so other people having the same question can rely on it? :) – Etienne Margraff May 02 '16 at 12:08
  • If the entity is NOT provided, how can i prompt the user to provide just the entity information in second step ? Do i need to update the Luis model to be able to take just 1 word as the entity and link it with the intent ? – Vikram Sep 22 '16 at 07:18