Botmetrics Data Models

Botmetrics uses Postgres as its main data store and here are the different models that it uses:

Botmetrics Data ModelsBotmetrics Data Models

  • User: A User is a Devise backed model that deals with user authentication.
  • BotCollaborator: BotCollaborator is a join table used to form a relationship between a Bot and a User. A user can invite other users as collaborators to view metrics on the same bot and each time that happens a new BotCollaborator entry is created. (A User has_many Bots through BotCollaborators).
  • Bot: A Bot is the model that backs a new "bot project" that a user might create. If you have Facebook, Slack and Kik bots, you will create three separate bots for each.
  • BotInstance: A BotInstance is a model that belongs_to a Bot. The significance of a BotInstance varies on the platform. For Slack, every time a new team signs up to use your bot, a new BotInstance record is created. On Facebook and Kik, only a single BotInstance exists per bot.
  • BotUser: A BotUser is a model that belongs_to a BotInstance. A BotUser represents all of the users that interact with your bot on that platform.
  • Event: An Event is a model that belongs_to both BotInstance and BotUser. An event represents a "metric" on Botmetrics. Every time a message is sent to/from the bot (or in the case of Slack, a message that is being transmitted in a channel that the bot has access to), or an image upload, etc. is tracked in the Event model.
  • Dashboard: A Dashboard is a model that belongs_to a Bot. A dashboard is created every time a user creates a custom dashboard to track a custom metric.
  • DashboardEvent: A DashboardEvent acts a join model between Dashboard and Event. Whenever a new event is created, if it matches the conditions of the custom dashboard, a DashboardEvent entry will be created to store the relationship between the Dashboard and the Event. (A Dashboard has_many Events through DashboardEvents).