Like and dislike button

Hi ,

Can you please guide me that somehow I can make a like and dislike button at the last of every conversation.

I want the Thumbs up and Thumbs Down button at the last of every conversation.

Please help in that.

1 Like

@renisweta1094, Below is a thought I had on achieving your use case.

  1. Create a dialog (Say: “User Satisfaction” as a hidden dialog ) which has an entity node to collect user opinion.
  2. Configure the message at entity node to display a “quick replies template with images” which has like and dislike icons on it
  3. Transition the entity node to a script node and store the received input (Like / Dislike) into a BotContext type context variable. (You could even include the user info along with the select option if needed)
  4. Now link the dialog “User Satisfaction” at the end of each dialog in you bot as the last node.

Hope this helps :slight_smile:

3 Likes

The other way to handle this usecase is from the botkit.
It might be a tough job for the developer to link the dialog at end of conversation flow at the dialogs, considering the fact that there could be many end of dialog flows and even many dialogs in the bot.
Other problem area for the developer would be invoking the “User Satisfaction” dialog after an FAQ response.

These can be addressed if the botkit is enabled at the bot and is configured to have the onEvent received. At the bot kit, you could have the logic to trigger the dialog when the eventTypes “endFAQ” or “endDialog” are received at the bot kit.

Below is sample snippet at botkit for your reference.

on_event: function(requestId, data, callback)
{
if ( data.event.eventType === “endDialog”)
{
data.message = ‘User Satisfaction’;
return sdk.sendBotMessage(data, callback);
}
else {
return callback(null, data);
}
}
1 Like

Please Help, It’s not working!!!
I have tried the same thing and I have debugged to confirm that request was sent to the bot platform and the messaging endpoint sendBotMessageUrl returned 200 OKs but the bot didn’t respond.
there was no message from the bot, on_bot_message was never triggered.

function onEvent(requestId, data, callback)
{
if (data.event.eventType === "endDialog")
{
    if(data.event.completedTaskName === "userfeedback" && data.event.endReason === "Fulfilled")
    {
        if(data.channel.body !=":+1:" && data.channel.body != ":-1:")
        {//ex this is for utterance ex 'hello'
            data.message = data.channel.body;
            return sdk.sendBotMessage(data,callback);               
        }
        else
        {
            return callback(null, data);
        }
    }
    else
    {
        data.message = 'UserFeedback';
        return sdk.sendBotMessage(data,callback);  
    }
}
else
{
    return callback(null, data);
}   
}

@Subrahmanyam Any Update please

@Subrahmanyam Any Updates?

any updates?

    if (data.event.eventType === "endDialog" || data.event.eventType ==="endFAQ")
{     
    if(data.event.completedTaskName === "userfeedback" && data.event.endReason === "Fulfilled")
    {
        return callback(null, data); 
    } 
    else
    {
        var test= JSON.stringify(data);
        data.message = 'UserFeedback';
        return sdk.sendBotMessage(data,callback);  
    }                         
}
else
{
    return callback(null, data);         
}

@swagata.sengupta @Subrahmanyam any update?

@damaresh.n
I am able to configure a feedback dialog and call it from botkit.
Here is my code (Basically, I am checking if the end of dialog is from a task other than feedback, I am calling feedback, else, just displaying the current total likes)

    on_event: function (requestId, data, callback) {
        console.log("on_event ==> Event details:");
        console.log(data.event);       
        if (data.event.eventType === "endDialog") {
            console.log("end of dialog processing");
            if (data.event.completedTaskName != "feedbackdialog" && data.event.endReason === "Fulfilled"){
                console.log("Dialog executed: " + data.event.completedTaskName);
                data.message = "feedbackdialog";
                return sdk.sendBotMessage(data, callback);
            } else {
                console.log("Feedback dialog executed. Total likes " + data.context.session.BotContext.TOTAL_LIKES);
                return callback(null, data);
            }
        }
    }

Here is how the feedbackDialog is set up. In the script nodes, I am just using a bot context variable to increment to increment or reduce total likes:

var totLikesPresent = BotContext.get("TOTAL_LIKES");

if(totLikesPresent === undefined){
   BotContext.put("TOTAL_LIKES",1);
} else {
    totLikesPresent +=1;
    BotContext.put("TOTAL_LIKES",totLikesPresent);
}

Bot output

BotKit console:

Some tips:

  1. Please use console.log statements like I did to see what is the event object. This will help you write the correct code to tap the dialog.
  2. In feedback dialog, try not to have ‘not connected’ nodes. Not sure what your bot configuration is but the principle remains the same.
  3. If you are not getting a grip on botkit, you may use end of dialog event also.

Hi Swagati

I have done almost the same thing that you have explained in your reply, even after that it was not working. i even when down debugging to check what was the response from platform for sendBotMessageUrl request but it always returned success message.
so finally i decided to take a fresh copy of botkit and migrate my solution and its working fine now.

One last problem which i have is handling interruptions in middle of feedback dialog, right now when user says something other than confirmation values its going to none Intent but we have a proper response in KB for that utterance

and i have set the interruption behavior as well properly

if you see in the chat history, first time its picking proper response but second time as its in middle of Dialog Task and as its interrupted its going to Default_Intent.

@damaresh.n
Try using intent over entity setting and try once. This works much better in entity LoV instead of confirmation node. You can take the value of yes/ no like in confirmation in list of value entity and configure transitions.

Thank you it worked.