External modules in Hooks


Hi guys! I have a doubt, I think it is very basic, but I can not find it in the documentation.

I’m creating hooks in version 11 and I need to include modules for the hooks. Do I have to include the node_modules folder as explained for the actions? Or can not I do this on the hooks?

I need to add logic that interacts with different APIs that uses Crypto for example. What is the correct way to do it?

Thank you!

1 Like

Hello @lmoralejo, there are two different ways you can provide dependencies for your hooks.

As you may have read in the documentation, the first one is to add a node_modules folder directly in the same folder as your hook. That’s not very efficient, not portable, and it’s the least recommended method.

The best way to proceed is to create a module, add any dependency you need, and add your hooks to your module. When Botpress is processing hooks or actions, it first looks for node modules in the current folder. If the dependency is not found, it will look in the node_modules of the module. Then, it will finally checks in the node_modules of botpress itself.

The documentation is lacking about that subject, but i’m taking notes to make this part clearer very soon. We have a complete module example which is coming in next update, which is due max friday.


Hi Allardy! any news about next update?


@lmoralejo Yes, it was release sunday. Here’s a link to our examples, check the complete module one: https://github.com/botpress/botpress/tree/master/examples


Thanks @allardy! I’ll look at it ASAP!


Hi @allardy sorry for my question of begginner, but I don’t understand.

I’m using the bp.exe v11.8.1.

I has used the complete-module (https://github.com/botpress/botpress/tree/master/examples/module-templates/complete-module) and followed the next steps:

1. Copy the folder  `examples/module-templates/complete-module`  to  `modules/complete-module`
2. Open a terminal in the folder  `modules/complete-module`  and type  `yarn && yarn build`
3. Edit your  `botpress.config.json`  and add the module definition so it will be loaded:

{ ... "modules": [ ... { "location": "MODULES_ROOT/complete-module", "enabled": true }, }

4. Start Botpress:  `yarn start`

In the step 2, shows:
error Package "module-builder" refers to a non-existing file '"{project_path}\\build\\module-builder"'

Then I copied the ‘builder’ folder in {project_path} and run again yarn && yarn build. This show several warnings & finally show the error:

$ ./node_modules/.bin/module-builder build
".\node_modules\.bin\module-builder" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.
error Command failed with exit code 1.

I don’t know that I’m doing wrong. Can you help me?

To create a new module, Should I use the source code instead bp.exe?



@lmoralejo Yes, when you want to create a module, you need to checkout the github repository, because the module builder isn’t included in the shipped binary (there is no dev tools at all with it). Otherwise, it would be much bigger.

Quick steps:

  1. Clone the repository
  2. Build using yarn && yarn build
  3. Follow the same steps you just pasted

You should be all good then !


Ok, thanks @allardy! I’ll try and if any error ocurrs, I’ll let you know!



Hi @allardy!
I downloaded the code and I compiled the complete-module example, but when I do change on actions folders or rename the module, for example, the module compile well, but botpress start says:

ModuleLoader Error in module "renamed-module" onServerStarted [Error, EISDIR: illegal operation on a directory, read]
Error: EISDIR: illegal operation on a directory, read

I don’t know what I am doing wrong. Can you help me? I’m beginner with BP11 & typescript.

Thanks in advance.