CustomerServiceIm
客服 Engine
Usage
How to use my plugin.
Installation
在
Gemfile
里边添加如下代码gem 'customer_service_im'
安装 gem
$ bundle i
执行 Engine 安装的命令
rails g customer_service_im:install
修改
config/initializers/customer_service_im.rb
里边的配置信息,小程序配置和腾讯语音识别配置修改
config/cable.yml
中的配置,全部的 adapter 都改为 redis
development:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
安装 Engine 迁移
rails customer_service_im:install:migrations
安装
ActiveStorage
,如果宿主应用已安装则可跳过,操作冪等,可重复执行rails active_storage:install
执行迁移文件
rails db:migrate
删除宿主应用的
app/channels
,目前没有好的解决方案,暂时先这样配置对应环境
websocket
域名白名单,如config/initializers/development.rb
Rails.application.configure do # ... # config.action_cable.allowed_request_origins = [/http:\/\/*/, /https:\/\/*/] config.action_cable.allowed_request_origins = [/http:\/\/example\.com/, /https:\/\/example\.com/] # ... end
挂载 engine ,在
config/routes.rb
中添加mount CustomerServiceIm::Engine => "/customer_service"
设置对应环境(如:
config/initializers/development.rb
)的默认 host 地址,用于拼接语音识别文件的 url 地址,必须外网能够访问Rails.application.configure do # ... Rails.application.routes.[:host] = ENV.fetch("DEFAULT_HOST", "https://demo.mini-geek.com") # ... end
启用服务
$ rails s -b 0.0.0.0
部署注意事项
- 反向代理的配置
- redis 的配置
config/cable.yml
的配置
Contributing
Contribution directions go here.
License
The gem is available as open source under the terms of the MIT License.