|
@@ -541,7 +541,7 @@ class OutboundClient:
|
|
# 检查白名单
|
|
# 检查白名单
|
|
_bucket_call_type = 0
|
|
_bucket_call_type = 0
|
|
con.execute("answer", "", device_id)
|
|
con.execute("answer", "", device_id)
|
|
- self.build_call_info(call_id, device_id, new_device_id, destination=None, bucket_type=_bucket_call_type, **kwargs)
|
|
|
|
|
|
+ self.build_call_info(CallType.INCOMING_AGENT_CALL.code, call_id, device_id, new_device_id, destination=None, bucket_type=_bucket_call_type, **kwargs)
|
|
self.server.agent.acd_service.transfer_to_agent(call_id, device_id)
|
|
self.server.agent.acd_service.transfer_to_agent(call_id, device_id)
|
|
elif bucket and bucket.name == 'AI':
|
|
elif bucket and bucket.name == 'AI':
|
|
#转到ai机器人
|
|
#转到ai机器人
|
|
@@ -549,13 +549,13 @@ class OutboundClient:
|
|
service_category = 1
|
|
service_category = 1
|
|
destination = self.server.agent.register(**kwargs)
|
|
destination = self.server.agent.register(**kwargs)
|
|
self.server.logger.info("device_id=%s, destination=%s, new_device_id=%s" % (device_id, destination, new_device_id))
|
|
self.server.logger.info("device_id=%s, destination=%s, new_device_id=%s" % (device_id, destination, new_device_id))
|
|
- self.build_call_info(call_id, device_id, new_device_id, str(destination), bucket_type=_bucket_call_type, **kwargs)
|
|
|
|
|
|
+ self.build_call_info(CallType.INCOMING_BOT_CALL.code, call_id, device_id, new_device_id, str(destination), bucket_type=_bucket_call_type, **kwargs)
|
|
self.server.cache.add_device_user_part(device_id, destination)
|
|
self.server.cache.add_device_user_part(device_id, destination)
|
|
con.execute("bridge", "{sip_h_P-LIBRA-CallId=%s,sip_h_P-LIBRA-DeviceId=%s,origination_uuid=%s}user/%s" % (call_id, new_device_id, new_device_id, destination), device_id)
|
|
con.execute("bridge", "{sip_h_P-LIBRA-CallId=%s,sip_h_P-LIBRA-DeviceId=%s,origination_uuid=%s}user/%s" % (call_id, new_device_id, new_device_id, destination), device_id)
|
|
else:
|
|
else:
|
|
# 传统服务
|
|
# 传统服务
|
|
con.execute("answer", "", device_id)
|
|
con.execute("answer", "", device_id)
|
|
- self.build_call_info(call_id, device_id, new_device_id, destination=None, bucket_type=_bucket_call_type, **kwargs)
|
|
|
|
|
|
+ self.build_call_info(CallType.INCOMING_AGENT_CALL.code, call_id, device_id, new_device_id, destination=None, bucket_type=_bucket_call_type, **kwargs)
|
|
self.server.agent.acd_service.transfer_to_agent(call_id, device_id)
|
|
self.server.agent.acd_service.transfer_to_agent(call_id, device_id)
|
|
|
|
|
|
registry.CALL_INCOMING_REQUESTS.labels(f"{_bucket_call_type}").inc()
|
|
registry.CALL_INCOMING_REQUESTS.labels(f"{_bucket_call_type}").inc()
|
|
@@ -578,29 +578,32 @@ class OutboundClient:
|
|
# # Ignore the error if socket is already closed
|
|
# # Ignore the error if socket is already closed
|
|
# pass
|
|
# pass
|
|
|
|
|
|
- def build_call_info(self, call_id, device_id, new_device_id, destination, bucket_type, **kwargs):
|
|
|
|
|
|
+ def build_call_info(self, call_type, call_id, device_id, new_device_id, destination, bucket_type, **kwargs):
|
|
caller = kwargs.get('Channel-Caller-ID-Number')
|
|
caller = kwargs.get('Channel-Caller-ID-Number')
|
|
called = destination
|
|
called = destination
|
|
now = datetime.now().timestamp()
|
|
now = datetime.now().timestamp()
|
|
|
|
|
|
call_info = CallInfo(call_id=call_id, agent_key=destination,
|
|
call_info = CallInfo(call_id=call_id, agent_key=destination,
|
|
caller=caller, called=called, direction=Direction.INBOUND.code,
|
|
caller=caller, called=called, direction=Direction.INBOUND.code,
|
|
- call_type=CallType.BOT_CALL.code, call_time=now,
|
|
|
|
|
|
+ call_type=call_type, call_time=now,
|
|
uuid1=call_id, uuid2=device_id, saas_id=saasId, bucket_type=bucket_type,
|
|
uuid1=call_id, uuid2=device_id, saas_id=saasId, bucket_type=bucket_type,
|
|
core_uuid=None, cti_flow_id=None, conference=None, group_id=None, hidden_customer=0, caller_display=None, called_display=None, number_location=None, agent_name=None, login_type=None, ivr_id=None, task_id=None, media_host=None, sip_server=None, client_host=None, record=None, record2=None, record_time=None, answer_flag=None, wait_time=None, answer_count=0, hangup_dir=None, sdk_hangup=0, hangup_code=None, answer_time=None, end_time=None, talk_time=None, first_queue_time=None, queue_start_time=None, queue_end_time=None, overflow_count=0, cdr_notify_url=None, queue_level=None, transfer_agent=None,device_list=[], device_info_map = {}, follow_data = {}, process_data = {}, next_commands=[], call_details=[])
|
|
core_uuid=None, cti_flow_id=None, conference=None, group_id=None, hidden_customer=0, caller_display=None, called_display=None, number_location=None, agent_name=None, login_type=None, ivr_id=None, task_id=None, media_host=None, sip_server=None, client_host=None, record=None, record2=None, record_time=None, answer_flag=None, wait_time=None, answer_count=0, hangup_dir=None, sdk_hangup=0, hangup_code=None, answer_time=None, end_time=None, talk_time=None, first_queue_time=None, queue_start_time=None, queue_end_time=None, overflow_count=0, cdr_notify_url=None, queue_level=None, transfer_agent=None,device_list=[], device_info_map = {}, follow_data = {}, process_data = {}, next_commands=[], call_details=[])
|
|
device_custom = DeviceInfo(device_id=device_id, call_time=now,
|
|
device_custom = DeviceInfo(device_id=device_id, call_time=now,
|
|
call_id=call_id, device_type=DeviceType.CUSTOMER.code,
|
|
call_id=call_id, device_type=DeviceType.CUSTOMER.code,
|
|
agent_key=destination, cdr_type=CdrType.OUTBOUND.code,
|
|
agent_key=destination, cdr_type=CdrType.OUTBOUND.code,
|
|
cti_flow_id=None, conference=None, agent_name=None, from_agent=None, caller=None, called=None, display=None, called_location=None, caller_location=None, ring_start_time=None, ring_end_time=None, answer_time=None, bridge_time=None, end_time=None, talk_time=None, sip_protocol=None, channel_name=None, hangup_cause=None, ring_cause=None, sip_status=None, record=None, record_time=None, record_start_time=None, state=None, apparent_number=None, caller_display=None)
|
|
cti_flow_id=None, conference=None, agent_name=None, from_agent=None, caller=None, called=None, display=None, called_location=None, caller_location=None, ring_start_time=None, ring_end_time=None, answer_time=None, bridge_time=None, end_time=None, talk_time=None, sip_protocol=None, channel_name=None, hangup_cause=None, ring_cause=None, sip_status=None, record=None, record_time=None, record_start_time=None, state=None, apparent_number=None, caller_display=None)
|
|
- device_bot = DeviceInfo(device_id=new_device_id, call_time=now,
|
|
|
|
- call_id=call_id, device_type=DeviceType.ROBOT.code,
|
|
|
|
- agent_key=destination, cdr_type=CdrType.INBOUND.code,
|
|
|
|
- cti_flow_id=None, conference=None, agent_name=None, from_agent=None, caller=None, called=None, display=None, called_location=None, caller_location=None, ring_start_time=None, ring_end_time=None, answer_time=None, bridge_time=None, end_time=None, talk_time=None, sip_protocol=None, channel_name=None, hangup_cause=None, ring_cause=None, sip_status=None, record=None, record_time=None, record_start_time=None, state=None, apparent_number=None, caller_display=None)
|
|
|
|
-
|
|
|
|
call_info.device_list.append(device_id)
|
|
call_info.device_list.append(device_id)
|
|
- call_info.device_list.append(new_device_id)
|
|
|
|
# call_info.next_commands.append(NextCommand(device_id, NextType.NEXT_CALL_BRIDGE.code, new_device_id))
|
|
# call_info.next_commands.append(NextCommand(device_id, NextType.NEXT_CALL_BRIDGE.code, new_device_id))
|
|
- call_info.device_info_map = {device_id: device_custom, new_device_id: device_bot}
|
|
|
|
|
|
+ call_info.device_info_map = {device_id: device_custom}
|
|
|
|
+
|
|
|
|
+ if CallType.INCOMING_BOT_CALL.code == call_type:
|
|
|
|
+ device_bot = DeviceInfo(device_id=new_device_id, call_time=now,
|
|
|
|
+ call_id=call_id, device_type=DeviceType.ROBOT.code,
|
|
|
|
+ agent_key=destination, cdr_type=CdrType.INBOUND.code,
|
|
|
|
+ cti_flow_id=None, conference=None, agent_name=None, from_agent=None, caller=None, called=None, display=None, called_location=None, caller_location=None, ring_start_time=None, ring_end_time=None, answer_time=None, bridge_time=None, end_time=None, talk_time=None, sip_protocol=None, channel_name=None, hangup_cause=None, ring_cause=None, sip_status=None, record=None, record_time=None, record_start_time=None, state=None, apparent_number=None, caller_display=None)
|
|
|
|
+ call_info.device_list.append(new_device_id)
|
|
|
|
+ call_info.device_info_map = {new_device_id: device_bot}
|
|
|
|
+
|
|
self.server.cache.add_call_info(call_info)
|
|
self.server.cache.add_call_info(call_info)
|
|
return call_info
|
|
return call_info
|
|
|
|
|