customer_service_im 0.11.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2b3772c30a1022d27d4b3110b09e3a451d5899016fdf59a1d36293c5e6f3eb6
4
- data.tar.gz: 19bf4342fa89caf4bf3e5e35ef9e0c11cbe270654d5c001ba98d6ba65f0decf4
3
+ metadata.gz: 361eef1d405d594d4623b8f5918e8832f5c08bae60a78b0383cdf1d066b02a21
4
+ data.tar.gz: 5622634866a2d0c12b12c710a37d88a4bf30a4e5660836d3d3baad341ef97f6e
5
5
  SHA512:
6
- metadata.gz: 5c65da60c3ed1e4262599a5b26d5bd6ce9dfebb0961b188e35db97c244551e7280cbe2425b82b75ebd150dfda6d8a2e0251e232ce2e93c2a5410958f7e7fac1a
7
- data.tar.gz: ca2c7cfe0de0a82658e928f69d11162454b3e05be82d29bb41bf328eed42bd71e29fa9fa8597e81a0f7a6ffe28e630eb0b264efda0e4d193558618d0c476fb77
6
+ metadata.gz: de3b926211144172238515e1d96775e4b75f6017e1ec02d91dca5c18d9c6ebb39a979c8935d13299396da4714cc30740461683f2d38e785579d03d01dfb11df6
7
+ data.tar.gz: 26dc6a611ade6678afcf6dbd536d4d0112a4dfc2b4d8661753260c59a9cdc3cb181248bd27ef1bbecdf7d1dfae874ef5a16f16485cc6b6994f2b635426a88d41
data/README.md CHANGED
@@ -1,26 +1,89 @@
1
1
  # CustomerServiceIm
2
- Short description and motivation.
2
+ 客服 Engine
3
3
 
4
4
  ## Usage
5
5
  How to use my plugin.
6
6
 
7
7
  ## Installation
8
- Add this line to your application's Gemfile:
9
8
 
9
+ 1. 在`Gemfile`里边添加如下代码
10
10
  ```ruby
11
11
  gem 'customer_service_im'
12
12
  ```
13
13
 
14
- And then execute:
14
+ 2. 安装 gem
15
15
  ```bash
16
- $ bundle
16
+ $ bundle i
17
17
  ```
18
18
 
19
- Or install it yourself as:
19
+ 3. 执行 Engine 安装的命令
20
20
  ```bash
21
- $ gem install customer_service_im
21
+ rails g customer_service_im:install
22
22
  ```
23
23
 
24
+ 4. 修改`config/initializers/customer_service_im.rb`里边的配置信息,小程序配置和腾讯语音识别配置
25
+
26
+ 5. 修改`config/cable.yml`中的配置,全部的 adapter 都改为 redis
27
+
28
+ ```yml
29
+ development:
30
+ adapter: redis
31
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
32
+
33
+ ```
34
+
35
+ 7. 安装 Engine 迁移
36
+ ```bash
37
+ rails customer_service_im:install:migrations
38
+ ```
39
+
40
+ 6. 安装 `ActiveStorage` ,如果宿主应用已安装则可跳过,操作冪等,可重复执行
41
+ ```bash
42
+ rails active_storage:install
43
+ ```
44
+
45
+ 7. 执行迁移文件
46
+ ```bash
47
+ rails db:migrate
48
+ ```
49
+
50
+ 8. 删除宿主应用的`app/channels`,目前没有好的解决方案,暂时先这样
51
+
52
+ 9. 配置对应环境`websocket`域名白名单,如`config/initializers/development.rb`
53
+ ```ruby
54
+ Rails.application.configure do
55
+ # ...
56
+ # config.action_cable.allowed_request_origins = [/http:\/\/*/, /https:\/\/*/]
57
+ config.action_cable.allowed_request_origins = [/http:\/\/example\.com/, /https:\/\/example\.com/]
58
+ # ...
59
+ end
60
+ ```
61
+
62
+ 10. 挂载 engine ,在`config/routes.rb`中添加
63
+ ```ruby
64
+ mount CustomerServiceIm::Engine => "/customer_service"
65
+ ```
66
+
67
+ 11. 设置对应环境(如:`config/initializers/development.rb`)的默认 host 地址,用于拼接语音识别文件的 url 地址,必须外网能够访问
68
+ ```ruby
69
+ Rails.application.configure do
70
+ # ...
71
+ Rails.application.routes.default_url_options[:host] = ENV.fetch("DEFAULT_HOST", "https://demo.mini-geek.com")
72
+ # ...
73
+ end
74
+ ```
75
+
76
+ 12. 启用服务
77
+ ```bash
78
+ $ rails s -b 0.0.0.0
79
+ ```
80
+
81
+ ## 部署注意事项
82
+
83
+ - 反向代理的配置
84
+ - redis 的配置
85
+ - `config/cable.yml`的配置
86
+
24
87
  ## Contributing
