auto_reply_bot.md 1.8 KB

#fb chatbot auto reply function

Feature

Admin Can...

  • List pages under his management
  • List recently posts for certain page
  • Setup some post reply rules/templates for certain post
    • rules can be either wildcard or keywords
  • Setup some private message reply rules/content for certain page
    • rules can be either wildcard or keywords
  • CRUD all post reply rules
  • CRUD all post reply templates
  • CRUD all private message reply rules/content

System will...

  • Auto reply post under certain post
  • Auto reply private message for certain page
  • Save all post content
  • Save all post replies
  • Save all private message

##Model

Admin

has_many :page_managerships
has_many :pages, through: :page_managerships

PageManagership

belongs_to :admin
belongs_to :page
  • admin_id
  • page_id

Page

has_many :page_ownerships
has_many :admins, through: :page_managerships
has_many :posts
has_many :pm_reply_rules, class: MessageReplyRule

.auto_reply_post(user_input)
.auto_reply_pm(user_input)
  • facebook_id
  • name
  • access_token

MessageReplyRule

belongs_to :page
  • page_id
  • match_type, [wildcard, keywords]
  • keywords
  • reply_template_ids
  • published_at

MessageReplyTemplate

belongs_to :page
  • page_id
  • content, text

Post

belongs_to :page
has_many :reply_rules, class: PostReplyRule
  • page_id
  • facebook_id

PostReplyRule

belongs_to :post
has_one :template
  • post_id
  • match_type, [wildcard, keywords]
  • keywords
  • reply_template_ids
  • published_at

PostReplyTemplate

belongs_to :page
  • page_id
  • content, text

ReplyHistory

belongs_to :page
  • page_id
  • post_id
  • sender_facebook_id
  • receipt_facebook_id
  • reply_type
  • reply_rule_id
  • reply_template_id