Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qiangwayu9962
cskefu
提交
625ba344
C
cskefu
项目概览
qiangwayu9962
/
cskefu
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cskefu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
625ba344
编写于
8月 05, 2021
作者:
Chatopera 研发团队
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
https://github.com/chatopera/cskefu/issues/455
Fix session time period, upgrade chatopera sdk
上级
46aff0c3
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
71 addition
and
10 deletion
+71
-10
contact-center/app/src/main/java/com/chatopera/cc/basic/Constants.java
...r/app/src/main/java/com/chatopera/cc/basic/Constants.java
+3
-0
contact-center/app/src/main/java/com/chatopera/cc/model/FbMessenger.java
...app/src/main/java/com/chatopera/cc/model/FbMessenger.java
+19
-0
contact-center/app/src/main/resources/static/images/messenger.png
...center/app/src/main/resources/static/images/messenger.png
+0
-0
contact-center/config/sql/cosinee-MySQL-slim.sql
contact-center/config/sql/cosinee-MySQL-slim.sql
+2
-2
contact-center/config/sql/upgrade/009.alter_uk_agentservice_sessiontimes.sql
...ig/sql/upgrade/009.alter_uk_agentservice_sessiontimes.sql
+6
-0
contact-center/config/sql/upgrade/009.alter_uk_agentuser_sessiontimes.sql
...onfig/sql/upgrade/009.alter_uk_agentuser_sessiontimes.sql
+6
-0
contact-center/root/pom.xml
contact-center/root/pom.xml
+1
-1
public/plugins/chatbot/classes/ChatbotConstants.java
public/plugins/chatbot/classes/ChatbotConstants.java
+2
-0
public/plugins/chatbot/classes/ChatbotEventSubscription.java
public/plugins/chatbot/classes/ChatbotEventSubscription.java
+32
-7
未找到文件。
contact-center/app/src/main/java/com/chatopera/cc/basic/Constants.java
浏览文件 @
625ba344
...
...
@@ -131,6 +131,9 @@ public class Constants {
public
static
final
String
AUDIT_AGENT_MESSAGE
=
"cskefu.agent.audit"
;
// 机器人返回的结果数据来源为faq
public
final
static
String
PROVIDER_FAQ
=
"faq"
;
public
final
static
String
PROVIDER_FEEDBACK
=
"feedback"
;
public
final
static
String
PROVIDER_FEEDBACK_EVAL_POSITIVE
=
"positive"
;
public
final
static
String
PROVIDER_FEEDBACK_EVAL_NEGATIVE
=
"negative"
;
// Facebook OTN 发送
public
final
static
String
INSTANT_MESSAGING_MQ_QUEUE_FACEBOOK_OTN
=
"cskefu.outbound.faceboot.otn"
;
...
...
contact-center/app/src/main/java/com/chatopera/cc/model/FbMessenger.java
浏览文件 @
625ba344
...
...
@@ -16,11 +16,14 @@
package
com.chatopera.cc.model
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.commons.lang.StringUtils
;
import
org.hibernate.annotations.GenericGenerator
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.Map
;
@Entity
@Table
(
name
=
"cs_fb_messenger"
)
...
...
@@ -151,7 +154,23 @@ public class FbMessenger implements Serializable {
return
config
;
}
/**
* Get config as map object
*
* @return
*/
public
Map
<
String
,
String
>
parseConfigMap
()
{
Map
<
String
,
String
>
configMap
=
(
Map
<
String
,
String
>)
JSONObject
.
parse
(
StringUtils
.
isNotBlank
(
getConfig
())
?
getConfig
()
:
"{}"
);
return
configMap
;
}
public
void
setConfig
(
String
config
)
{
this
.
config
=
config
;
}
public
<
K
,
V
>
void
setConfigMap
(
Map
<
K
,
V
>
config
)
{
String
data
=
JSONObject
.
toJSONString
(
config
);
this
.
config
=
data
;
}
}
contact-center/app/src/main/resources/static/images/messenger.png
0 → 100644
浏览文件 @
625ba344
3.8 KB
contact-center/config/sql/cosinee-MySQL-slim.sql
浏览文件 @
625ba344
...
...
@@ -529,7 +529,7 @@ CREATE TABLE `uk_agentservice` (
`ipaddr` varchar(50) DEFAULT NULL COMMENT 'IP地址',
`osname` varchar(100) DEFAULT NULL COMMENT '操作系统名称',
`browser` varchar(100) DEFAULT NULL COMMENT '浏览器',
`sessiontimes`
int(20
) DEFAULT NULL COMMENT '会话时长',
`sessiontimes`
bigint(64
) DEFAULT NULL COMMENT '会话时长',
`servicetime` datetime DEFAULT NULL COMMENT '服务时长',
`region` varchar(255) DEFAULT NULL COMMENT '区域',
`agentusername` varchar(50) DEFAULT NULL COMMENT '坐席用户名',
...
...
@@ -666,7 +666,7 @@ CREATE TABLE `uk_agentuser` (
`ipaddr` varchar(50) DEFAULT NULL COMMENT 'IP地址',
`osname` varchar(100) DEFAULT NULL COMMENT '操作系统名称',
`browser` varchar(100) DEFAULT NULL COMMENT '浏览器',
`sessiontimes`
int(20
) DEFAULT NULL COMMENT '会话时长',
`sessiontimes`
bigint(64
) DEFAULT NULL COMMENT '会话时长',
`servicetime` datetime DEFAULT NULL COMMENT '服务次数',
`region` varchar(255) DEFAULT NULL COMMENT '地区',
`agentservice` varchar(32) DEFAULT NULL COMMENT '服务ID',
contact-center/config/sql/upgrade/009.alter_uk_agentservice_sessiontimes.sql
0 → 100644
浏览文件 @
625ba344
USE
`cosinee`
;
-- -----------------
-- prepare variables
-- -----------------
ALTER
TABLE
`uk_agentservice`
MODIFY
COLUMN
`sessiontimes`
BIGINT
(
64
)
NULL
DEFAULT
NULL
COMMENT
'会话时长'
;
contact-center/config/sql/upgrade/009.alter_uk_agentuser_sessiontimes.sql
0 → 100644
浏览文件 @
625ba344
USE
`cosinee`
;
-- -----------------
-- prepare variables
-- -----------------
ALTER
TABLE
`uk_agentuser`
MODIFY
COLUMN
`sessiontimes`
BIGINT
(
64
)
NULL
DEFAULT
NULL
COMMENT
'会话时长'
;
contact-center/root/pom.xml
浏览文件 @
625ba344
...
...
@@ -375,7 +375,7 @@
<dependency>
<groupId>
com.chatopera.bot
</groupId>
<artifactId>
sdk
</artifactId>
<version>
3.
3.2
</version>
<version>
3.
5.0
</version>
</dependency>
</dependencies>
<repositories>
...
...
public/plugins/chatbot/classes/ChatbotConstants.java
浏览文件 @
625ba344
...
...
@@ -20,4 +20,6 @@ public class ChatbotConstants {
public
static
final
String
THRESHOLD_FAQ_BEST_REPLY
=
"BOT_THRESHOLD_FAQ_BEST_REPLY"
;
public
static
final
String
THRESHOLD_FAQ_SUGG_REPLY
=
"BOT_THRESHOLD_FAQ_SUGG_REPLY"
;
public
static
final
String
DEFAULT_BOT_PROVIDER
=
"https://bot.chatopera.com"
;
public
static
final
String
PROVIDER_FEEDBACK_EVAL_POSITIVE_REPLY_PLACEHOLDER
=
"${evaluationYesReply}"
;
public
static
final
String
PROVIDER_FEEDBACK_EVAL_NEGATIVE_REPLY_PLACEHOLDER
=
"${evaluationNoReply}"
;
}
public/plugins/chatbot/classes/ChatbotEventSubscription.java
浏览文件 @
625ba344
...
...
@@ -17,10 +17,10 @@
package
com.chatopera.cc.plugins.chatbot
;
import
com.chatopera.bot.exception.ChatbotException
;
import
com.chatopera.bot.sdk.Response
;
import
com.chatopera.cc.basic.Constants
;
import
com.chatopera.cc.basic.MainContext
;
import
com.chatopera.cc.cache.Cache
;
import
com.chatopera.cc.controller.api.request.RestUtils
;
import
com.chatopera.cc.model.Chatbot
;
import
com.chatopera.cc.persistence.repository.AgentUserRepository
;
import
com.chatopera.cc.persistence.repository.ChatMessageRepository
;
...
...
@@ -105,21 +105,29 @@ public class ChatbotEventSubscription {
// Get response from Conversational Engine.
com
.
chatopera
.
bot
.
sdk
.
Chatbot
bot
=
new
com
.
chatopera
.
bot
.
sdk
.
Chatbot
(
c
.
getClientId
(),
c
.
getSecret
(),
botServiceProvider
);
JSONObject
result
=
bot
.
conversation
(
request
.
getUserid
(),
request
.
getMessage
(),
faqBestReplyThreshold
,
faqSuggReplyThreshold
);
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"fromUserId"
,
request
.
getUserid
());
body
.
put
(
"textMessage"
,
request
.
getMessage
());
body
.
put
(
"faqBestReplyThreshold"
,
faqBestReplyThreshold
);
body
.
put
(
"faqSuggReplyThreshold"
,
faqSuggReplyThreshold
);
Response
result
=
bot
.
command
(
"POST"
,
"/conversation/query"
,
body
);
// parse response
if
(
result
!=
null
)
{
logger
.
info
(
"[chat] chat response {}"
,
result
.
toString
());
if
(
result
.
get
Int
(
RestUtils
.
RESP_KEY_RC
)
==
0
)
{
if
(
result
.
get
Rc
(
)
==
0
)
{
// reply
JSONObject
data
=
result
.
getJSONObject
(
"data"
);
JSONObject
data
=
(
JSONObject
)
result
.
getData
(
);
if
(
data
.
has
(
"logic_is_fallback"
))
{
ChatMessage
resp
=
creatChatMessage
(
request
,
c
);
resp
.
setMessage
(
data
.
getString
(
"string"
));
ChatMessage
respHelp
=
new
ChatMessage
();
JSONArray
respParams
=
new
JSONArray
();
if
(!
StringUtils
.
equals
(
MainContext
.
ChannelType
.
WEBIM
.
toString
(),
c
.
getChannel
()))
{
// 非 WEBIM 情况,比如 Facebook Messenger,使用下面的方法
// 如果在更多渠道下,此处可能仅适应于 Messenger,那么宜将检测条件调整为 ChannelType.MESSENGER
if
(
data
.
getBoolean
(
"logic_is_fallback"
))
{
if
(!
StringUtils
.
equals
(
Constants
.
CHATBOT_HUMAN_FIRST
,
c
.
getWorkmode
()))
{
JSONArray
faqReplies
=
data
.
getJSONArray
(
"faq"
);
...
...
@@ -157,6 +165,20 @@ public class ChatbotEventSubscription {
message
.
put
(
"attachment"
,
attachment
);
resp
.
setExpmsg
(
message
.
toString
());
}
}
else
if
(
StringUtils
.
equals
(
Constants
.
PROVIDER_FEEDBACK
,
data
.
getJSONObject
(
"service"
).
get
(
"provider"
).
toString
()))
{
respHelp
=
null
;
// 反馈回复内容
String
sentiment
=
data
.
getJSONObject
(
"service"
).
get
(
"sentiment"
).
toString
();
if
(
StringUtils
.
equals
(
Constants
.
PROVIDER_FEEDBACK_EVAL_POSITIVE
,
sentiment
))
{
// 积极评价
resp
.
setMessage
(
ChatbotConstants
.
PROVIDER_FEEDBACK_EVAL_POSITIVE_REPLY_PLACEHOLDER
);
}
else
if
(
StringUtils
.
equals
(
Constants
.
PROVIDER_FEEDBACK_EVAL_NEGATIVE
,
sentiment
))
{
// 消极评价
resp
.
setMessage
(
ChatbotConstants
.
PROVIDER_FEEDBACK_EVAL_NEGATIVE_REPLY_PLACEHOLDER
);
}
else
{
// no response
resp
.
setMessage
(
"${leaveMeAlone}"
);
}
}
else
if
(
StringUtils
.
equals
(
Constants
.
PROVIDER_FAQ
,
data
.
getJSONObject
(
"service"
).
get
(
"provider"
).
toString
()))
{
if
(
data
.
has
(
"params"
))
{
resp
.
setMessage
(
data
.
getJSONArray
(
"params"
).
getJSONObject
(
0
).
getString
(
"content"
));
...
...
@@ -197,6 +219,7 @@ public class ChatbotEventSubscription {
}
}
}
else
{
// 当前渠道为 WEBIM
if
(
data
.
getBoolean
(
"logic_is_fallback"
))
{
// 兜底回复,检查FAQ
JSONArray
faqReplies
=
data
.
getJSONArray
(
"faq"
);
...
...
@@ -221,11 +244,13 @@ public class ChatbotEventSubscription {
// 更新聊天机器人累计值
updateAgentUserWithRespData
(
request
.
getUserid
(),
request
.
getOrgi
(),
data
);
// 保存并发送
// 保存并发送
if
(
MainContext
.
ChannelType
.
WEBIM
.
toString
().
equals
(
resp
.
getChannel
()))
{
// WEBIM 渠道
chatbotProxy
.
saveAndPublish
(
resp
);
}
else
{
// 其他渠道
chatMessageRes
.
save
(
resp
);
if
(
respParams
.
length
()
>
0
)
{
for
(
int
i
=
0
;
i
<
respParams
.
length
();
i
++)
{
...
...
@@ -244,7 +269,7 @@ public class ChatbotEventSubscription {
}
}
}
else
{
logger
.
warn
(
"[chat] can not get expected response
{}"
,
result
.
toString
());
logger
.
warn
(
"[chat] can not get expected response
rc {}, error {}"
,
result
.
getRc
(),
result
.
getError
());
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录