25
88
  Contribution directions go here.
26
89
 
@@ -77,7 +77,6 @@ module CustomerServiceIm::Concerns::Customer
77
77
 
78
78
  User.create_with(
79
79
  email: "#{SecureRandom.uuid}@mp.com",
80
- password: Digest::MD5.hexdigest(open_id)
81
80
  ).find_or_create_by(open_id: open_id)
82
81
  end
83
82
  end
@@ -4,6 +4,8 @@ module CustomerServiceIm
4
4
  belongs_to :user, polymorphic: true
5
5
  belongs_to :staff, optional: true
6
6
 
7
+ after_create :broadcast_to_channel
8
+
7
9
  # validates_presence_of :title
8
10
 
9
11
  def last_message
@@ -82,7 +82,7 @@ module CustomerServiceIm
82
82
  else
83
83
  logger = Logger.new Rails.root.join("log/speech_recognition.log")
84
84
  logger.error result.errors
85
- raise TsrRecognizeError.new(result.errors)
85
+ raise CustomerServiceIm::AsrRecognizeError.new(result.errors)
86
86
  end
87
87
  end
88
88
 
@@ -1,12 +1,6 @@
1
1
 
2
2
  TxAsr.setup do |config|
3
3
 
4
- # TODO 需要将 secret_key 和 secret_id 改为你实际项目中的配置
5
- config.secret_key = "JL6amhMkqfDVWGjuoRp1DI8j48wTnunQ"
6
- config.secret_id = "AKIDta1B5i49yXpqb5HCqELBk35qJWS7VcS1"
7
- config.region = "ap-guangzhou"
8
-
9
-
10
4
  # 声音格式: 支持 mp3 和 wav
11
5
  config.voice_format = "mp3"
12
6
 
@@ -0,0 +1,4 @@
1
+
2
+ module CustomerServiceIm
3
+ class AsrRecognizeError < StandardError; end
4
+ end
@@ -1,3 +1,3 @@
1
1
  module CustomerServiceIm
2
- VERSION = '0.11.0'
2
+ VERSION = '0.15.0'
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require "customer_service_im/version"
2
2
  require "customer_service_im/engine"
3
3
  require "customer_service_im/core_ext"
4
+ require "customer_service_im/asr_recognize_error"
4
5
  # require 'shoulda'
5
6
  require "jwt"
6
7
  require 'jbuilder'
@@ -10,11 +11,14 @@ require 'mini_program'
10
11
 
11
12
  module CustomerServiceIm
12
13
  # Your code goes here...
13
- mattr_accessor :appid, :app_secret, :jwt_secret
14
+ mattr_accessor :appid, :app_secret, :jwt_secret, :asr_config
14
15
 
15
16
  def self.setup
16
17
  if block_given?
17
18
  yield self
19
+ TxAsr.secret_key = asr_config&.fetch(:secret_key, :blank_asr_secret_key)
20
+ TxAsr.secret_id = asr_config&.fetch(:secret_id, :blank_asr_secret_id)
21
+ TxAsr.region = asr_config&.fetch(:region, :blank_asr_region)
18
22
  end
19
23
  end
20
24
  end
@@ -3,4 +3,11 @@ CustomerServiceIm.setup do |config|
3
3
  config.jwt_secret = Rails.application.secret_key_base
4
4
  config.appid = "xxx"
5
5
  config.app_secret = "x1x"
6
+
7
+ # tencent asr config
8
+ config.asr_config = {
9
+ secret_key: "tencent asr secret key",
10
+ secret_id: "tencent asr secret id",
11
+ region: "tencent asr "
12
+ }
6
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: customer_service_im
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-27 00:00:00.000000000 Z
11
+ date: 2021-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -189,6 +189,7 @@ files:
189
189
  - db/migrate/20211026062727_add_password_digest_to_customer_service_im_staffs.rb
190
190
  - db/migrate/20211026062951_add_email_to_customer_service_im_staffs.rb
191
191
  - lib/customer_service_im.rb
192
+ - lib/customer_service_im/asr_recognize_error.rb
192
193
  - lib/customer_service_im/core_ext.rb
193
194
  - lib/customer_service_im/engine.rb
194
195
  - lib/customer_service_im/version.rb
@@ -196,7 +197,6 @@ files:
196
197
  - lib/generators/customer_service_im/install/install_generator.rb
197
198
  - lib/generators/customer_service_im/install/templates/initializer.rb
198
199
  - lib/tasks/customer_service_im_tasks.rake
199
- - lib/tsr_recognize_error.rb
200
200
  homepage: https://github.com/bkyz/customer_service_im
201
201
  licenses:
202
202
  - MIT
@@ -1,2 +0,0 @@
1
-
2
- class TsrRecognizeError < StandardError; end