Learn how you can build your own plugins to customize and extend the Jovo Framework.
Plugins allow you to easily extend the Jovo Framework without having to mess with its core code and architecture.
Plugins allow you to "hook" into several parts of the request execution, called
middlewares. Here is a list of all available middlewares:
||First initialization of
||Raw JSON request from platform gets processed. Can be used for authentication middlewares.|
||Determines which platform (e.g.
||Natural language understanding (NLU) information gets extracted for built-in NLUs (e.g.
||Request gets routed through external NLU (e.g.
||Initialization of user object. User data is retrieved from database.|
||Request and NLU data (intent, input, state) is passed to router. intentMap and inputMap are executed. Handler path is generated.|
||Handler logic is executed. Output object is created and finalized.|
||User gets finalized, DB operations.|
||Platform response JSON gets created from output object.|
||Response gets sent back to platform.|
||Errors get handled if applicable.|
Download the plugin:
Enable it in your app:
Every plugin has to have an install function, which is used to hook up the plugin to the middlewares. It is also the point at which you can access the plugin's config (more on that later on).
While connecting the plugin to a middleware, you specify a function to be executed as soon as the request execution hits the specified middleware:
You can specify the configuration options of your plugin inside the
The default configuration is set inside the
config object of the plugin class:
Your user can change the configuration using the
config.js file inside their project using the following syntax:
The user's config will be merged with your default config and will be first accessible inside the
install() function (not the constructor) of your plugin using
Your function will receive the
handleRequest object as input, which has the following properties:
The first property is a reference to the current
app object. Here's an example from the
I18Next plugin, which uses the
app object to load the language files: here
The second property is the
host object (Lambda, Azure, ExpressJS, etc.), which has the following interface:
jovo object is the third property, which is the same object you reference inside your handler using
Depending on the middleware you use, the object can be
undefined, since the initialization happens inside the
The last one is the
error property, which wil be
undefined, unless the plugin is hooked up to the