Skip to content

API : Aido object

Damien BUTY edited this page May 20, 2020 · 4 revisions

The aido object is returned when you require('aido'). It contains the necessary methods for initializing and starting your aido server, as well as access to needed aido components :

module.exports = {
  Slash,

  init,
  start,

  helpers,
  registerSlash,
  registerView,
  emitSlash,
  emitAction,

  koaApp,
  koaRouter,
}

Slash (Class) : The Slash class that you will extend to create your Slash commands. Please visit the Slash page for complete reference.


init (function) : The function used to initialize your aido server. It takes the following arguments :

  • options (object) : The configuration options of your aido server. Please refer to the init page for complete reference of the options.

start (function) : The function used to start your aido server. It takes the following arguments :

  • port (Number) : The port on which to listen. Defaults to 3000.

helpers (object) : Plugins can provide methods and variables for use in the global context of your application. They will be exposed by the aido.helpers object, under the plugin's name :

aido.init({
  // ...
  plugins: [somePlugin],
  // ...
})

const someValue = aido.helpers['some-plugin'].someValue
aido.helpers['some-plugin'].someMethod(someValue)

registerSlash (function) : If for some reason you cannot initialize all your Slashes before initializing the aido server, you can register them manually at a later point in time with this helper. It takes the following arguments :

  • name (String) : The name of your Slash
  • slash (Slash) : Your extended Slash class

registerView (function) : You can also register views manually, for example if you want to provide them as a string instead of having them in a separate .pug file. It takes the following arguments :

  • name (String) : The name of your view
  • template (String) : The pug template of your view

emitSlash (function) : This helper allows you to trigger a Slash command for a user, emulating this particular user typing /somecommand in their Slack client. Please refer to the emitters page for complete reference.

emitSlash (function) : This helper allows you to trigger an action for a user, emulating this particular user clicking on a button or submitting a Dialog form on a particular view. Please refer to the emitters page for complete reference.


koaApp (object) : This is the koa application underlying your aido server.

koaRouter (object) : This is the koa-router underlying your aido server. You can use it to declare new routes on your server for serving static files or whatever fits your needs.