The simplest way that worked for me was to copy the existing complete-module to a custom module say test-module.

Copy examples\module-templates\complete-module to modules\test-module location

Next stop was to modify modules\test-module\package.json with details like name and description.

Inside out\bp\data\global\botpress.config.json add below entry, to register and enable your custom module

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

Open a terminal in modules\test-module location, run yarn && yarn build and start Botpress yarn start

Choose any bot in your workspace and you should see test-module on the side bar.

Congratulations you have created your very own custom module.

Note: Using Botpress v12.0.5

Troubleshooting module-builder error

If you encounter below errors, then most probably the Botpress source is missing (dev tools), you must build the source.

$ ./node_modules/.bin/module-builder build
'.\node_modules\.bin\module-builder' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

All modifications and customization needs the below 2 steps, module builder is not included in the shipped binary (no dev tools are present, the reason being the binary size would increase)

  1. Clone the repository https://github.com/botpress/botpress
  2. Build using yarn && yarn build

Reference: https://botpress.io/docs/advanced/custom-module/


Simon

I am a Fullstack developer and Consultant with an experience of 9+ years in the industry. I mainly work on Java, React, Javascript, NodeJs, Elasticsearch and Botpress.

12 Comments

Kenneth Kaigu · August 3, 2019 at 7:05 pm

Great tutorial…

What kind of custom module can you create ?

    Abhishek Simon · August 3, 2019 at 7:46 pm

    Thank you, so far I have created a few chart.js components, customized scrollable card and a rating component.
    Few other components like datatable, calendar date picker are some components that I will be creating in some days.

Joey Stella · August 9, 2019 at 9:53 pm

I am trying to do this; however, my terminal does not recognize ‘yarn’ commands, when it is in the module. Do you know how to solve this problem?

    Abhishek Simon · August 10, 2019 at 12:36 am

    Check whether yarn is present in your path.

      Joey Stella · August 14, 2019 at 8:15 pm

      So, if you are trying to create a fully custom module, do you need to move botpress-master into whatever version of botpress you are using? Because I have not been able to figure that part out.

Abhishek Simon · November 17, 2019 at 8:35 pm

@Joey Stella: Botpress-master is the source where you create your custom module and components. You can keep your custom module as a shared folder between all your Botpress source/binaries and refer them and it should work.

Also, check out the latest post, it might help you further.
https://abhisheksimon.wordpress.com/2019/11/17/upgrading-bot-to-latest-botpress-version/

Anil · November 19, 2019 at 4:23 pm

I am getting the same error >>>
$ ./node_modules/.bin/module-builder build
‘.\node_modules\.bin\module-builder’ is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
Can you please tell what I need to do to solve this…

Abhishek Simon · November 19, 2019 at 7:12 pm

@Anil Are you trying to build from binary, as it will not work? Please follow the last 2 steps mentioned in this guide. 1. clone from the repository then run “yarn && yarn build”

Anil · December 4, 2019 at 12:08 pm

How to include dev tools that are missing in the existing botpress withourt cloning the entire repo.If possible Can you add a video of creating module and creting custom component,That would be very heplful

    Abhishek Simon · December 4, 2019 at 8:53 pm

    @Anil The process is, create a custom module in the source (Github) once you are satisfied, use it in the binary, for your deployment purposes. If you follow the steps exactly mentioned in this post, you will be able to create your own custom module. Next, you can follow the exact steps mentioned in “How to create a custom component in Botpress?”.

    If you still feel something is missing do let me know, will try to clarify your doubts.

    At present, I am unable to create any videos due to work-related commitments.

How to create a wrapper over dialog in Botpress? – Abhishek Simon · August 2, 2019 at 2:18 pm

[…] infa-module is my custom module, all customizations are done under this module. Read through this blog and create your own custom […]

How to create a custom component in Botpress? – Abhishek Simon · August 6, 2019 at 2:59 pm

[…] jump in to create our custom component, one needs to create a custom module. Please follow along this guide to create your custom module, then come back and […]

Leave a Reply

Your email address will not be published. Required fields are marked *