title: Nodejs Replace multiple switch/ifelse statements with config
body: <p>I am creating a (nodejs) chat bot, that reads messages and should act upon them. Due to its nature, the easy way to select which command should be executed is by multiple if else statements that execute a directive (a command), to which I pass a callback function.</p>
  
  <p>Is there a better way? Any way to use a yaml or any other type of xml like config file to assign the route/controller?</p>
  
  <p>Here is a code example. Full project <a href="https://github.com/drakoumel/BMO" rel="nofollow">here</a></p>
  
  <pre><code>var main = require('./Directives/default');
  
  if (workingMsgBody.indexOf("help") &gt; -1) {
      main.help(function(data) {
       outputChannel.sendOutput(msg.medium, data);
  });
  
  //multiple elseif statements follow
  
  module.exports.help = function(callback) {
    callback('blah blah');
  }
  </code></pre>