Skip to content

API : Init configuration options

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

The aido.init function takes one object as an argument, containing all the configuration options necessary for the operation of an aido server. A simple example would look like this :

// Configure global application
aido.init({
  viewsFolder: __dirname,
  slash: { number: Number },
  plugins: [somePlugin, someOtherPlugin],
  signingSecret: process.env['SIGNING_SECRET'],
  appToken: process.env['APP_TOKEN'],
})

The options object is available from the Slash class as this.options. You can add any arbitrary values in this object, as long as they don't interfere with reserved aido configuration options. Some plugins might also be configured through the options object : you can see an example of this behaviour in the aido-graphql plugin documentation.

Configuration object reference

Oauth & tokens

See the OAuth authentification page for reference on single-tenant and multi-tenant setups, and the associated tokens.

appToken (String) : The token used by your aido server to send messages to Slack. Found in the OAuth & Permissions page of your Slack application, in this format : xoxb-xxxxxxxxxx-xxxxxxxxxxx. (On applications still using legacy scopes, you should use the "Oauth Access token" in the xoxp-... format here, and if needed provide the xoxb-... as a botToken (see below).

signingSecret (String) : This string is used to authenticate that the requests you get do indeed come from your Slack application. It can be found in the Basic information page of your Slack application, and looks like a random alphanumeric string.

slackVerificationToken (String) : This string serves the same purpose as the signingSecret, but is considered less secure and could be deprecated by Slack at any point in time. We recommend updating your existing applications to using the signingSecret instead.

clientId (String) : This string is used for multi-tenant applications, when a user installs & authorizes your app on a new workspace. It is found in the Basic information page of your Slack application.

clientSecret (String) : This string is used for OAuth authorization, in conjunction with clientId. It is also found in the Basic information page of your Slack application.

botToken (String) : If your Slack application still uses legacy scopes, this token is needed to send multi-party conversations as a bot. It is found in the OAuth & Permissions page of your Slack application. This authentication method is discouraged as it might be deprecated by Slack in the future - we recommend Updating to Granular Scopes for your Slack application.


Aido application setup

slash (Object) : Here you must specify all the slash commands used in your aido application. These are provided in the following format : { commandname: CommandClass }. Be aware that the commandname part should match exactly with the slash command you configured on your Slask application (in this case the user would have to type /commandname to start the CommandClass slash).

You can alias a command by just reusing the same class with several names, as in the example below :

aido.init({
  slash: {
    commandname: CommandClass,
    commandalias: CommandClass,
  }
})

plugins (Array) : This is where you will provide all the plugins used by your aido application. The plugins will be initialized in the order they are provided.

const aidoGraphql = require('aido-graphql')
const aidoHook = require('aido-hook')

aido.init({
  plugins: [aidoGraphql, aidoHook],
})

persistentStorage (Object or String): This option allows you to specify the database used by your aido application. It can take two forms :

  • If it is a String, then it should contain the path to a SQLite database. If it doesn't exist it will be created by aido. If persistentStorage is not set, then aido will default to a sessions.db file in the same path as your application's index.

  • If it is an Object, then it should be a knex-compatible connection configuration object. Compatible databases for Knex are PostgreSQL, MySQL and SQLite.

Other options

viewsFolder (String) : The absolute path of the folder containing your views. Defaults to ./views relative to your application's index.

viewsTemplateExtension (String) : The extension of the view templates in your viewsFolder. Defaults to pug.

getSlackProfile (Boolean) : If this option is true, then for each interaction with a user their complete Slack profile will be requested and exposed in the Slash class as this.user.slackProfile. Bear in mind that the API endpoint used (users.info) is rate-limited ! If you expect a lot of requests we recommend storing the necessary information in your own database rather than the user's Slack profile. Defaults to false.