Integrate data to data analytics
# 🤝help
r
Creating a New Action: In the Botpress interface, go to the "Bot" section and select a bot. Then go to the "Code Editor" tab. Here, you can create a new action by clicking the "+Action" button. This will create a new .js file where you can write your code. To send data to Google Analytics, you can use the code I provided in a previous message. is this possible in botpress cloud ? i would like to extract the analytics part of botpress or send the data to google anayltics. i want to be able to share the analytics with my clients without having to give them acess to my account. is it possible in any way ? @rich-battery-69172 @acoustic-hair-60678 thanks guys for your hardwork

https://cdn.discordapp.com/attachments/1131866854298751017/1131871145822531664/Appli.png

My plan was to create something like this for our clients. Where they would be able to see how many messages they used, how many users used the chatbot, a tab to see the conversation history of users. You think this is something we can do ?$
Would i need to do something like this ? const chatHistory = workflow.chatHistory || [] // Retrieve existing chat history or initialize an empty array const timestamp = luxon.DateTime.now().toISO() // Get current timestamp const message = event.payload.text // Get the user's message // Create a new chat entry with timestamp and message const chatEntry = { timestamp, message } // Add the new chat entry to the chat history chatHistory.push(chatEntry) // Update the chat history in the workflow variable workflow.chatHistory = chatHistory And then extract this info into a google sheets, and calculate the messages send ? When botpress calculates the messages at 0.005, is it send by the user AND answer from the bot ? If yes, i would need to extract both user message and bot question plus answer? so much work xD Cuz the code i've used needs to be in every node right ? :/
I would want to take this outside botpress. plus having a record of the conversations. Sorry lot of info but i hope it canhelp you help me 😄

https://cdn.discordapp.com/attachments/1131866854298751017/1131895831868489759/Capture_decran_2023-07-21_122810.png

a
That code looks pretty solid @rough-magician-49397. Since it would need to run so often, I'd recommend using a hook instead of running it manually in an execute code card. You could do this in a "Before outgoing message" hook and it should be okay.

https://cdn.discordapp.com/attachments/1131866854298751017/1131897790025449573/image.png

r
Thanks its working as intended. When botpress calculates the messages at 0.005, is it send by the user AND answer from the bot ? If yes i need to retrieve bot answers and questions too in my chat history. And for the analytics part ? thanks for your help !!! 😄
a
If you're trying to analyze the data outside of Botpress, I'd take a look at using the API to get conversations, etc from the database. There's not an easy way to do it so you will have to write some code. @early-train-33247 's Botpress inbox https://github.com/devguilhermy/botpress-inbox could help you there. If anything it is a good starting point for making your own tool.
r
oh nice docs
i can achieve this ?

https://cdn.discordapp.com/attachments/1131866854298751017/1131900770074235000/244872559-7978adfe-ad28-41be-8573-3930023e9607.png

time to get to work !
thanks
Ok i'm having access to this ! is there a way i can host this in render.com for exemple ?
🤖 Now to figure out your bot id as a user, open any conversation and go to the developer console. You will see a MESSAGES: [...] log. Open the list and look for the first message sent by the bot (a good clue is direction: "outgoing"). Could you guys tell me what number it is following my image? thanks

https://cdn.discordapp.com/attachments/1131866854298751017/1131908488688324688/inbox.png

a
I find it's easier to find the botID from the cloud studio. In the URL, the highlighted bit is the bot ID

https://cdn.discordapp.com/attachments/1131866854298751017/1131920509135769620/image.png

e
Hey @rough-magician-49397 and @acceptable-kangaroo-64719, the bot id as a user is different from the id in the Cloud.
Just follow these detailed instructions you pasted and you will find the id
@rough-magician-49397, instead of building an Analytics page yourself, you can use the one in the Dashboard! You should create a workspace for each client and add them as a collaborator so they can make changes to the workspace and bot settings, and to the bot behavior.
We are working on an official Inbox that shall be integrated into the dashboard, so your clients will be able to see conversations there as well
But in the meantime, you can host one version of the project on Vercel/Netlify/Render for each client
r
Is there a way to control what the clients can see? I woudnt like them to see the workflows etc. Its something that they can easily mess up. I really just need the analytics part and the conversations for them. Thanks for your answers btw
The project was to really create a platform where the user logins to see everything he needs in our end. Btw, i emailed for an entreprise plan (amplifai) too, maybe there's a way we can talk about this
e
There are several different roles you can set for collaborators. Viewers would be able to see the bot workflows but not change them.

https://cdn.discordapp.com/attachments/1131866854298751017/1132766209910243388/image.png

I get it, it makes sense building a custom dashboard! Regarding the enterprise plan, @freezing-printer-49373 is your guy!
g
Hey @rough-magician-49397 I am trying to do something similar for analytics. Would you be opposed to the idea of collaboration?
m
@early-train-33247 Where's the BOT ID AS A USER at? Can you send screenshots pls
14 Views