|
@@ -8,7 +8,7 @@ from . import app
|
|
|
import src.core.callcenter.cache as Cache
|
|
|
from src.core.callcenter import create_app
|
|
|
from src.core.callcenter.agent import AgentService, AgentOperService
|
|
|
-from src.core.callcenter.constant import success_response
|
|
|
+from src.core.callcenter.constant import success_response, error_response
|
|
|
from src.core.callcenter.enumeration import CallType
|
|
|
from src.core.callcenter.esl.client import InboundClient, OutboundClient
|
|
|
from flask import Flask, request, render_template_string
|
|
@@ -16,13 +16,13 @@ from flask import Flask, request, render_template_string
|
|
|
from src.core.callcenter.call import CallService
|
|
|
from src.core.callcenter.api import AgentCallRequest, AgentActionRequest, HangupCallRequest, \
|
|
|
HumanServiceQueryRequest
|
|
|
-# from src.core.voip.bot import BotAgent
|
|
|
+from src.core.voip.bot import BotAgent
|
|
|
|
|
|
|
|
|
-# agent = BotAgent(app.logger)
|
|
|
-agent = None
|
|
|
+agent = BotAgent(app.logger)
|
|
|
+# agent = None
|
|
|
inbound_client = InboundClient(agent, app.logger)
|
|
|
-# outbound_client = OutboundClient(agent, app.logger)
|
|
|
+outbound_client = OutboundClient(agent, app.logger)
|
|
|
call_service = CallService(inbound_client, app.logger)
|
|
|
agent_service = AgentService(inbound_client, app.logger)
|
|
|
agent_oper_service = AgentOperService(inbound_client, app.logger)
|
|
@@ -66,13 +66,13 @@ def get_init_config():
|
|
|
"""获取初始化配置"""
|
|
|
try:
|
|
|
data = request.get_json()
|
|
|
- param = AgentActionRequest.from_json(data=data)
|
|
|
+ param = AgentActionRequest.from_json(data)
|
|
|
res = agent_service.get_and_check(param)
|
|
|
return success_response(res)
|
|
|
|
|
|
except Exception as e:
|
|
|
print("Exception occurred: %s", str(e))
|
|
|
- return {"error": "An error occurred", "details": str(e)}, 500
|
|
|
+ return error_response(e)
|
|
|
|
|
|
|
|
|
@app.route('/open/agent/check-in', methods=['POST'])
|
|
@@ -80,12 +80,12 @@ def check_in():
|
|
|
"""坐席签入"""
|
|
|
try:
|
|
|
data = request.get_json()
|
|
|
- param = AgentActionRequest.from_json(data=data)
|
|
|
+ param = AgentActionRequest.from_json(data)
|
|
|
res = agent_oper_service.checkin(param)
|
|
|
return success_response(res)
|
|
|
except Exception as e:
|
|
|
print("Exception occurred: %s", str(e))
|
|
|
- return {"error": "An error occurred", "details": str(e)}, 500
|
|
|
+ return error_response(e)
|
|
|
|
|
|
|
|
|
@app.route('/open/agent/check-out', methods=['POST'])
|
|
@@ -93,11 +93,12 @@ def check_out():
|
|
|
"""坐席签出"""
|
|
|
try:
|
|
|
data = request.get_json()
|
|
|
- param = AgentActionRequest.from_json(data=data)
|
|
|
- return agent_oper_service.checkout(param)
|
|
|
+ param = AgentActionRequest.from_json(data)
|
|
|
+ res= agent_oper_service.checkout(param)
|
|
|
+ return success_response(res)
|
|
|
except Exception as e:
|
|
|
print("Exception occurred: %s", str(e))
|
|
|
- return {"error": "An error occurred", "details": str(e)}, 500
|
|
|
+ return error_response(e)
|
|
|
|
|
|
|
|
|
@app.route('/open/agent/busy', methods=['POST'])
|
|
@@ -105,11 +106,12 @@ def busy():
|
|
|
"""坐席置忙"""
|
|
|
try:
|
|
|
data = request.get_json()
|
|
|
- param = AgentActionRequest.from_json(data=data)
|
|
|
- return agent_oper_service.busy(param)
|
|
|
+ param = AgentActionRequest.from_json(data)
|
|
|
+ res= agent_oper_service.busy(param)
|
|
|
+ return success_response(res)
|
|
|
except Exception as e:
|
|
|
print("Exception occurred: %s", str(e))
|
|
|
- return {"error": "An error occurred", "details": str(e)}, 500
|
|
|
+ return error_response(e)
|
|
|
|
|
|
|
|
|
@app.route('/open/agent/idle', methods=['POST'])
|
|
@@ -117,8 +119,9 @@ def idle():
|
|
|
"""坐席置闲"""
|
|
|
try:
|
|
|
data = request.get_json()
|
|
|
- param = AgentActionRequest.from_json(data=data)
|
|
|
- return agent_oper_service.idle(param)
|
|
|
+ param = AgentActionRequest.from_json(data)
|
|
|
+ res = agent_oper_service.idle(param)
|
|
|
+ return success_response(res)
|
|
|
except Exception as e:
|
|
|
print("Exception occurred: %s", str(e))
|
|
|
return {"error": "An error occurred", "details": str(e)}, 500
|
|
@@ -129,7 +132,7 @@ def turn_on():
|
|
|
"""接通"""
|
|
|
try:
|
|
|
data = request.get_json()
|
|
|
- param = AgentActionRequest.from_json(data=data)
|
|
|
+ param = AgentActionRequest.from_json(data)
|
|
|
return agent_oper_service.checkin(param)
|
|
|
except Exception as e:
|
|
|
print("Exception occurred: %s", str(e))
|
|
@@ -141,7 +144,7 @@ def hang_up():
|
|
|
"""挂断"""
|
|
|
try:
|
|
|
data = request.get_json()
|
|
|
- param = AgentActionRequest.from_json(data=data)
|
|
|
+ param = AgentActionRequest.from_json(data)
|
|
|
res = call_service.hangup(param)
|
|
|
return success_response(res)
|
|
|
except Exception as e:
|