CustomerServiceIm

客服 Engine

Usage

How to use my plugin.

Installation

  1. Gemfile里边添加如下代码

    gem 'customer_service_im'
    
  2. 安装 gem

    $ bundle i
    
  3. 执行 Engine 安装的命令

    rails g customer_service_im:install
    
  4. 修改config/initializers/customer_service_im.rb里边的配置信息,小程序配置和腾讯语音识别配置

  5. 修改config/cable.yml中的配置,全部的 adapter 都改为 redis

development:
  adapter: redis
  url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>

  1. 安装 Engine 迁移

    rails customer_service_im:install:migrations
    
  2. 安装 ActiveStorage ,如果宿主应用已安装则可跳过,操作冪等,可重复执行

    rails active_storage:install
    
  3. 执行迁移文件

    rails db:migrate
    
  4. 删除宿主应用的app/channels,目前没有好的解决方案,暂时先这样

  5. 配置对应环境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
    
  6. 挂载 engine ,在config/routes.rb中添加

    mount CustomerServiceIm::Engine => "/customer_service"
    
  7. 设置对应环境(如:config/initializers/development.rb)的默认 host 地址,用于拼接语音识别文件的 url 地址,必须外网能够访问

    Rails.application.configure do
    # ...
    Rails.application.routes.default_url_options[:host] = ENV.fetch("DEFAULT_HOST", "https://demo.mini-geek.com")
    # ...
    end
    
  8. 启用服务

    $ 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.