dialogflow-botkit-client icon indicating copy to clipboard operation
dialogflow-botkit-client copied to clipboard

Implement a catch all

Open adantoscano opened this issue 7 years ago • 0 comments

Hi,

Implement a catch all could be a great idea, I've imported an agent in dialogflow but I don't use all actions, so if dialog get some action that I don't use I'll get nothing.

This is my suggestion

if (isDefined(response.result)) {
  let action = response.result.action;
  if (isDefined(action)) {
    if (worker.actionCallbacks[action]) {
      worker.actionCallbacks[action].forEach((callback) => {
        callback(message, response, bot);
      });
    }else{
      worker.actionCallbacks['anythingelse'].forEach((callback) => {
        callback(message, response, bot);
      });
    }
  }
}

adantoscano avatar Jan 17 '18 17:01 adantoscano