mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 18:59:08 +00:00
refator: Rename files and move code
This commit is contained in:
41
erpnext/erpnext_integrations/exotel_integration.py
Normal file
41
erpnext/erpnext_integrations/exotel_integration.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import frappe
|
||||
from erpnext.crm.doctype.utils import get_document_with_phone_number
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def handle_incoming_call(*args, **kwargs):
|
||||
incoming_phone_number = kwargs.get('CallFrom')
|
||||
|
||||
contact = get_document_with_phone_number(incoming_phone_number)
|
||||
last_communication = get_last_communication(incoming_phone_number, contact)
|
||||
call_log = create_call_log(kwargs)
|
||||
data = {
|
||||
'contact': contact,
|
||||
'call_payload': kwargs,
|
||||
'last_communication': last_communication,
|
||||
'call_log': call_log
|
||||
}
|
||||
|
||||
frappe.publish_realtime('incoming_call', data)
|
||||
|
||||
|
||||
def get_last_communication(phone_number, contact):
|
||||
# frappe.get_all('Communication', filter={})
|
||||
return {}
|
||||
|
||||
def create_call_log(call_payload):
|
||||
communication = frappe.new_doc('Communication')
|
||||
communication.subject = frappe._('Call from {}').format(call_payload.get("CallFrom"))
|
||||
communication.communication_medium = 'Phone'
|
||||
communication.send_email = 0
|
||||
communication.phone_no = call_payload.get("CallFrom")
|
||||
communication.comment_type = 'Info'
|
||||
communication.communication_type = 'Communication'
|
||||
communication.status = 'Open'
|
||||
communication.sent_or_received = 'Received'
|
||||
communication.content = 'call_payload'
|
||||
communication.communication_date = call_payload.get('StartTime')
|
||||
# communication.sid = call_payload.get('CallSid')
|
||||
# communication.exophone = call_payload.get('CallTo')
|
||||
# communication.call_receiver = call_payload.get('DialWhomNumber')
|
||||
communication.save(ignore_permissions=True)
|
||||
return communication
|
||||
Reference in New Issue
Block a user