Expose an API goes wrong


Hello i am following the following tutorial : https://botpress.github.io/en/docs/modules/api/

i have created an module called botpress-webhook

i have made an module and in this module index file i have added the code :

module.exports = {
  config: {},

  // eslint-disable-next-line no-unused-vars
  init: async (bp, configurator, helpers) => {
    // This is called before ready.
    // At this point your module is just being initialized, it is not loaded yet.

  // eslint-disable-next-line no-unused-vars
  ready: async (bp, configurator, helpers) => {
    var router = bp.getRouter('botpress-webhook');

    // Will be exposed at: http://localhost:3000/api/botpress-webhook/ping
    router.get('/ping', (req, res, next) => res.send('pong'))

    // eslint-disable-next-line no-unused-vars
    const config = await configurator.loadAll()
    // Do fancy stuff here :)

now in mij bot project package.json file i added my module
when i start my bot it says Loaded botpress-webhook, version 1.0.0

problem is if i go to the url : http://localhost:3000/api/botpress-webhook/ping i get the response
Cannot GET /api/botpress-webhook/ping
am i missing an step?


Are you sure you recompiled your module after making changes?


I am experiencing the same issue. What debug can I add to determine if the router has been setup correctly?


Try adding console.log('------------------') to the initialization script: if it doesn’t show up in server-console - then it doesn’t get executed at all.