mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
#153 支持配置机器人URL地址
This commit is contained in:
parent
bddaaa8f50
commit
8e5e44ab3f
@ -337,7 +337,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.chatopera.bot</groupId>
|
<groupId>com.chatopera.bot</groupId>
|
||||||
<artifactId>sdk</artifactId>
|
<artifactId>sdk</artifactId>
|
||||||
<version>1.0.1</version>
|
<version>1.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
@ -40,6 +40,7 @@ public class ChatbotEventHandler implements EventHandler<UserDataEvent> {
|
|||||||
|
|
||||||
private ChatbotRepository chatbotRes;
|
private ChatbotRepository chatbotRes;
|
||||||
private AgentUserRepository agentUserRes;
|
private AgentUserRepository agentUserRes;
|
||||||
|
private String botServiceUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据聊天机器人返回数据更新agentUser
|
* 根据聊天机器人返回数据更新agentUser
|
||||||
@ -62,9 +63,9 @@ public class ChatbotEventHandler implements EventHandler<UserDataEvent> {
|
|||||||
Chatbot c = getChatbotRes()
|
Chatbot c = getChatbotRes()
|
||||||
.findOne(request.getAiid());
|
.findOne(request.getAiid());
|
||||||
|
|
||||||
logger.info("[chatbot disruptor] chat request baseUrl {}, chatbot {}, fromUserId {}, textMessage {}", c.getBaseUrl(), c.getName(), request.getUserid(), request.getMessage());
|
logger.info("[chatbot disruptor] chat request baseUrl {}, chatbot {}, fromUserId {}, textMessage {}", getChatbotServiceUrl(), c.getName(), request.getUserid(), request.getMessage());
|
||||||
// Get response from Conversational Engine.
|
// Get response from Conversational Engine.
|
||||||
com.chatopera.bot.sdk.Chatbot bot = new com.chatopera.bot.sdk.Chatbot(c.getClientId(), c.getSecret());
|
com.chatopera.bot.sdk.Chatbot bot = new com.chatopera.bot.sdk.Chatbot(c.getClientId(), c.getSecret(), getChatbotServiceUrl());
|
||||||
JSONObject result = bot.conversation(request.getUserid(), request.getMessage());
|
JSONObject result = bot.conversation(request.getUserid(), request.getMessage());
|
||||||
|
|
||||||
// parse response
|
// parse response
|
||||||
@ -85,7 +86,7 @@ public class ChatbotEventHandler implements EventHandler<UserDataEvent> {
|
|||||||
resp.setUserid(request.getUserid());
|
resp.setUserid(request.getUserid());
|
||||||
resp.setType(request.getType());
|
resp.setType(request.getType());
|
||||||
resp.setChannel(request.getChannel());
|
resp.setChannel(request.getChannel());
|
||||||
if(data.has("params")){
|
if (data.has("params")) {
|
||||||
resp.setExpmsg(data.get("params").toString());
|
resp.setExpmsg(data.get("params").toString());
|
||||||
}
|
}
|
||||||
resp.setContextid(request.getContextid());
|
resp.setContextid(request.getContextid());
|
||||||
@ -138,4 +139,12 @@ public class ChatbotEventHandler implements EventHandler<UserDataEvent> {
|
|||||||
return chatbotRes;
|
return chatbotRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getChatbotServiceUrl() {
|
||||||
|
if (botServiceUrl == null) {
|
||||||
|
botServiceUrl = MainContext.getContext().getEnvironment().getProperty("chatopera.bot.url");
|
||||||
|
}
|
||||||
|
return botServiceUrl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -157,3 +157,6 @@ spring.servlet.multipart.max-request-size=15MB
|
|||||||
|
|
||||||
# MySQL Blob
|
# MySQL Blob
|
||||||
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext
|
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext
|
||||||
|
|
||||||
|
# Chatopera Bot
|
||||||
|
chatopera.bot.url=https://bot.chatopera.com
|
Loading…
x
Reference in New Issue
Block a user