36 lines
1.4 KiB
Bash
36 lines
1.4 KiB
Bash
#!/bin/bash
|
|
set -euo pipefail
|
|
# test.pubuli.com:7777 空库初始化
|
|
sudo docker exec guest-chat bundle exec rails runner "
|
|
email = 'admin@localhost.local'
|
|
password = 'LocalCw#168'
|
|
greeting = '您好,欢迎光临【49彩票集团】客服服务中心,请问有什么可以帮到您的呢?'
|
|
site_url = 'http://test.pubuli.com:7777'
|
|
|
|
account = Account.first || Account.create!(name: '测试客服', locale: 'zh_TW')
|
|
user = User.find_by(email: email)
|
|
unless user
|
|
user = User.new(name: '测试管理员', email: email, password: password, password_confirmation: password)
|
|
user.save!
|
|
AccountUser.create!(account: account, user: user, role: :administrator)
|
|
end
|
|
|
|
inbox = account.inboxes.first
|
|
unless inbox
|
|
channel = Channel::WebWidget.create!(
|
|
account: account,
|
|
website_url: site_url,
|
|
widget_color: '#E53935',
|
|
welcome_title: '',
|
|
welcome_tagline: greeting,
|
|
pre_chat_form_enabled: false
|
|
)
|
|
inbox = Inbox.create!(account: account, name: '49彩票集团客服', channel: channel, greeting_enabled: true, greeting_message: greeting)
|
|
end
|
|
|
|
bot = AgentBot.find_by(name: 'AI 客服') || AgentBot.create!(name: 'AI 客服', outgoing_url: 'http://127.0.0.1:7788/webhook/bot1/chatwoot', account: account)
|
|
AgentBotInbox.find_or_create_by!(inbox: inbox, agent_bot: bot, account: account)
|
|
|
|
puts \"OK account=#{account.id} inbox=#{inbox.id} token=#{inbox.channel.website_token} bot_url=#{bot.outgoing_url}\"
|
|
"
|