Integrate data to data analytics
# 🤝help
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

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 = // 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 😄

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.

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 !!! 😄
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 could help you there. If anything it is a good starting point for making your own tool.
oh nice docs
i can achieve this ?

time to get to work !
Ok i'm having access to this ! is there a way i can host this in 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

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

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
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
There are several different roles you can set for collaborators. Viewers would be able to see the bot workflows but not change them.

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