Creation of custom analytics to have the number of users arriving to each flow

Hi all, can anyone share how to create custom analytics to show the number of users arriving to each flow or even node on the conversation.

Hie @MeeVony, thank you for your question.

Since the Analytics module was revamped in v12.xx.x, we removed the custom analytics functionality. However, you can write an action that captures metrics in a custom table in your database; for instance, in a table with columns Date, Code, User, Channel, we can achieve as follows:

   * Record every time a node is entered
   * @title Post Query Statistics
   * @category Analytics
   * @author Michael 
  var moment = require('moment');

  const postStats = async () => {
    const dateRaw = new Date()
    const dateNorm= moment(dateRaw).format('DD-MM-YY');
    const metricName= temp.savedMetricInNode;
    const botUser =;
    const chanel =;

  const knex = require('knex')({
      client: 'pg',
      version: '12',
      connection: {
        host: '<YOUR-HOST>',
        user: 'postgres',
        password: '<YOUR-PASSWORD>',
        database: '<DATABASE-NAME>'
  useNullAsDefault: false

  .insert({Date: dateNorm, Code: metricName, User: botUser, Channel: chanel})
    .catch(e => console.log(e))
    .finally(() => knex.end)   

  return postStats()

PS: Don’t forget to use the set-variable action to create the variable named savedMetricInNode

@Michael_BotpressTeam Thank you for your answer. I’ll try it!

@Michael_BotpressTeam, I would like to have a confirmation that from botpress 12.xx.x onwards, it is no longer possible to add a custom analysis? I ask because I don’t see that from the changelog

How should I do if my database is SQLITE?