External modules in Hooks


#1

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!


#2

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.


#3

Hi Allardy! any news about next update?


#4

@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


#5

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