0

I have a (Botpress Framework v.10.51.1) bot and I have a botpress-module installed and linked to the bot, I wanted to debug the code in the botpress-module using vscode debugger,

I added the following to my vs-code launch.json and started my bot with the command npm start --debug

{
    "type": "node",
    "request": "launch",
    "name": "Launch Program",
    "cwd": "${workspaceRoot}",
    "port": 5859,
    "program": "${workspaceRoot}/node_modules/botpress/bin/botpress",
    "runtimeExecutable": "node",
    "runtimeArgs": [
        "--debug"
    ],
    "args": [ "start" ],
    "stopOnEntry": false
}

It's still not launching the debugger in vscode , What am i missing ? How do I do this?

Mahesh Kumaran
  • 887
  • 2
  • 12
  • 30

2 Answers2

1

It's hard to tell why it doesn't work on Botpress 10...

However, if you clone the latest version of the Botpress repo (12.0.1), you'll find the following launch.json file:

{
"version": "0.2.0",
"configurations": [
    {
     "type": "node",
     "runtimeVersion": "10.11.0",
     "request": "launch",
     "name": "Debug App",
     "program": "${workspaceFolder}/out/bp/index.js",
     "cwd": "${workspaceFolder}",
     "args": ["start"],
     "protocol": "auto",
     "env": {
       "BP_MODULES_PATH": "${workspaceFolder}/modules:${workspaceFolder}/internal-modules",
     "NODE_PATH": "${workspaceFolder}/out/bp",
     "DEBUG": "bp:*"
    },
    "smartStep": true,
    "outFiles": [
      "${workspaceFolder}/out",
      "${workspaceFolder}/modules/*/dist",
      "${workspaceFolder}/private-modules/*/dist",
      "!${workspaceFolder}/**/node_modules"
    ],
    "console": "integratedTerminal",
    "sourceMaps": true,
    "autoAttachChildProcesses": true
    }
  ]
}

Which works great for debugging the backend part of modules. It only requires you to start debugging with vscode using the "F5" key or by going to "Debug > Start Debugging".

I hope this information helps.

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
  • Hey , Thanks for the help, I have gone a long way using version 10.50 and I am still unable to debug , although botpress doesn't support X version anymore , I have built a couple custom modules and runs on production servers. – Mahesh Kumaran Jan 23 '20 at 20:50
0

@Mahesh VSCode allows you to easily debug Botpress. I have created a tutorial that can help understand what are the different ways you can debug a problem in Botpress.

We will use VSCode debugging and Botpress logging capability to find and resolve bugs in our bot

Let us try to debug this, by adding 3 additional statements debugger, console.log & bp.logger.info in our ValidateEmailSignature custom action.

Please checkout below tutorials for more information

https://youtu.be/89dFPVbXxCw

https://aabingunz.com/debugging-in-botpress/

AabinGunz
  • 12,109
  • 54
  • 146
  • 218
  • A link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted.](//stackoverflow.com/help/deleted-answers) –  Aug 05 '20 at 16:56
  • @Daniil: Thank you for your comment, I will keep it in mind. I added a context and quote from the link. – AabinGunz Aug 24 '20 at 08:34
  • @AabinGunz Thanks for posting out ! Unfortunately I was looking to debug Botpress v10. Have migrated them to v12. Thanks ! – Mahesh Kumaran Feb 23 '21 at 14:54