Is it possible to export the data of the tables of...
# 🤝help
m
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
@early-train-33247 would you happen to know if it's possible and how?
m
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
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
Oh I was looking for some tutorial but I only found some to import tables to Botpress, I want to export them
q
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
I will try it tomorrow too, I will keep you noticed if I'm able to do here!!
e
It's definitely possible with the Triggers!
Let us know if you guys can make it!
q
Did you get cron to work with Botpress? 💡 🛠️
j
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
Hey @jolly-policeman-82775 ! You know there's already a video on this right?

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

j
im doing updated versions
beucase thats kind of a difficult way of understanding
i did something new with code
c
An updated version is a good idea 🙂
with the new UI
j
yes
q
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
Okay I am not aware of that issue, but I'll try to reproduce it and let you know!
q
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
So now we need a webhook to receive the json from botpress
q
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
Maybe we need to JSON.parse the data table?
q
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
That's with JSON.stringify
I will screenshot this in a bit
q
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
Should I send it to webhook like this and then in make create an Array?
q
That's exactly what I'm been trying to do also 🛠️
m
I will try with the array aggregator then
q
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
Yep, me too, I was able one by one, but this is a new challenge
What about this module?
j
it repeats that funtion all over again
i think so 🤔
m
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
Thanks @jolly-policeman-82775 💎 I tried that also, something like that we'll need
j
heck yeah
q
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
Thanks a lot for the detailed steps @quick-musician-29561!! 🦾
@acceptable-gold-88171 let's consider this to improve the docs
q
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
lookes like an M stnads for MC donalds
(im hungry)
19 Views