Skip to main content

Use Botonic Plugins

Botonic offers several plugins. To use one of the available Botonic plugins, you must:

  • Add a plugins.js file in your Botonic project at the root of src.
  • Require every plugin you want to be executed every time the input is processed.
  • Import your plugins in src/index.js.

src/index.js

export { routes } from './routes'
export { locales } from './locales'
export { plugins } from './plugins'
export { webchat } from './webchat'
export { webviews } from './webviews'

src/docs/plugins.js

export const plugins = [
{
id: 'luis',
resolve: require('@botonic/plugin-luis'),
options: {
region: 'YOUR_REGION',
appID: 'YOUR_APP_ID',
endpointKey: 'YOUR_ENDPOINT_KEY',
},
},
]

After this is done, you will have your plugins running!

If for any reason, you need to access the plugin within your bot actions, you can also access and run them by the id you have defined when requiring your plugins, as shown in the example:

import React from 'react'
import { Text } from '@botonic/react'
import { RequestContext } from '@botonic/react'

export default class extends React.Component {
static contextType = RequestContext

static async botonicInit({ input, session, params, lastRoutePath, plugins }) {
let { dialogflow } = plugins
await dialogflow.pre({ input, session, lastRoutePath })
// Your stuff
}

render() {
// Your rendered components
}