Kogno
  • Introduction
  • Getting Started
    • Configuration
    • Starting the Server
    • Messenger Configuration
    • Telegram Configuration
    • WhatsApp Configuration
    • NLP Configuration
  • Conversation Class
  • Contexts
    • Blocks
      • before_anything
      • postback
      • deep_link
      • command
      • any_attachment
      • regular_expression
      • keyword
      • any_number
      • any_text
      • intent
      • entity
      • membership
      • recurring_notification
      • everything_else
      • after_all
    • Sub Contexts
    • Routing
    • Sequences
    • Conversational Forms
  • Replies / Notifications
    • text
    • button
    • quick_reply
    • raw
    • list
    • carousel
    • url
    • typing
    • image
    • video
    • html
    • markdown
    • contact
    • location
    • recurring_notification_request
    • messenger_generic_template
    • whatsapp_template
  • Templates
  • Models
    • User model
  • Scheduled Messages
  • Telegram Inline Query
  • Command Line
  • Global Methods
  • Internationalization
Powered by GitBook
On this page
  • Creating a new Model
  • Predefined models

Was this helpful?

Models

Models are classes, They talk to the database, store and validate data.

PreviousTemplatesNextUser model

Last updated 2 years ago

Was this helpful?

As in Rails, Kogno uses the library for this purpose, so the implementation and operation is the same. So you can check out the official if you want to read more about Models.

Creating a new Model

Model classes should be created in bot/models/ directory, where, in most cases, each one should have a corresponding database table. Which was .

In the example below, we will create Product model in bot/models/product.rb file.

For this to work, there must be a table in the database called products.

class Product < ActiveRecord::Base
end

Associations

All the models that are needed can be created (with exception of the predefined by Kogno), defining associations between them.

To lear more about associations you can read: .

Predefined models

In a new project, by default the following models and their corresponding tables are created:

User

users

Corresponds to users who are having or have had a conversation with the app.

Sequence

kogno_sequences

ChatLog

kogno_chat_logs

ScheduledMessage

kogno_scheduled_messages

LongPayload

kogno_long_payloads

MatchedMessage

kogno_matched_messages

MessengerRecurringNotification

kogno_messenger_recurring_notifications

TelegramChatGroup

kogno_telegram_chat_group

Message queue of the .

Stores log of incoming messages/events and replies, if enabled the .

queue.

It allows the with a number of characters greater than those delimited on each platform.

Used for feature from Telegram.

Stores the user's subscription current status from .

Store the Telegram groups or channels where .

Sequences
project's configuration
Scheduled Messages
updating messages
Messenger Recurring Notifications
the bot has been included
ActiveRecord
Rails documentation
A Guide to Active Record Associations
previously configured
creation of payloads