How to implement an interface in your integration
Finding the interface to implement
Unfortunately, interfaces aren’t yet listed on our website, so you must find them in the Botpress GitHub repository. To find the interface you want to implement, follow these steps:
Open the interfaces directory
Navigate to the interfaces directory of the botpress/botpress repository.
Adding the interface as a dependency
Once you have the interface name and version, you can add it as a dependency to your integration:
Add the dependencies section
If there is no bpDependencies section in your integration’s package.json file, create one:
{
"bpDependencies": {}
} Add the interface as a dependency
In the bpDependencies section, add the interface name and version as a dependency. For example, with an interface named creatable and version 0.0.1, you would add the following:
{
"bpDependencies": {
"creatable": "interface:creatable@0.0.1"
}
}It’s very important to follow this syntax:
"<interface-name>": "interface:<interface-name>@<version>".
Install the interface
Now that you have added the interface as a dependency, you can run the bp add command to install it. This command will:
- Download the interface from Botpress.
- Install it in a directory named
bp_modulesin your integration’s root directory.
Adding a helper build script
To keep your integration up to date, we recommend adding a helper build script to your integration:
Now, whenever you run npm run build, it will automatically install the interface and build your integration. This is useful for ensuring that your integration is always up to date with the latest version of the interface.
Adding the interface to your integration definition file
Now that the interface is installed, you must add it your integration definition file in order to implement it.
Next steps
Since each interface has its own specific requirements, you should refer to the interface documentation for more information.