feat: Add native support for CSML in agent_bot API (#4913)

This commit is contained in:
Pranav Raj S
2022-06-23 19:17:46 +05:30
committed by GitHub
parent f71980bd95
commit b7606e4dd2
26 changed files with 722 additions and 80 deletions

View File

@@ -3,6 +3,8 @@
# Table name: agent_bots
#
# id :bigint not null, primary key
# bot_config :jsonb
# bot_type :integer default(0)
# description :string
# name :string
# outgoing_url :string
@@ -27,6 +29,9 @@ class AgentBot < ApplicationRecord
has_many :inboxes, through: :agent_bot_inboxes
has_many :messages, as: :sender, dependent: :restrict_with_exception
belongs_to :account, optional: true
enum bot_type: { webhook: 0, csml: 1 }
validate :validate_agent_bot_config
def available_name
name
@@ -48,4 +53,10 @@ class AgentBot < ApplicationRecord
type: 'agent_bot'
}
end
private
def validate_agent_bot_config
errors.add(:bot_config, 'Invalid Bot Configuration') unless AgentBots::ValidateBotService.new(agent_bot: self).perform
end
end