How to override interruptions when "Discard All" is uttered during a prompt


(John Aspen Catingub) #1

Hi,

I’ve been trying to get a String Entity to work on an interruption when “Discard All” is prompted.

The String Entity, “Description” is mandatory and almost any form of text is allowed even if it attempts to trigger other Dialog Tasks/FAQ; but I want “Discard All” to be an exception and it should discard all tasks when this is uttered.

However when “Discard All” is typed down, it is being processed as the Entity Node value.

Here are my interruptions settings:
InterruptionSettings


(Swagat) #2

@aspen.catingub
Usually String and Description accept anything which is typed down.

You can achieve your use case in either of the ways -

  1. You can write an entity level transition based on its value and end the dialog.
  2. You can tap into the entity value in botkit, and if the condition is met, send refresh like shown below -
    (remember, setting nlMeta is refresh true may result in empty message from bot. So, that may need to be handled - The below solution is just an example and it does not in any way indicate an optimum solution)
   on_user_message: function (requestId, data, callback) {

        console.log("###request id: " + requestId);
        console.log("on_user_message ==> " + data.message);
        console.log("on_user_message (Meta Info) ==> " + JSON.stringify(data.metaInfo));
        var currMsg = data.message;
        if(currMsg.toLowerCase() === 'discard all'){
            console.log("Setting nl meta refresh true");
            data.metaInfo = {
                nlMeta: {
                    isRefresh: true,
                }
            };

        }
        sdk.sendBotMessage(data, callback);

    },
    on_bot_message: function (requestId, data, callback) {
        console.log("###request id: " + requestId);
        console.log("on_bot_message ==> " + data.message);
        console.log("on_bot_message (Meta Info) ==> " + JSON.stringify(data.metaInfo));

        var currMsg = data.message;
        if(currMsg === ''){
            data.message = "Ok";
            return sdk.sendUserMessage(data, callback);
        }

        sdk.sendUserMessage(data, callback);
    },