#!/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 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: site_url, 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}\" "