How to run bash commands in botpress

Hi guys,

What is the best way to make botpress run linux commands and return the result to the chat?
Botpress supports shelljs ? is there another way?

Please, help me

Hi @michelpeterson and welcome to the community

You can use an action or a hook, in which you can use whatever library you prefer.

Thanx for ur answer my friend, do u can detail it ? I’ve used action with this js code, i see it in console.log but it not return the result to botpress DM:

const { exec } = require(“child_process”);

const call = async () => {
const { data } = await exec(“ls -la”, (error, stdout, stderr) => {
if (error) {
console.log(error: ${error.message});
return;
}
if (stderr) {
console.log(stderr: ${stderr});
return;
}
console.log(stdout: ${stdout});
});
session.response = data
}
return call()

@michelpeterson

I didn’t test, but I guess you should add the node_modules as hinted there

If you want to include other dependencies not already included, there are two possible ways. You can add the node_modules folder containing your dependency in the same folder as your action, or you can create a module that includes your dependency.