Sometimes, there might be a need to use some value from existing databases like Oracle, Postgres, etc. In this tutorial, we will see how to use values from an existing Oracle database and later use it in our Botpress bot.
Let us create a simple bot that takes user id as input, checks for the user record in Oracle database and later displays the username.
Create a custom action (out\bp\data\global\actions\UserDBUtility.js) in Botpress code editor
/** * Saves or Retrieves data from Oracle DB * @title User DB Utility * @category Utility * @author Abhishek Raj Simon * @param {string} name - Only supports get/set operations * @param {string} key - Can contain any key against which value needs to be pushed to DB * @param {string} value - Can contain a any value that needs to be pushed to DB */ const userDBUtility = async (name, key, value) => { const userId = event.target const botId = event.botId const table = "users"; const knex = require('knex')({ client: 'oracledb', connection: { host: 'dbhost', user: 'dbuser', password: 'dbpass', database: 'dbname' }, useNullAsDefault: false, log: { warn(message) { console.log(message); }, error(message) { console.error(message); }, deprecate(message) { console.log(message); }, debug(message) { console.log(message); }, } }); if (knex) { user.param = value let query = "", response = false; if ('get' === name) { query = "select name from " + table + " where userid='" + value + "'"; } else if ('set' === name) { query = "insert into " + table + "(userid, name) values('" + key + "','" + value + "')"; } await knex.raw(query).on('query', function (data) { //A query event is fired just before a query takes place. Useful for logging all queries throughout your application. console.log("Executing: " + data.sql) }).then(function (data) { if (data.length == 1 && name === 'get') { console.log(data[0]["NAME"]) user.param = value user.data = data[0]["NAME"] user.userDbStatus = true; } else if (data.length == 1 && name === 'set') { user.data = undefined; user.userDbStatus = true; } else { user.data = undefined; user.userDbStatus = false; } }).catch(err => console.log(err)); } else { console.log("knex is not initialized"); } } return userDBUtility(args.name, args.key, args.value)
In our custom action UserDBUtility
we are initializing an Oracle DB connection using Knex and then we will use get
DB type operation to fetch data for the given user id.
We will pass 3 parameters to UserDBUtility
action. Please refer to the “UserDBUtility Property” screenshot.
- name: Type of DB operation, here allowed values are
get
andset
. - key: DB column name
- value: DB column value
Note: Please provide database connection parameters by replacing dbhost
, dbuser
, dbpass
and dbname
in UserDBUtility
action.
Knex is a SQL query builder for Postgres, MSSQL, MySQL, MariaDB, SQLite3, Oracle, and Amazon Redshift designed to be flexible, portable, and fun to use. Knex is available out of the box with Botpress. To use any of the above databases, we also need to install the respective database library. For our case we will use yarn add oracledb
. If you are using any other database, please use an appropriate command from the below list.
yarn add pg yarn add sqlite3 yarn add mysql yarn add mysql2 yarn add oracledb yarn add mssql
Once we get the response we are storing it inside user
, one of the memory variables supported by Botpress.
Here is the user
table content from Oracle database.
Now we will create our bot’s flow.
Let’s look at each node in the above screenshot
- The 1st node is a greeting node.
- The 2nd node waits for user input, calls our
UserDBUtility
custom action, later depending on the response received from database flow transitions to either Node 3 or Node 4. Please check the below screenshot for more information. - The 3rd node is a success node, where the record is found for the given user id and displayed before ending the flow.
- In case the user record is not found, flow is transitioned to the 4th node that is a failure node. The flow is then transitioned to a retry node.
- The 5th node is the retry node which always transitions to Node 2 to repeat tasks from step 2.
That’s it. This is how we use values from Oracle database in a Botpress bot. Let me know in the comment section if you have questions.
Here is a link to the exported bot.
55 Comments
Luiz Cesar Leite · March 3, 2020 at 10:26 pm
It was help full indeed 🙂
Thank you very much!
Simon · March 4, 2020 at 2:30 pm
@Luiz You are welcome, let me know if you need help on any other topic.
teddewees · March 11, 2020 at 6:17 am
Ӏt’s hard to come by knowledgeɑble people in this particular topic, bսt you sound luke
you know what you’re talkking aboᥙt! Thanks
Simon · March 12, 2020 at 9:05 pm
You are welcome.
kenneth kaigu · March 11, 2020 at 7:33 pm
Can you replicate this tutorial this with a mysql database?
Simon · March 12, 2020 at 9:07 pm
@kenneth It should be fairly simple just do yarn add mysql or mysql2 along with knex configuration changes and the steps should be same. Let me know how it goes.
monami · April 10, 2020 at 3:41 pm
Sorry I m unable to do it can tell me the steps with mysql
Simon · May 3, 2020 at 11:10 am
@monami Please have a look at below tutorial, let me know if this helps.
https://aabingunz.com/how-to-connect-to-mysql-database-using-botpress/
Saúl · June 2, 2020 at 7:37 am
i have a question, how can I use the “yarn add pg” commands?
Simon · June 2, 2020 at 7:59 am
You should install yarn. Check below getting started guide.
https://yarnpkg.com/lang/en/docs/getting-started/
Saúl · June 3, 2020 at 3:47 am
Hi again! I´ve used your code and ran the “install yarn pg” in the same folder as bp.exe and I cannot see the changes over my DB, Do you have a clue of what’s going on?
Simon · June 3, 2020 at 6:39 am
Yarn will only work on Botpress source that can be found here, check this Readme
https://github.com/botpress/botpress/blob/master/README.md
So, when you are developing your bot, use Botpress source and then install pg using yarn, once your bot is ready, then use the Botpress binary (bp.exe) to deploy your bot in production system.
Saúl · June 3, 2020 at 9:34 am
Sorry for this many questions but I really need to know 😅, I´ve clonesd the repository into my computer and ran yarn in that folder, my question is how do i put my bot there or how does the connection between this source and the binaries work, I’m really lost NGL
Saúl · June 3, 2020 at 4:04 am
If I’m using postgres, do I have to change anything from the code, I know I have to change “client” and the next variables but I still don’t get the info into my DB.
Simon · June 3, 2020 at 6:46 am
Take a look at below guide, it should work.
https://aabingunz.com/how-to-save-data-from-bot-to-postgres-db/
Try above tutorial, if you still face any issue I will help you.
Saúl · June 3, 2020 at 9:41 am
Can you plese help me with the installation process?
Saúl · June 3, 2020 at 10:05 am
I’ve followed a video to install botpress using command lines and it worked, the only thing its that it installed version 10 and I created my bot In version 12 (Via bp.exe), Its there a way to update that botpress installation (the one from CMD)?
Simon · June 3, 2020 at 10:46 am
Botpress 10x and 11x+ are totally different and 10x is not used anymore unless you want to live with older version as no update or support will be available for 10x. Please use 11x+, infact try the latest and greatest Botpress available.
Saúl · June 3, 2020 at 11:25 am
I did this, I downloaded the Source botpress that you send me, then I followed the commands in there to make it work (Yarn, yarn build and yarn start). To my surprise it worked, it gave me the same botpress admin login, I even changed the DB to postgres, the problem now its that it doesn’t let me create or import a bot it says:
“Cannot mount bot “e-sre” [Error, while processing content elements: Error: while computing elements of type “builtin_action-button” (element: undefined): TypeError: this.memDb(…).select(…).where(…).andWhere(…).then(…).each is not a function]
STACK TRACE …”
And now i cant build it anymore!
Simon · June 3, 2020 at 12:09 pm
Which version of Botpress are you using now? Looks like
builtin_action-button
is something newly introduced, which I haven’t used so far. If it’s a vanilla install then please raise a concern in Botpress community.Also try the following in sequence for a workaround
1. Start with a stable version, for me Botpress v12.2.1 worked and is working fine so far (almost 6 months)
2. Try creating a test bot in a vanilla installation (No postgres, just default SQLlite)
3. Try importing your bot in vanilla installation (No postgres, just default SQLlite)
4. Configure postgres if you want to
Saúl · June 4, 2020 at 12:09 am
I did exactly this nd its working fine so far!, thanks for your attention and again for your blog, it’s really useful. Thank you 😀
Saúl · June 4, 2020 at 2:28 am
I stumbled across another error, its with this Code, the DBUtility, when I try to connect to my database ii throws this error:
{ Error: connect ECONNREFUSED IP:Port
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
errno: ‘ECONNREFUSED’,
code: ‘ECONNREFUSED’,
syscall: ‘connect’,
address: ‘IP’,
port: Port }
I changed the address and Port values just to not show mine but in my console they´re the values of the postgres DB
Simon · June 4, 2020 at 10:36 am
Looks like it is unable to connect to your DB. Check if you are able to connect to it using a simple nodejs process.
ECONNREFUSED is returned by the connect() system call when the remote system or service is either not listening on the specified port or a firewall between you is making it appear so.
Saúl · June 4, 2020 at 2:48 am
I added “port: Port #” in the code you gave us and it accesed, the thing is that In the query section it uses “Userid” but my DB doesn’t have any column called like that, how can I edit the code to make it “Universa” so that I can specify the column that I want to fill bygiving the program the exact name as is in the DB?
Saúl · June 4, 2020 at 4:31 am
To synthesize my new problem:
1. I don’t use “userid” in my DB it has another name
2. I achieved to chage this by playing around with the entire function and changing the query a bit
3. It worked but, the DB has “Not null” columns so I have to fill the entire row at once using data from the user (in total I have 5 columns)
4. I need to fill them all at once at the end of my flow.
5. And to check them the user has to insert the “userid” (I don call it that way but let’s just use that for now) and the rest of the info has to be displayed
I don´t know anything about this programming language but I’m trying my best to understand your code and it would be really helpful if you help me. Thanks again.
Saúl · June 4, 2020 at 5:16 am
This is my code at least the beginning:
const userDBUtility = async (name, curp, fec_ven, fec_cit, hor_cit, lug_cit) => {
const userId = event.target
const botId = event.botId
const table = ‘usuarios’
const knex = require(‘knex’)({
client: ‘pg’,
connection: {
host: ‘localhost’,
port: ‘####’,
user: ‘postgres’,
password: ‘######’,
database: ‘DB’
},
useNullAsDefault: false,
log: {
warn(message) {
console.log(message)
},
error(message) {
console.error(message)
},
deprecate(message) {
console.log(message)
},
debug(message) {
console.log(message)
}
}
})
if (knex) {
user.param1 = curp
user.param2 = fec_ven
user.param3 = fec_cit
user.param4 = hor_cit
user.param5 = lug_cit
let query = ”,
response = false
if (‘get’ === name) {
query =
‘select ‘ +
fec_cit +
‘, ‘ +
hor_cit +
‘, ‘ +
lug_cit +
‘ ‘ +
‘from ‘ +
table +
” where column= ‘” +
curp +
“‘”
} else if (‘set’ === name) {
query =
‘insert into ‘ +
table +
” values(‘” +
curp +
“‘, ‘” +
fec_ven +
“‘, ‘” +
fec_cit +
“‘, ‘” +
hor_cit +
“‘, ‘” +
lug_cit +
“‘)”
}
Saúl · June 4, 2020 at 5:18 am
With that code, it no longer says the previous error but now it goes straight into error and stops
Simon · June 4, 2020 at 10:55 am
You are on the right track, but it would be much simpler if you go through some basics of nodejs, ES6/javascript tutorials.
Saúl · June 6, 2020 at 9:46 am
Hello Simon, me again :/
I’ve managed to store my info into the postgres DB, turns out that code that I showed you did work 😀
But know I have another problem, I can´t seem to be able to get it to be shown to the user via a Botpress message, I wanted to do something like “Your date is: data_DB” where “data_DB” it´s the info retrieved I tried using this code and your MySql version but I still can´t get it to work: Here´s mi code:
***********************************************************************************
const myAction = async (name, table, value1) => {
user.data = undefined
const knex = require(‘knex’)({
//Las siguientes variables son las que se necesitan para conectar a la DB
client: ‘pg’,
connection: {
host: ‘localhost’,
port: ‘####’,
user: ‘postgres’,
password: ‘XXXXX’,
database: ‘Pass’
},
useNullAsDefault: false,
log: {
warn(message) {
console.log(message)
},
error(message) {
console.error(message)
},
deprecate(message) {
console.log(message)
},
debug(message) {
console.log(message)
}
}
})
if (knex) {
//Here’s the start of the ‘get’ code
let query = ”
if (‘get’ === name) {
query = ‘select (col1, col2, col3) from ‘ + table + ‘ where key=’ + “‘” + value1 + “‘”
}
await knex
.raw(query)
.on(‘query’, function(data) {
console.log(‘Execution: ‘ + data.sql)
}) //Here’s The Beginning of my problems
.then(function(data) {
if (data.length > 0 && name === ‘get’) {
user.data = data[0][0][0][value1]
} else {
user.data = undefined
}
})
.catch(err => console.log(err))
} else {
console.log(‘There´s an error with Knex’)
}
}
return myAction(args.name, args.table, args.value1)
/** Your code ends here */
}
************************************************************************************
I’ve been all day trying and can´t get it, this is the last of my problems, but I need this.
Simon · June 6, 2020 at 1:40 pm
To show a dynamic message in Botpress where the message contain’s dynamic data from a database, you can use
replyToEvent
, check below snippet.const userId = event.target;
const botId = event.botId;
const channelId = event.channel;
const eventDestination = { target: userId, botId: botId, channel: channelId }
let content = user.data; //Assuming this contains your dynamic text.
const contentPayload = await bp.cms.renderElement('builtin_text', { text: content, typing: true }, eventDestination)
await bp.events.replyToEvent(eventDestination, contentPayload)
Let me know if this helps. Also, feel free to seek help, after you have given your fare share of tries, because that will help you understand your problem. Sometimes my availability is restricted due to other project commitments but I will try to help as soon as it is possible.
Saúl · June 6, 2020 at 8:42 pm
I don’t really get it, I’ve been reading knex.js guidelines and still can’t figuere it out, I just want the DB info as literal text you know? My idea is to show something like
“Your date is due to: ‘Database info'”
So I want to make this action to return as string variables the results of the ‘select’ query, and then use those variables just to show the user that info. I’m still searching for the solution, thanks for your time 😀
Simon · June 6, 2020 at 9:03 pm
By “Database info” do you mean the actual database connection details or a sql query response?
Saúl · June 6, 2020 at 10:21 pm
I mean the literal content of the column, like for example, I have a date stored in a varchar column (not DATE because i save the month’s name not number) and I want that value shown as text in a message, so what i meant it’s the query result, i want that info returned from the query shown to the user, just the value.
Simon · June 6, 2020 at 11:38 pm
Supposing you have a column name “datestr” in you database table then use
data[0]["datestr"]
to get the datestr value and then use replyToEvent to display this value in Botpress chat.Saúl · June 7, 2020 at 1:07 am
How should I apply the “replyToEvent” code that you gave me into my project or where do I put it?
Simon · June 7, 2020 at 1:12 am
Place it wherever you are getting data from database, preferably in your custom action.
Saúl · June 7, 2020 at 1:45 am
await knex
.raw(query)
.on(‘query’, function(data) {
console.log(‘Executing: ‘ + data.sql)
})
.then(function(data) {
if (data.length == 1 && name === ‘get’) {
console.log(data[0][‘fec_cit’])
user.param = value1
user.data = data[0][‘fec_cit’]
user.userDbStatus = true
}
})
.catch(err => console.log(err))
} else {
console.log(‘knex is not initialized’)
}
const userId = event.target
const botId = event.botId
const channelId = event.channel
const eventDestination = { target: userId, botId: botId, channel: channelId }
let content = user.data //Assuming this contains your dynamic text.
const contentPayload = await bp.cms.renderElement(‘builtin_text’, { text: content, typing: true }, eventDestination)
await bp.events.replyToEvent(eventDestination, contentPayload)
}
I Placed it there but still can’t get it to work
Saúl · June 7, 2020 at 1:58 am
This is the entire code:
function action(bp: typeof sdk, event: sdk.IO.IncomingEvent, args: any, { user, temp, session } = event.state) {
/** Your code starts below */
/**
* Obtiene información a una base de datos
* @title dbConGet
* @category Utility
* @authors Saúl Abraham Esparza Rivera
* @param {string} name – Identificador de Operación (get)
* @param {string} table – Nombre de la tabla donde se guardaran los datos
* @param {string} value1 – Destinado al CURP
*/
const myAction = async (name, table, value1) => {
const userId = event.target
const botId = event.botId
const channelId = event.channel
const eventDestination = { target: userId, botId: botId, channel: channelId }
const knex = require(‘knex’)({
//Las siguientes variables son las que se necesitan para conectar a la DB
client: ‘pg’,
connection: {
host: ‘localhost’,
port: ‘####’,
user: ‘postgres’,
password: ‘XXXX’,
database: ‘Pass’
},
useNullAsDefault: false,
log: {
warn(message) {
console.log(message)
},
error(message) {
console.error(message)
},
deprecate(message) {
console.log(message)
},
debug(message) {
console.log(message)
}
}
})
if (knex) {
let query = ”
if (‘get’ === name) {
query = ‘select fec_cit, hor_cit, lug_cit from ‘ + table + ‘ where curp=’ + “‘” + value1 + “‘”
}
await knex
.raw(query)
.on(‘query’, function(data) {
console.log(‘Executing: ‘ + data.sql)
})
.then(function(data) {
if (data.length == 1 && name === ‘get’) {
console.log(data[0][‘fec_cit’])
user.param = value1
user.data = data[0][‘fec_cit’]
user.userDbStatus = true
}
})
.catch(err => console.log(err))
} else {
console.log(‘knex is not initialized’)
}
let content = user.data //Assuming this contains your dynamic
const contentPayload = await bp.cms.renderElement(‘builtin_text’, { text: content, typing: true }, eventDestination)
await bp.events.replyToEvent(eventDestination, contentPayload)
}
return myAction(args.name, args.table, args.value1)
/** Your code ends here */
}
Saúl · June 7, 2020 at 2:02 am
Given that code, how I’m I suppose to get the info into a message? Using user.data?
Saúl · June 3, 2020 at 6:30 am
Now, if Im testing a postgres DB what should I change?
ปั๊มไลค์ · June 6, 2020 at 10:19 pm
Like!! I blog frequently and I really thank you for your content. The article has truly peaked my interest.
nanda · August 6, 2020 at 2:47 pm
The connection to oracle db is not working for me throws knex run exception as bellow
Error: Knex: run
$ npm install oracledb –save
Cannot find module ‘oracledb’
1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in ‘require’ call. 2) If you don’t want to compile the package/file into executable and want to ‘require’ it from filesystem (likely plugin), specify an absolute path in ‘require’ call using process.cwd() or process.execPath.
at Client_Oracledb.initializeDriver (C:\snapshot\build-windows\node_modules\knex\lib\client.js:232:13)
at Client_Oracledb.Client (C:\snapshot\build-windows\node_modules\knex\lib\client.js:66:10)
at Client_Oracledb.Client_Oracle (C:\snapshot\build-windows\node_modules\knex\lib\dialects\oracle\index.js:24:10)
at new Client_Oracledb (C:\snapshot\build-windows\node_modules\knex\lib\dialects\oracledb\index.js:16:17)
at Knex (C:\snapshot\build-windows\node_modules\knex\lib\knex.js:52:28)
at Object.base.apply (C:\snapshot\build-windows\node_modules\vm2\lib/contextify.js:439:32)
at userDBUtility (vm.js:15:33)
at Object. (vm.js:72:10)
at NodeVM.run (C:\snapshot\build-windows\node_modules\vm2\lib\main.js:428:23)
at runInVm.Promise (C:\snapshot\build-windows\out\bp\core\services\action\vm.js:0:0)
at Promise._execute (D:\rite_work\botpress-v12\modules\.cache\module__bffbc03eb11541e2f2609cc4891a9d0a9e10e1fc6a4add9a1fa1acc9d5b2062c\node_production_modules\bluebird\js\release\debuggability.js:384:9)
at Promise._resolveFromExecutor (D:\rite_work\botpress-v12\modules\.cache\module__bffbc03eb11541e2f2609cc4891a9d0a9e10e1fc6a4add9a1fa1acc9d5b2062c\node_production_modules\bluebird\js\release\promise.js:518:18)
at new Promise (D:\rite_work\botpress-v12\modules\.cache\module__bffbc03eb11541e2f2609cc4891a9d0a9e10e1fc6a4add9a1fa1acc9d5b2062c\node_production_modules\bluebird\js\release\promise.js:103:10)
at VmRunner.runInVm (C:\snapshot\build-windows\out\bp\core\services\action\vm.js:0:0)
at ScopedActionService. (C:\snapshot\build-windows\out\bp\core\services\action\action-service.js:0:0)
at Generator.next ()
at __awaiter (C:\snapshot\build-windows\out\bp\core\services\action\action-service.js:0:0)
at Promise._execute (D:\rite_work\botpress-v12\modules\.cache\module__bffbc03eb11541e2f2609cc4891a9d0a9e10e1fc6a4add9a1fa1acc9d5b2062c\node_production_modules\bluebird\js\release\debuggability.js:384:9)
at Promise._resolveFromExecutor (D:\rite_work\botpress-v12\modules\.cache\module__bffbc03eb11541e2f2609cc4891a9d0a9e10e1fc6a4add9a1fa1acc9d5b2062c\node_production_modules\bluebird\js\release\promise.js:518:18)
at new Promise (D:\rite_work\botpress-v12\modules\.cache\module__bffbc03eb11541e2f2609cc4891a9d0a9e10e1fc6a4add9a1fa1acc9d5b2062c\node_production_modules\bluebird\js\release\promise.js:103:10)
at __awaiter (C:\snapshot\build-windows\out\bp\core\services\action\action-service.js:0:0)
at ScopedActionService._runInVm (C:\snapshot\build-windows\out\bp\core\services\action\action-service.js:0:0)
at ScopedActionService. (C:\snapshot\build-windows\out\bp\core\services\action\action-service.js:0:0)
at Generator.next ()
at fulfilled (C:\snapshot\build-windows\out\bp\core\services\action\action-service.js:0:0)
at tryCatcher (D:\rite_work\botpress-v12\modules\.cache\module__bffbc03eb11541e2f2609cc4891a9d0a9e10e1fc6a4add9a1fa1acc9d5b2062c\node_production_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (D:\rite_work\botpress-v12\modules\.cache\module__bffbc03eb11541e2f2609cc4891a9d0a9e10e1fc6a4add9a1fa1acc9d5b2062c\node_production_modules\bluebird\js\release\promise.js:547:31)
at Promise._settlePromise (D:\rite_work\botpress-v12\modules\.cache\module__bffbc03eb11541e2f2609cc4891a9d0a9e10e1fc6a4add9a1fa1acc9d5b2062c\node_production_modules\bluebird\js\release\promise.js:604:18)
at Promise._settlePromiseCtx (D:\rite_work\botpress-v12\modules\.cache\module__bffbc03eb11541e2f2609cc4891a9d0a9e10e1fc6a4add9a1fa1acc9d5b2062c\node_production_modules\bluebird\js\release\promise.js:641:10)
at _drainQueueStep (D:\rite_work\botpress-v12\modules\.cache\module__bffbc03eb11541e2f2609cc4891a9d0a9e10e1fc6a4add9a1fa1acc9d5b2062c\node_production_modules\bluebird\js\release\async.js:97:12)
at _drainQueue (D:\rite_work\botpress-v12\modules\.cache\module__bffbc03eb11541e2f2609cc4891a9d0a9e10e1fc6a4add9a1fa1acc9d5b2062c\node_production_modules\bluebird\js\release\async.js:86:9)
at Async._drainQueues (D:\rite_work\botpress-v12\modules\.cache\module__bffbc03eb11541e2f2609cc4891a9d0a9e10e1fc6a4add9a1fa1acc9d5b2062c\node_production_modules\bluebird\js\release\async.js:102:5)
at Immediate.Async.drainQueues (D:\rite_work\botpress-v12\modules\.cache\module__bffbc03eb11541e2f2609cc4891a9d0a9e10e1fc6a4add9a1fa1acc9d5b2062c\node_production_modules\bluebird\js\release\async.js:15:14)
at runCallback (timers.js:696:18)
at tryOnImmediate (timers.js:667:5)
at processImmediate (timers.js:649:5)
at process.topLevelDomainCallback (domain.js:121:23)
what shall i do now, could you pleae help me.
Simon · August 7, 2020 at 11:50 am
@nanda Let me try this at my end and I will share a tutorial for the same in couple of days.
Simon · August 8, 2020 at 12:54 pm
@nanda: Use a fresh Botpress installation and follow this tutorial exactly. You should be able to do it. I see that you used npm install oracledb. Please do not mix yarn and npm together. In this tutorial I am using yarn add oracledb
nanda · August 12, 2020 at 10:23 pm
yarn add oracledb to be execute the command in the bp.exe dir?
after executing the yarn i need to start bp and develop my bot right?
nanda · August 12, 2020 at 11:05 pm
@simon still am getting the same error, got latest bp and after starting executed the yarn in new cmd and followed this tutorial, this time i have not used npm
Simon · August 13, 2020 at 11:53 am
@nanda Since you are developing use this.
yarn add oracledb
will work with this under the working directory of botpress. Once you are done with your development you should deploy your bot using this which will have bp.exe in a windows build.Pooja · June 7, 2021 at 6:01 pm
Hello..Aactually i follow this document and create flow…But im not getting username…..I have used postgres db.Thanks in advance
pooja dendge · June 9, 2021 at 1:37 pm
I follow this all steps and trying to create postgres db connection im not getting userid…in flow it goes to record not found???
K · September 20, 2021 at 2:18 am
Hello,
I am getting stuck on the step where you run yarn add pg. I run the command in the botpress source root folder and get the following error:
“error Running this command will add the dependency to the workspace root rather than the workspace itself, which might not be what you want – if you really meant it, make it explicit by running this command again with the -W flag (or –ignore-workspace-root-check).”
I tried overriding this error and running it anyway, but then the project wouldn’t build anymore, so I ran yarn remove pg to undo it, and the project would build again.
What am I doing wrong?
Kuleena · October 18, 2021 at 1:14 pm
Hi,I am very new to chatbots and also botpress.I am trying to integrate the botpress with oracle database.
As per your tutorial,it says “we also need to install the respective database library. For our case we will use yarn add oracledb.” Please can you provide steps on how to install the database library.
Thank You in advance.
Anna · October 31, 2021 at 7:09 pm
Thanks for the article.
I am getting the below error.Please can you help me on the same
Knex: run
$ npm install oracledb –save
Cannot find module ‘oracledb’
Require stack:
– C:\snapshot\build-windows\node_modules\knex\lib\dialects\oracledb\index.js
– C:\snapshot\build-windows\node_modules\knex\lib\knex.js
– C:\snapshot\build-windows\node_modules\knex\lib\index.js
– C:\snapshot\build-windows\node_modules\knex\knex.js
– C:\snapshot\build-windows\packages\bp\dist\core\database\index.js
– C:\snapshot\build-windows\packages\bp\dist\core\bpfs\drivers\db-driver.js
– C:\snapshot\build-windows\packages\bp\dist\core\bpfs\ghost-service.js
– C:\snapshot\build-windows\packages\bp\dist\core\bpfs\index.js
– C:\snapshot\build-windows\packages\bp\dist\core\config\config-loader.js
– C:\snapshot\build-windows\packages\bp\dist\core\config\index.js
– C:\snapshot\build-windows\packages\bp\dist\core\bots\bot-monitoring-service.js
– C:\snapshot\build-windows\packages\bp\dist\core\bots\index.js
– C:\snapshot\build-windows\packages\bp\dist\core\app\api.js
– C:\snapshot\build-windows\packages\bp\dist\core\app\inversify\app.inversify.js
– C:\snapshot\build-windows\packages\bp\dist\core\app\core-loader.js
– C:\snapshot\build-windows\packages\bp\dist\core\app\bootstrap.js
– C:\snapshot\build-windows\packages\bp\dist\index.js
1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in ‘require’ call. 2) If you don’t want to compile the package/file into executable and want to ‘require’ it from filesystem (likely plugin), specify an absolute path in ‘require’ call using process.cwd() or process.execPath.
Error: Cannot find module ‘oracledb’
Require stack:
Simon · December 13, 2021 at 2:45 pm
I never encountered this error. Can you try solution provided in this link? https://stackoverflow.com/a/51413753
Anna · December 29, 2021 at 2:37 pm
Sorry,the url https://stackoverflow.com/a/51413753 didn’t help.
I get the above error when I run the emulator in the chatbot.
Do the oracle Client and the bp.exe needs to be in the same folder?
Please could you provide the steps.
I have run the npm install oracledb and yarn add oracledb from the cmd and there is no error.
Thank You.
Simon · January 23, 2022 at 1:27 pm
It seems you have mixed npm and yarn together. Can you create a clean workspace and just use yarn (as most of the tutorials on my site and Botpress site are using yarn). Then follow the following steps
1. Build Botpress
yarn && yarn build
2. Run Botpress once
3. See if it is coming fine.
4. Install oracledb by running
yarn add oracledb
from the same directory where you ran build command for Botpress.Let me know how it goes. Also which version of node are you using. I have tried node