Files
2026-08-15 14:51:51 +08:00

40 lines
1.8 KiB
Bash

#!/bin/bash
set -euo pipefail
sudo docker exec guest-chat bundle exec rails runner "
email = 'admin@localhost.local'
password = 'LocalCw#168'
greeting = '您好,欢迎光临【49彩票集团】客服服务中心,请问有什么可以帮到您的呢?'
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
user.confirm if user.respond_to?(:confirm)
user.update!(confirmed_at: Time.current) if user.respond_to?(:confirmed_at) && user.confirmed_at.nil?
inbox = account.inboxes.first
unless inbox
channel = Channel::WebWidget.create!(
account: account,
website_url: 'http://www.pubuli.com:7777',
widget_color: '#E53935',
welcome_title: '',
welcome_tagline: greeting,
pre_chat_form_enabled: false,
continuity_via_email: false
)
inbox = Inbox.create!(account: account, name: '49彩票集团客服', channel: channel, greeting_enabled: true, greeting_message: greeting, enable_email_collect: false)
end
inbox.update!(enable_email_collect: false) if inbox.respond_to?(:enable_email_collect=)
channel = inbox.channel
channel.update!(continuity_via_email: false, pre_chat_form_enabled: false) if channel.respond_to?(:continuity_via_email=)
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}\"
"