BotBuilder-Samples icon indicating copy to clipboard operation
BotBuilder-Samples copied to clipboard

Display HeroCard using luis action binding

Open HelloJyo opened this issue 9 years ago • 4 comments

how to create a HeroCard in the "fulfill()" of luis action binding? any examples..?

HelloJyo avatar Jul 07 '17 05:07 HelloJyo

Hi @HelloJyo , Take a look at the FullfillReplyHandler @ https://github.com/Microsoft/BotBuilder-Samples/blob/master/Node/blog-LUISActionBinding/samples/bot/app.js#L38 See how to configure LAB with the option @ https://github.com/Microsoft/BotBuilder-Samples/blob/master/Node/blog-LUISActionBinding/samples/bot/app.js#L28

More information here:

  • README (search for fulfillReply)
  • Commit Details: https://github.com/Microsoft/BotBuilder-Samples/pull/130

Regards, -PabloC.

pcostantini avatar Jul 07 '17 14:07 pcostantini

` fulfill : function (parameters, callback) {

utilities.FilterFunction(parameters.x, parameters.y).then(function (matches){
   utilities.CreateCard(session, matches).then(function(cards){

        var reply = new builder.Message(session)
            .attachmentLayout(builder.AttachmentLayout.carousel)
            .attachments(cards);

        callback(util.format(reply));
    });

});

}`

This is what I want to do.. But session won't work on the function.

HelloJyo avatar Jul 10 '17 04:07 HelloJyo

Hi @HelloJyo

You should NOT create the card in the action's fulfill method. In it you should only invoke your action and pass back a result using the callback handler.

You should create the HeroCard from the optional fulfillReplyHandler when calling the bindToBotDialog method. See here for an example: https://github.com/Microsoft/BotBuilder-Samples/blob/master/Node/blog-LUISActionBinding/samples/bot/app.js#L28

In there you'll have access to the session object and the actionModel with the result. You can then check the actionModel.intentName to verify which LUIS intent was triggered and create the card as you wish.

Regards, -PabloC.

pcostantini avatar Jul 11 '17 17:07 pcostantini

Okay, I got it now... Thanks and regards, -Jyo

HelloJyo avatar Jul 12 '17 05:07 HelloJyo