diff --git a/crm/twilio/api.py b/crm/twilio/api.py index 4656caa1..a1c061de 100644 --- a/crm/twilio/api.py +++ b/crm/twilio/api.py @@ -1,7 +1,7 @@ from werkzeug.wrappers import Response +import json import frappe -from twilio.rest import Client from .twilio_handler import Twilio, IncomingCall @frappe.whitelist() @@ -58,3 +58,24 @@ def twilio_incoming_call_handler(**kwargs): resp = IncomingCall(args.From, args.To).process() return Response(resp.to_xml(), mimetype='text/xml') + + +@frappe.whitelist(allow_guest=True) +def get_call_info(**kwargs): + """This is a webhook called when the outgoing call status changes. + E.g. 'initiated' 'ringing', 'in-progress', 'completed' etc. + """ + args = frappe._dict(kwargs) + call_info = { + 'ParentCallSid': args.ParentCallSid, + 'CallSid': args.CallSid, + 'CallStatus': args.CallStatus, + 'CallDuration': args.CallDuration, + 'From': args.From, + 'To': args.To, + } + + client = Twilio.get_twilio_client() + client.calls(args.ParentCallSid).user_defined_messages.create( + content=json.dumps(call_info) + ) \ No newline at end of file diff --git a/crm/twilio/twilio_handler.py b/crm/twilio/twilio_handler.py index 944e7430..1206cc74 100644 --- a/crm/twilio/twilio_handler.py +++ b/crm/twilio/twilio_handler.py @@ -70,8 +70,8 @@ class Twilio: """ return identity.replace('(at)', '@') - def get_recording_status_callback_url(self): - url_path = "/api/method/twilio_integration.twilio_integration.api.update_recording_info" + def get_call_status_callback_url(self): + url_path = "/api/method/crm.twilio.api.get_call_info" return get_public_url(url_path) def generate_twilio_dial_response(self, from_number: str, to_number: str): @@ -84,7 +84,12 @@ class Twilio: # recording_status_callback=self.get_recording_status_callback_url(), # recording_status_callback_event='completed' ) - dial.number(to_number) + dial.number( + to_number, + status_callback_event='initiated ringing answered completed', + status_callback=self.get_call_status_callback_url(), + status_callback_method='POST' + ) resp.append(dial) return resp diff --git a/crm/twilio/utils.py b/crm/twilio/utils.py index 0112bdb0..664b1083 100644 --- a/crm/twilio/utils.py +++ b/crm/twilio/utils.py @@ -2,7 +2,7 @@ from frappe.utils import get_url def get_public_url(path: str=None): - return get_url(path) + return get_url().split(":8", 1)[0] + path def merge_dicts(d1: dict, d2: dict): diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 53d64c63..ebeb5d0d 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,11 +1,14 @@ diff --git a/frontend/src/components/AppSidebar.vue b/frontend/src/components/AppSidebar.vue index 712e06ee..61bc1bea 100644 --- a/frontend/src/components/AppSidebar.vue +++ b/frontend/src/components/AppSidebar.vue @@ -1,25 +1,33 @@ diff --git a/frontend/src/components/CallUI.vue b/frontend/src/components/CallUI.vue new file mode 100644 index 00000000..5ad179a8 --- /dev/null +++ b/frontend/src/components/CallUI.vue @@ -0,0 +1,435 @@ + + + + + diff --git a/frontend/src/components/CommunicationArea.vue b/frontend/src/components/CommunicationArea.vue index 58f8b18e..3f5114f5 100644 --- a/frontend/src/components/CommunicationArea.vue +++ b/frontend/src/components/CommunicationArea.vue @@ -10,7 +10,7 @@ @@ -47,78 +47,6 @@ /> - - - - -
-
-
Incoming Call...
- -
-
- -
{{ getUser().full_name }}
-
+917666980887
-
-
-
- - -
-
-
- - diff --git a/frontend/src/components/Icons/DialpadIcon.vue b/frontend/src/components/Icons/DialpadIcon.vue new file mode 100644 index 00000000..8fa62ab2 --- /dev/null +++ b/frontend/src/components/Icons/DialpadIcon.vue @@ -0,0 +1,73 @@ + diff --git a/frontend/src/components/Icons/DragIcon1.vue b/frontend/src/components/Icons/DragIcon1.vue new file mode 100644 index 00000000..bf71373c --- /dev/null +++ b/frontend/src/components/Icons/DragIcon1.vue @@ -0,0 +1,16 @@ + diff --git a/frontend/src/components/Icons/MinimizeIcon.vue b/frontend/src/components/Icons/MinimizeIcon.vue new file mode 100644 index 00000000..dbdba9f7 --- /dev/null +++ b/frontend/src/components/Icons/MinimizeIcon.vue @@ -0,0 +1,24 @@ + diff --git a/pyproject.toml b/pyproject.toml index 731a2294..a07fd686 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ readme = "README.md" dynamic = ["version"] dependencies = [ # "frappe~=15.0.0" # Installed and managed by bench. - "twilio==6.44.2" + "twilio==8.5.0" ] [build-system]