JavaScript How to throw a custom message using Dialogflow after three times of fallback throw custom message java,throw custom message c#,throw custom

I am developing a chatbot using Dialogflow, I would like to throw a message to user when the chatbot doesn't understand the user input for three times in a row and for the forth time respond with a custom message (not the one of the options declared on the dialogflow interface)

One idea that I have is to make a counter within the input unknown action like this:

var counter = 1;
// The default fallback intent has been matched, try to recover (https://dialogflow.com/docs/intents#fallback_intents)
'input.unknown': () => {
    // Use the Actions on Google lib to respond to Google requests; for other requests use JSON
    if (requestSource === googleAssistantRequest) {
        sendGoogleResponse('I\'m having trouble, can you try that again?'); // Send simple response to user
    } else {
        if (counter == 3) {
            counter = 1;
            sendResponse('Custom message');
        } else {
            counter++;
            sendResponse('I\'m having trouble, can you try that again?'); // Send simple response to user
        }

    }
},

This would work, but idk if this will work for multiple user at the same time, I was thinking to create a storage for storing requests attached by a unique id and have a different counter for each request!

Do you have any better idea of achieving such thing in Dialogflow?

Answer:1

I have defined a function as following : function getCurrentComponent(){ if($rootRouter._currentInstruction){ return $rootRouter.recognize($rootRouter._currentInstruction.urlPath).then(...

I have defined a function as following : function getCurrentComponent(){ if($rootRouter._currentInstruction){ return $rootRouter.recognize($rootRouter._currentInstruction.urlPath).then(...

  1. function handle to symbolic matlab
  2. function handle to string matlab
  3. function_handle with value
  4. function handle with multiple variables matlab
  5. function handle with two variables
  6. function_handle with value matlab
  7. function handle with parameters matlab
  8. string handling function
  9. function handle for loop matlab
  10. function handle with multiple outputs
  11. handle to function matlab
  12. function handle to symbolic
  13. function handle with multiple variables
  14. function handle to double
  15. function handle with arguments matlab
  16. function handle to matrix
  17. function handle with array
  18. function handle to

The following Promise behaves as expected, the Promise in the return statement gets fulfilled and the then right afterwards gets executed before the last call of then: (new Promise(resolve => ...

The following Promise behaves as expected, the Promise in the return statement gets fulfilled and the then right afterwards gets executed before the last call of then: (new Promise(resolve => ...

Here is my code function consec(string) { for (let letter of string) { console.log(letter); } } console.log(consec("zoo")); the result is "z" "o" "o" undefined This is the link of my ...

Here is my code function consec(string) { for (let letter of string) { console.log(letter); } } console.log(consec("zoo")); the result is "z" "o" "o" undefined This is the link of my ...

I am using SVG filter feMorphology's dilate to implement shadow spread for a shape. Am expecting below result. <?xml version="1.0" encoding="UTF-8"?> <svg width="188px" height="209px" ...

I am using SVG filter feMorphology's dilate to implement shadow spread for a shape. Am expecting below result. <?xml version="1.0" encoding="UTF-8"?> <svg width="188px" height="209px" ...