Finding the interface to implement

Unfortunately, interface are not 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:

1

Open the interfaces directory

Navigate to the interfaces directory of the botpress/botpress repository.

2

Find the interface

Find the interface you want to implement and open its directory.

3

Find the name and version

Open the interface.definition.ts file to find the interface name and version.

Adding the interface as a dependency

Once you have the interface name and version, you can add it as a dependency to your integration:

1

Open the package.json file

Open your integration’s package.json file.

2

Add the bpDependencies section

If there is no bpDependencies section in your integration’s package.json file, create one:

{
  "bpDependencies": {}
}
3

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:[email protected]"
  }
}

It is very important to follow this syntax:
"<interface-name>": "interface:<interface-name>@<version>".

4

Save the package.json file

Save the package.json file.

5

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_modules in 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:

1

Open the package.json file

Open your integration’s package.json file.

2

Add the build script

In the scripts section, add the following script:

{
  "scripts": {
    "build": "bp add -y && bp build"
  }
}

If the build script already exists in your package.json file, please replace it.

3

Save the package.json file

Save the package.json file.

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.

1

Open the integration.definition.ts file

Open your integration’s integration.definition.ts file.

2

Import the interface

At the top of the file, import the interface. For example, with an interface named creatable, you would add the following import statement:

import creatable from './bp_modules/creatable'
3

Extend your definition

Use the .extend() function at the end of your new IntegrationDefinition() statement. For example, with an interface named creatable, you would add the following:

export default new sdk.IntegrationDefinition({
  ...
})
  .extend(creatable, () => ({}))

Next steps

Since each interface has its own specific requirements, you should refer to the interface documentation for more information.