https://discord.gg/botpress logo
#🤝help
Is it possible to export the data of the tables of Botpress automatic, not with the export csv
# 🤝help
m

modern-honey-58818

01/04/2024, 3:32 PM
I want my bot to export one time per week with a Fixed Schedule Trigger the data of one of my tables, is it possible to do it?
c

crooked-van-25152

01/04/2024, 3:47 PM
@early-train-33247 would you happen to know if it's possible and how?
m

modern-honey-58818

01/04/2024, 3:48 PM
I saw that maybe with Zapier I can, but I don't know
Hope @early-train-33247 or @quick-musician-29561 knows something about this
q

quick-musician-29561

01/04/2024, 4:06 PM
Great idea! ⭐ I have done something similar with Make.com, there are many good tutorials here already. But if you want to use it weekly with a Fixed Schedule Trigger, there are still some minor issues with cron (at least for me) https://discord.com/channels/1108396290624213082/1177356079496179772
m

modern-honey-58818

01/04/2024, 4:08 PM
Oh I was looking for some tutorial but I only found some to import tables to Botpress, I want to export them
q

quick-musician-29561

01/04/2024, 4:11 PM
yes, I think most to them are that way
There's one from @jolly-policeman-82775 ⚡ and @bland-agent-12616 🦸‍♂️
@modern-honey-58818 Now that you mentioned it, I can also go back to practice cron in Botpress, and try to export KB tables once a week to Google sheets.
m

modern-honey-58818

01/04/2024, 4:16 PM
I will try it tomorrow too, I will keep you noticed if I'm able to do here!!
e

early-train-33247

01/04/2024, 4:21 PM
It's definitely possible with the Triggers!
Let us know if you guys can make it!
q

quick-musician-29561

01/05/2024, 3:59 PM
Did you get cron to work with Botpress? 💡 🛠️
j

jolly-policeman-82775

01/05/2024, 4:02 PM
wow, my tutorials are getting shared a lot now loll
next up im going to do a tutorial on setting users language via 3 ways
c

crooked-van-25152

01/05/2024, 4:26 PM
Hey @jolly-policeman-82775 ! You know there's already a video on this right?

https://youtu.be/fBwSLPbPqn8?si=-zLn-dUysxdjYTct

j

jolly-policeman-82775

01/05/2024, 4:28 PM
im doing updated versions
beucase thats kind of a difficult way of understanding
i did something new with code
c

crooked-van-25152

01/05/2024, 4:36 PM
An updated version is a good idea 🙂
with the new UI
j

jolly-policeman-82775

01/05/2024, 4:37 PM
yes
q

quick-musician-29561

01/05/2024, 7:15 PM
Based on my testing, Fixed Schedule/Cron Expression always gives an error, which I have posted in other threads on the subject. We are not in a hurry, but if at some point the professionals in the Botpress team take the time to see if it works properly in Botpress, and how to do it, then I'll be able to help others with that again 🫡 I have tried all kinds of tricks with conversationId and channel, but Fixed Schedule Trigger loses context every time it runs (everything works perfectly when Fixed Schedule is taken off).
"always gives an error" actually not always, I can log things to console with that 😆 but nothing else
I use Linux servers in my work every day and run tasks with cron, and it's one of the easiest things to do on Linux servers. I don't know why I can't understand it with Botpress 🤷‍♂️
e

early-train-33247

01/05/2024, 8:40 PM
Okay I am not aware of that issue, but I'll try to reproduce it and let you know!
q

quick-musician-29561

01/05/2024, 8:44 PM
Thank you! When you are not busy 🫡
I don't have a use case for cron (yet), but I think all simple examples that work, will help many bot builders A LOT
We could have used it with @wide-oyster-38514 in one of his ideas for Hub template (limited daily/weekly messages), but then we solved it differently
Error logs one hour ago:
Copy code
json
Error sending outgoing message {
  integration: 'schedulev1',
  messageType: 'text',
  payload: '{"type":"text","text":"Sorry, an error occurred. Please try again later","typing":true}',
  error: It [Error]: request/body must have required property 'conversationId'
      at Bc (/var/task/customer_code.js:11:62529)
      at Nt (/var/task/customer_code.js:11:62351)
      at R (/var/task/customer_code.js:11:71961)
      at /var/task/customer_code.js:11:64329
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async Object.flushSendMessages (/var/task/customer_code.js:620:10205)
      at async Object.processEvent (/var/task/customer_code.js:641:1912)
      at async processErrorFlow (/var/task/customer_code.js:641:4162)
      at async runDialogEngine (/var/task/customer_code.js:641:3991)
      at async startEventProcessing (/var/task/customer_code.js:641:3525) {
    isApiError: true,
    code: 400,
    description: 'The request payload is invalid.',
    type: 'InvalidPayload',
    error: undefined,
    id: 'err_20240105190137xE0D80E62'
  }
}
Without Fixed Schedule, everything works. With Fixed Schedule, "request/body must have required property 'conversationId'"
this no one has solved yet
I'm guessing the most requested features with Fixed Schedule and cron here are: - send message/reminder to chatbot user (they have decided the cron schedule) - give user new messages (daily cron schedule) - send KB table data to Make.com + Google sheets (weekly)
If we can get some help how cron works in Botpress, we can continue from there 🔥 🛠️
I have not been able to solve it, so I have followed this method ⚡ How to Build AI Chatbots in 2024 - Turning Your Bugs into Features 🛠️
I spent so many hours on this yesterday without any success. However, now I feel like I'm finally making progress.
bug 👾 (not in Botpress, but in my chatbot)
same thing as a feature 🤖
Simple example, but that's how we learn
Copy code
js
console.log("hello every minute!")

