diff --git a/contact-center/163.source.list b/contact-center/163.source.list new file mode 100644 index 00000000..7cced678 --- /dev/null +++ b/contact-center/163.source.list @@ -0,0 +1,5 @@ +deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse +deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse +deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse +deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse +deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse diff --git a/contact-center/Dockerfile b/contact-center/Dockerfile index 2dca2952..a2dd9e07 100644 --- a/contact-center/Dockerfile +++ b/contact-center/Dockerfile @@ -6,6 +6,8 @@ ARG VCS_REF LABEL org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vcs-url="https://github.com/chatopera/cosin" +COPY 163.source.list /etc/apt/sources.list + # Set timezone RUN apt-get update && \ apt-get install --no-install-recommends -y tzdata && \ diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/api/rest/ApiChatbotController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/api/rest/ApiChatbotController.java index fb03e88d..09fef5fe 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/api/rest/ApiChatbotController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/api/rest/ApiChatbotController.java @@ -16,6 +16,7 @@ package com.chatopera.cc.app.handler.api.rest; import com.chatopera.bot.exception.ChatbotException; +import com.chatopera.cc.app.basic.MainContext; import com.chatopera.cc.app.basic.MainUtils; import com.chatopera.cc.app.handler.Handler; import com.chatopera.cc.app.handler.api.request.RestUtils; @@ -79,6 +80,8 @@ public class ApiChatbotController extends Handler { @Autowired private ConsultInviteRepository consultInviteRes; + private String botBaseUrl; + @RequestMapping(method = RequestMethod.POST) @Menu(type = "apps", subtype = "chatbot", access = true) @ApiOperation("聊天机器人") @@ -277,14 +280,16 @@ public class ApiChatbotController extends Handler { invite.setAiname(c.getName()); } else { resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_6); - resp.addProperty(RestUtils.RESP_KEY_ERROR, "Chatopera开发者平台提示:该机器人不存在,请先创建机器人, 登录 https://bot.chatopera.com"); + resp.addProperty(RestUtils.RESP_KEY_ERROR, "Chatopera开发者平台Chatopera开发者平台提示:无法访问该机器人,请确认【1】该服务器可以访问互联网,【2】该聊天机器人已经创建,【3】clientId和Secret正确设置。提示:该机器人不存在,请先创建机器人, 登录 https://bot.chatopera.com"); return resp; } } catch (ChatbotException e) { + logger.error("bot create error", e); resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_5); resp.addProperty(RestUtils.RESP_KEY_ERROR, "Chatopera开发者平台提示:无法访问该机器人,请确认【1】该服务器可以访问互联网,【2】该聊天机器人已经创建,【3】clientId和Secret正确设置。"); return resp; } catch (MalformedURLException e) { + logger.error("bot request error", e); resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_7); resp.addProperty(RestUtils.RESP_KEY_ERROR, "更新智能问答引擎失败。" + e.toString()); return resp; @@ -423,7 +428,7 @@ public class ApiChatbotController extends Handler { */ private JsonObject create(JsonObject j, String creater, String organ, String orgi) { JsonObject resp = new JsonObject(); - String baseUrl = "https://bot.chatopera.com"; + String baseUrl = getBotBaseUrl(); String snsid = null; String workmode = null; String clientId = null; @@ -480,7 +485,7 @@ public class ApiChatbotController extends Handler { } try { - com.chatopera.bot.sdk.Chatbot bot = new com.chatopera.bot.sdk.Chatbot(clientId, secret); + com.chatopera.bot.sdk.Chatbot bot = new com.chatopera.bot.sdk.Chatbot(clientId, secret, getBotBaseUrl()); if (bot.exists()) { // 该机器人存在,clientId 和 Secret配对成功 // 创建成功 @@ -532,14 +537,22 @@ public class ApiChatbotController extends Handler { return resp; } } catch (ChatbotException e) { + logger.error("bot create error", e); resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_5); resp.addProperty(RestUtils.RESP_KEY_ERROR, "Chatopera开发者平台提示:无法访问该机器人,请确认【1】该服务器可以访问互联网,【2】该聊天机器人已经创建,【3】clientId和Secret正确设置。"); return resp; } catch (MalformedURLException e) { + logger.error("bot request error", e); resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4); resp.addProperty(RestUtils.RESP_KEY_ERROR, "Chatopera开发者平台提示:不合法的聊天机器人服务URL。"); return resp; } } + private String getBotBaseUrl(){ + if(this.botBaseUrl == null) + this.botBaseUrl = MainContext.getContext().getEnvironment().getProperty("chatopera.bot.url"); + return this.botBaseUrl; + } + } diff --git a/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html b/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html index f985a02b..eb63a88b 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html +++ b/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html @@ -515,7 +515,7 @@ <#if sessionConfig?? && sessionConfig.satisfaction?? && sessionConfig.satisfaction> document.getElementById("diaShade").style.display = "block" ; - document.getElementById("dialogWrap").style.display = "block" ; + document.getElementById("dialogWrap").style.display = "block"; } if(document.getElementById("agentserviceid")){ @@ -525,7 +525,7 @@ socket.on('message', function(data) { var chat=document.getElementsByClassName('chatting-left').innerText; chat = data.message; - // console.log("On Server Message from Chatbot: ", chat, ", 动态参数:", data.expmsg); + console.log("On Server Message from Chatbot: ", chat, ", 动态参数 data.expmsg:", data.expmsg); if(data.messageType == "image"){ chat = "" ;