await Data1Table.createRecord({ Name: 'Jack Black'})
After publishing, now it just logs "hello every minute!" and also stores new data into KB table every minute
I guess the triggers are still limited to running code and cannot send messages, which I knew because it always throws the error "conversationId needed". However, I tried using the triggers to execute code or send a JSON payload, which also needs a conversationId. And even though I provided them correctly (in the same way they work without triggers), I guess we can't use code that requires those with triggers (yet).
If my thoughts are correct, consider adding those limitations to docs also. I think that's what causes the most confusion, bot builders think that cron triggers work for every task. https://botpress.com/docs/cloud/toolbox/capture-information/#cron-schedule
Make.com scenario
I have the exact same data here as in Botpress KB table
Column fields Name, Age, City
then the same data goes from "Parse JSON" module to Iterator, takes the column data (Name, Age, City) from each row
Iterator is doing the same task, Add a Row, as many times as your KB table data has rows
In "Goole Sheets" module I use this
m

modern-honey-58818

01/08/2024, 1:31 PM
So now we need a webhook to receive the json from botpress
q

quick-musician-29561

01/08/2024, 1:31 PM
And when you run the scenario, Botpress KB table data goes into Google Sheets
Yes, this is the last missing piece in this (because I think cron schedule weekly works also with that)
I managed to send the data in a correct format from Botpress to Make.com last week, and the week before that. I know that because I built projects here that needed it, and it worked. But now for some reason it's not working, it seems that Google sheets needs the data in a different format. Luckily Make.com has several different tools for editing the data.
m

modern-honey-58818

01/08/2024, 1:36 PM
Maybe we need to JSON.parse the data table?
q

quick-musician-29561

01/08/2024, 1:37 PM
This is the correct format for KB table data to work with that scenario:
Copy code
json
[{"Name":"Jack Black","Age":35,"City":"Stockholm"},{"Name":"Tom Jones","Age":44,"City":"Tallinn"},{"Name":"Bob Marley","Age":22,"City":"London"}]
if you manage to get your data in that format to make.com, it should work
m

modern-honey-58818

01/08/2024, 1:39 PM
That's with JSON.stringify
I will screenshot this in a bit
q

quick-musician-29561

01/08/2024, 1:41 PM
Yes, I have tried both those, but still it doesn't work. It needs to be an array for Iterator to work, now I noticed that Webhook gives it as a Make.com Collection (not an array)
m

modern-honey-58818

01/08/2024, 1:43 PM
Should I send it to webhook like this and then in make create an Array?
q

quick-musician-29561

01/08/2024, 1:44 PM
That's exactly what I'm been trying to do also 🛠️
m

modern-honey-58818

01/08/2024, 1:45 PM
I will try with the array aggregator then
q

quick-musician-29561

01/08/2024, 1:45 PM
In my case it works already if there is only one object (one KB row) like this
Copy code
json
[{"Name":"Jack Black","Age":35,"City":"Stockholm"}]
if there is more, Make.com creates some 🧙‍♂️ Array of Collections 🪄 and it needs more work
the projects I have completed previously, all of them have sent only one user data etc. at a time, not the entire KB table with many rows for multiple users or conversations
m

modern-honey-58818

01/08/2024, 1:51 PM
Yep, me too, I was able one by one, but this is a new challenge
What about this module?
j

jolly-policeman-82775

01/08/2024, 1:58 PM
it repeats that funtion all over again
i think so 🤔
m

modern-honey-58818

01/08/2024, 1:59 PM
I think that too, so if the problem here is that it only insert one kb row, maybe we can do an easy do while or for loop
q

quick-musician-29561

01/08/2024, 1:59 PM
Thanks @jolly-policeman-82775 💎 I tried that also, something like that we'll need
j

jolly-policeman-82775

01/08/2024, 2:00 PM
heck yeah
q

quick-musician-29561

01/08/2024, 4:24 PM
Now it seems to be working
Store your KB data into a new object and send that object to Make.com
Copy code
js
const users = await Data1Table.findRecords({
  filter: AI`everything`
})
console.log(users)

let object = {
    "people": users
};

try {
  const response = await axios.post('xxxxxxxxxxxxxxxxxxxxxxxxxx', object)
// REPLACE XXXXX WITH YOUR WEBHOOK ADDRESS

  console.log("RESPONSE: " + response.data)
} catch (error) {
  console.error(error)
}
then you have your KB data in Webhook
and all KB table data goes to Google sheets
@modern-honey-58818 let us know if this works for you 🛠️ 👍
next I'm going to try the same but with also weekly cron schedule, and add another module in Make.com scenario where it always empties first the Google sheet, then replaces the same sheet with the latest data
e

early-train-33247

01/09/2024, 3:53 AM
Thanks a lot for the detailed steps @quick-musician-29561!! 🦾
@acceptable-gold-88171 let's consider this to improve the docs
q

quick-musician-29561

01/09/2024, 4:52 AM
Thanks, @early-train-33247 🫡 If @modern-honey-58818's use case works out here, I'll post a tutorial to help others to try it out. Something like "Automatically Back-up KB Table Data into Google sheets"
j

jolly-policeman-82775

01/09/2024, 5:42 AM
lookes like an M stnads for MC donalds
(im hungry)
3 Views