diff --git a/twilio_integration/fixtures/custom_field.json b/twilio_integration/fixtures/custom_field.json index f02b174..55508b4 100644 --- a/twilio_integration/fixtures/custom_field.json +++ b/twilio_integration/fixtures/custom_field.json @@ -11,63 +11,10 @@ "description": null, "docstatus": 0, "doctype": "Custom Field", - "dt": "Voice Call Settings", + "dt": "Event", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "twilio_number", - "fieldtype": "Select", - "hidden": 0, - "hide_border": 0, - "hide_days": 0, - "hide_seconds": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_preview": 0, - "in_standard_filter": 0, - "insert_after": "call_receiving_device", - "label": "Twilio Number", - "length": 0, - "mandatory_depends_on": null, - "modified": "2020-12-09 08:06:16.330327", - "name": "Voice Call Settings-twilio_number", - "no_copy": 0, - "non_negative": 0, - "options": null, - "parent": null, - "parentfield": null, - "parenttype": null, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "print_width": null, - "read_only": 0, - "read_only_depends_on": null, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "translatable": 1, - "unique": 0, - "width": null - }, - { - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "collapsible_depends_on": null, - "columns": 0, - "default": null, - "depends_on": "eval: doc.channel==='WhatsApp'", - "description": "To use WhatsApp for Business, initialize Twilio Settings.", - "docstatus": 0, - "doctype": "Custom Field", - "dt": "Notification", - "fetch_from": null, - "fetch_if_empty": 0, - "fieldname": "twilio_number", + "fieldname": "custom_call_log", "fieldtype": "Link", "hidden": 0, "hide_border": 0, @@ -79,28 +26,32 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "slack_webhook_url", - "label": "Twilio Number", + "insert_after": "repeat_this_event", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Call Log", "length": 0, - "mandatory_depends_on": "eval: doc.channel==='WhatsApp'", - "modified": "2020-10-26 11:05:12.231781", - "name": "Notification-twilio_number", + "link_filters": null, + "mandatory_depends_on": null, + "modified": "2025-01-09 23:19:10.458697", + "module": null, + "name": "Event-custom_call_log", "no_copy": 0, "non_negative": 0, - "options": "Communication Medium", - "parent": null, - "parentfield": null, - "parenttype": null, + "options": "Call Log", "permlevel": 0, + "placeholder": null, "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "print_width": null, - "read_only": 0, + "read_only": 1, "read_only_depends_on": null, "report_hide": 0, "reqd": 0, "search_index": 0, + "show_dashboard": 0, + "sort_options": 0, "translatable": 0, "unique": 0, "width": null diff --git a/twilio_integration/hooks.py b/twilio_integration/hooks.py index 4cf7fe6..7eceb08 100644 --- a/twilio_integration/hooks.py +++ b/twilio_integration/hooks.py @@ -99,6 +99,15 @@ # "on_trash": "method" # } # } +fixtures = [ + { + "dt": "Custom Field", + "filters": [ + ["name", "in", ["Event-custom_call_log"]] + ] + } +] + # Scheduled Tasks # --------------- diff --git a/twilio_integration/public/js/twilio_call_handler.js b/twilio_integration/public/js/twilio_call_handler.js index f02a448..1236c46 100644 --- a/twilio_integration/public/js/twilio_call_handler.js +++ b/twilio_integration/public/js/twilio_call_handler.js @@ -1,3 +1,6 @@ +var con +var call_start=0 +let def="" var onload_script = function() { frappe.provide('frappe.phone_call'); frappe.provide('frappe.twilio_conn_dialog_map') @@ -104,6 +107,7 @@ var onload_script = function() { } function update_call_log(conn, status="Completed") { + con=conn if (!conn.parameters.CallSid) return frappe.call({ "method": "twilio_integration.twilio_integration.api.update_call_log", @@ -115,6 +119,7 @@ var onload_script = function() { } function call_screen(conn) { + con=conn frappe.call({ type: "GET", method: "twilio_integration.twilio_integration.api.get_contact_details", @@ -127,8 +132,126 @@ var onload_script = function() { } }); } + } + +async function change_status_complete(sell_type) + { + + let fields= [ + { + "label": 'Call Rating', + "fieldname": "call_rating", + "fieldtype": "Rating", + }, + { + "label": 'Request Call Review', + "fieldname": "request_call_review", + "fieldtype": "Check", + }, + { + "fieldname": "cb1", + "fieldtype": "Column Break", + }, + { + "label": 'Reviewer', + "fieldname": "reviewer", + "fieldtype": "Link", + "options":"User" + }, + { + "fieldname": "cb2", + "fieldtype": "Column Break", + }, + { + "label": 'Call Notes', + "fieldname": "call_notes", + "fieldtype": "Small Text", + } + ] + await frappe.db.get_value("Selling Step",sell_type, "create_event", function(value) { + console.log("$$$$$$$$$$$$$$$",value.create_event) + if (value.create_event==1){ + + fields.push({ + "label": 'Events', + "fieldname": "Sb1", + "fieldtype": "Section Break", + },{ + "label": 'NEXT STEP', + "fieldname": "selling_step", + "fieldtype": "Link", + "options":"Selling Step", + "reqd":1 + }, + { + "label": 'Starts On', + "fieldname": "starts_on", + "fieldtype": "Datetime", + "reqd":1 + }, + { + "label": 'Subject', + "fieldname": "subject", + "fieldtype": "Data", + "reqd":1 + }, + { + "fieldname": "cb3", + "fieldtype": "Column Break", + }, + { + "label": 'Descriptions', + "fieldname": "descriptions", + "fieldtype": "Small Text", + "reqd":1 + }) + } + console.log("$$$$$$$$$$$$$$$444555dhjdghjdfhjdfhjfdhyyyyyyyyyyy",fields) + console.log("trigger cdhdhhdjhfdhjdf") + console.log("uuuuuuuuuuuuuuuuuuuuuuuuuuuu",con.parameters.CallSid) + + }) + + console.log("outside before dialg",fields) + var d = new frappe.ui.Dialog({ + static: 1, + fields: fields, + primary_action: function(values) { + + d.hide(); + if (!con.parameters.CallSid) return + frappe.call({ + "method": "twilio_integration.twilio_integration.api.set_call_details", + "args": { + "call_sid": con.parameters.CallSid, + "sell_type":sell_type, + "values": values + } + }) + frappe.call({ + "method": "twilio_integration.twilio_integration.api.create_event", + "args": { + "call_ref": con.parameters.CallSid, + "values": values, + "sell_type":sell_type + } + }) + + + + + }, + primary_action_label: __('Submit') + }); + d.get_close_btn().hide(); + d.show(); + + + + }; + function get_status_indicator(status) { const indicator_map = { 'available': 'blue', @@ -192,6 +315,7 @@ class TwilioCallPopup { } setup_dialpad(conn) { + con=conn let me = this; this.dialpad = new DialPad({ twilio_device: this.twilio_device, @@ -250,12 +374,20 @@ class TwilioCallPopup { } class OutgoingCallPopup extends TwilioCallPopup { + constructor(twilio_device, phone_numbers) { super(twilio_device); this.phone_numbers = phone_numbers; } - show() { + async show() { + if(cur_frm.doc.custom_selling_step){ + await frappe.db.get_value("Selling Step", cur_frm.doc.custom_selling_step, "call_instructions", function(value) { + console.log(value) + def = value.call_instructions + }) + } + this.dialog = new frappe.ui.Dialog({ 'static': 1, 'title': __('Make a Call'), @@ -270,6 +402,31 @@ class OutgoingCallPopup extends TwilioCallPopup { 'default': this.phone_numbers[0], 'read_only': 0, 'reqd': 1 + }, + { + 'fieldname': 'sell_type', + 'label': 'Sell Type', + 'fieldtype': 'Link', + 'options': "Selling Step", + "default":cur_frm.doc.custom_selling_step, + "reqd":1, + onchange: () => { + let z=this.dialog + const sell_type = this.dialog.get_value('sell_type'); + + frappe.db.get_value("Selling Step", sell_type, "call_instructions", function(value) { + console.log(value) + z.set_value('instructions',value.call_instructions); + }) + + } + }, + { + 'fieldname': 'instructions', + 'label': 'Instructions', + 'fieldtype': 'Text Editor', + "read_only": 1, + "default":def } ], primary_action: () => { @@ -285,12 +442,14 @@ class OutgoingCallPopup extends TwilioCallPopup { frappe.twilio_conn_dialog_map[outgoingConnection] = this; outgoingConnection.on("ringing", function () { me.set_header('ringing'); + call_start=1 }); } else { this.dialog.enable_primary_action(); } }, primary_action_label: __('Call'), + secondary_action: () => { if (this.twilio_device) { this.twilio_device.disconnectAll(); @@ -316,6 +475,12 @@ class OutgoingCallPopup extends TwilioCallPopup { this.dialog.get_secondary_btn().addClass('hide'); this.dialog.show(); this.dialog.get_close_btn().show(); + this.dialog.get_close_btn().on('click', () => { + if (call_start== 1){ + console.log("$$$$$$$$$$$$$Calling") + change_status_complete(this.dialog.get_value('sell_type')) + } + }); } } diff --git a/twilio_integration/twilio_integration/api.py b/twilio_integration/twilio_integration/api.py index b04ee51..660c688 100644 --- a/twilio_integration/twilio_integration/api.py +++ b/twilio_integration/twilio_integration/api.py @@ -1,3 +1,4 @@ +import json from werkzeug.wrappers import Response import frappe @@ -40,7 +41,7 @@ def voice(**kwargs): def _get_caller_number(caller): identity = caller.replace('client:', '').strip() user = Twilio.emailid_from_identity(identity) - return frappe.db.get_value('Voice Call Settings', user, 'twilio_number') + return frappe.db.get_value('Voice Call Settings', user, 'twilio_number'),user args = frappe._dict(kwargs) twilio = Twilio.connect() @@ -52,19 +53,23 @@ def _get_caller_number(caller): # Generate TwiML instructions to make a call from_number = _get_caller_number(args.Caller) - resp = twilio.generate_twilio_dial_response(from_number, args.To) - - call_details = TwilioCallDetails(args, call_from=from_number) - create_call_log(call_details) + resp = twilio.generate_twilio_dial_response(from_number[0], args.To) + + call_details = TwilioCallDetails(args, call_from=from_number[0]) + abc=create_call_log(call_details) + if abc: + doc=frappe.get_doc("Call Log",abc) + doc.custom_voip_user=from_number[1] + doc.save(ignore_permissions=True) return Response(resp.to_xml(), mimetype='text/xml') @frappe.whitelist(allow_guest=True) def twilio_incoming_call_handler(**kwargs): args = frappe._dict(kwargs) call_details = TwilioCallDetails(args) - create_call_log(call_details) - - resp = IncomingCall(args.From, args.To).process() + abc=create_call_log(call_details) + resp = IncomingCall(args.From, args.To).process(abc) + return Response(resp.to_xml(), mimetype='text/xml') @frappe.whitelist() @@ -77,6 +82,7 @@ def create_call_log(call_details: TwilioCallDetails): call_log.flags.ignore_permissions = True call_log.save() frappe.db.commit() + return call_log.name @frappe.whitelist() def update_call_log(call_sid, status=None): @@ -89,6 +95,7 @@ def update_call_log(call_sid, status=None): call_log = frappe.get_doc("Call Log", call_sid) call_log.status = status or TwilioCallDetails.get_call_status(call_details.status) call_log.duration = call_details.duration + call_log.custom_call_info=str(call_details.__dict__) call_log.flags.ignore_permissions = True call_log.save() frappe.db.commit() @@ -136,4 +143,50 @@ def whatsapp_message_status_callback(**kwargs): args = frappe._dict(kwargs) if frappe.db.exists({'doctype': 'WhatsApp Message', 'id': args.MessageSid, 'from_': args.From, 'to': args.To}): message = frappe.get_doc('WhatsApp Message', {'id': args.MessageSid, 'from_': args.From, 'to': args.To}) - message.db_set('status', args.MessageStatus.title()) \ No newline at end of file + message.db_set('status', args.MessageStatus.title()) +@frappe.whitelist() +def set_call_details(call_sid,sell_type,values): + """Update call log status. + """ + twilio = Twilio.connect() + if not (twilio and frappe.db.exists("Call Log", call_sid)): return + a=json.loads(values) + call_log = frappe.get_doc("Call Log", call_sid) + call_log.custom_ratings=a.get("call_ratings") + call_log.custom_request_call_review=a.get("request_call_review") + call_log.custom_reviewer=a.get("reviewer") + call_log.custom_sell_type=sell_type + call_log.custom_call_notes=a.get("call_notes") + call_log.flags.ignore_permissions = True + call_log.save() + frappe.db.commit() + + +@frappe.whitelist() +def create_event(call_ref,values,sell_type): + values=json.loads(values) + if values.get("selling_step"): + doc=frappe.get_doc("Selling Step",sell_type) + if doc.create_event==1: + call_log = frappe.get_doc("Call Log", call_ref) + event=frappe.new_doc("Event") + event.starts_on=values.get("starts_on") + event.subject=values.get("subject") + event.event_category="Call" + event.event_type="Private" + event.description=values.get("descriptions") + event.custom_call_log=call_ref + if call_log.links: + for link in call_log.links: + event.append("event_participants", { + "reference_doctype": link.link_doctype, + "reference_docname": link.link_name + }) + event.flags.ignore_permissions = True + event.save() + frappe.db.commit() +# @frappe.whitelist() +# def fetch_contact(doc,method): +# if doc.type=="Incoming": +# doc=frappe.get_doc("Contact Phone",{"phone":doc.}) + diff --git a/twilio_integration/twilio_integration/custom/call_log.json b/twilio_integration/twilio_integration/custom/call_log.json new file mode 100644 index 0000000..b69227d --- /dev/null +++ b/twilio_integration/twilio_integration/custom/call_log.json @@ -0,0 +1,582 @@ +{ + "custom_fields": [ + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "creation": "2024-02-20 17:44:26.851730", + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "dt": "Call Log", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_voip_user", + "fieldtype": "Link", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "idx": 6, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "call_received_by", + "is_system_generated": 0, + "is_virtual": 0, + "label": "VOIP User", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-02-20 17:44:26.851730", + "modified_by": "Administrator", + "module": null, + "name": "Call Log-custom_voip_user", + "no_copy": 0, + "non_negative": 0, + "options": "User", + "owner": "Administrator", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "creation": "2024-03-03 23:27:00.323837", + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "dt": "Call Log", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_call_info", + "fieldtype": "Text", + "hidden": 1, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "idx": 7, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "custom_voip_user", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Call Info", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-03-03 23:27:00.323837", + "modified_by": "Administrator", + "module": null, + "name": "Call Log-custom_call_info", + "no_copy": 0, + "non_negative": 0, + "options": null, + "owner": "Administrator", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 1, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 1, + "unique": 0, + "width": null + }, + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "creation": "2024-05-27 15:17:32.888906", + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "dt": "Call Log", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_call_ratings", + "fieldtype": "Rating", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "idx": 24, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "custom_call_details", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Call Ratings", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-05-27 15:17:32.888906", + "modified_by": "ajogdand@dexciss.com", + "module": null, + "name": "Call Log-custom_call_ratings", + "no_copy": 0, + "non_negative": 0, + "options": null, + "owner": "ajogdand@dexciss.com", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "creation": "2024-05-27 15:17:33.171741", + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "dt": "Call Log", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_request_call_review", + "fieldtype": "Check", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "idx": 26, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "custom_call_ratings", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Request Call Review", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-05-27 15:17:33.171741", + "modified_by": "ajogdand@dexciss.com", + "module": null, + "name": "Call Log-custom_request_call_review", + "no_copy": 0, + "non_negative": 0, + "options": null, + "owner": "ajogdand@dexciss.com", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "creation": "2024-05-27 15:17:33.450913", + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "dt": "Call Log", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_reviewer", + "fieldtype": "Link", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "idx": 27, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "custom_request_call_review", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Reviewer", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-05-27 15:17:33.450913", + "modified_by": "ajogdand@dexciss.com", + "module": null, + "name": "Call Log-custom_reviewer", + "no_copy": 0, + "non_negative": 0, + "options": "User", + "owner": "ajogdand@dexciss.com", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "creation": "2024-05-27 15:17:34.018099", + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "dt": "Call Log", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_call_notes", + "fieldtype": "Markdown Editor", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "idx": 29, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "custom_sell_type", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Call Notes", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-05-27 15:17:34.018099", + "modified_by": "ajogdand@dexciss.com", + "module": null, + "name": "Call Log-custom_call_notes", + "no_copy": 0, + "non_negative": 0, + "options": null, + "owner": "ajogdand@dexciss.com", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "creation": "2024-05-28 15:19:52.352083", + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "dt": "Call Log", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_sell_type", + "fieldtype": "Link", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "idx": 28, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "custom_column_break_tpfyr", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Sell Type", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-05-28 15:19:52.352083", + "modified_by": "ajogdand@dexciss.com", + "module": null, + "name": "Call Log-custom_sell_type", + "no_copy": 0, + "non_negative": 0, + "options": "Selling Step", + "owner": "ajogdand@dexciss.com", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "creation": "2024-05-28 15:20:36.210581", + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "dt": "Call Log", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_call_details", + "fieldtype": "Tab Break", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "idx": 23, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "links", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Call Details", + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-05-28 15:20:36.210581", + "modified_by": "ajogdand@dexciss.com", + "module": null, + "name": "Call Log-custom_call_details", + "no_copy": 0, + "non_negative": 0, + "options": null, + "owner": "ajogdand@dexciss.com", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "creation": "2024-05-28 15:20:36.492968", + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "dt": "Call Log", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_column_break_tpfyr", + "fieldtype": "Column Break", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "idx": 27, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "custom_reviewer", + "is_system_generated": 0, + "is_virtual": 0, + "label": null, + "length": 0, + "mandatory_depends_on": null, + "modified": "2024-05-28 15:20:36.492968", + "modified_by": "ajogdand@dexciss.com", + "module": null, + "name": "Call Log-custom_column_break_tpfyr", + "no_copy": 0, + "non_negative": 0, + "options": null, + "owner": "ajogdand@dexciss.com", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null + } + ], + "custom_perms": [], + "doctype": "Call Log", + "links": [], + "property_setters": [ + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "creation": "2024-05-28 15:20:36.036720", + "default_value": null, + "doc_type": "Call Log", + "docstatus": 0, + "doctype_or_field": "DocType", + "field_name": null, + "idx": 0, + "is_system_generated": 0, + "modified": "2024-05-28 15:20:36.036720", + "modified_by": "ajogdand@dexciss.com", + "module": null, + "name": "Call Log-main-field_order", + "owner": "ajogdand@dexciss.com", + "property": "field_order", + "property_type": "Data", + "row_name": null, + "value": "[\"call_details_section\", \"id\", \"from\", \"to\", \"call_received_by\", \"custom_voip_user\", \"custom_call_info\", \"employee_user_id\", \"medium\", \"start_time\", \"end_time\", \"column_break_4\", \"type\", \"customer\", \"status\", \"duration\", \"recording_url\", \"recording_html\", \"section_break_11\", \"type_of_call\", \"summary\", \"section_break_19\", \"links\", null, \"custom_call_ratings\", \"custom_request_call_review\", \"custom_reviewer\", null, \"custom_sell_type\", \"custom_call_notes\"]" + } + ], + "sync_on_migrate": 1 +} \ No newline at end of file diff --git a/twilio_integration/twilio_integration/twilio_handler.py b/twilio_integration/twilio_integration/twilio_handler.py index d81654e..8899ed6 100644 --- a/twilio_integration/twilio_integration/twilio_handler.py +++ b/twilio_integration/twilio_integration/twilio_handler.py @@ -122,7 +122,7 @@ def __init__(self, from_number, to_number, meta=None): self.to_number = to_number self.meta = meta - def process(self): + def process(self,abc): """Process the incoming call * Figure out who is going to pick the call (call attender) * Check call attender settings and forward the call to Phone @@ -135,10 +135,19 @@ def process(self): resp = VoiceResponse() resp.say(_('Agent is unavailable to take the call, please call after some time.')) return resp - + if attender['call_receiving_device'] == 'Phone': + if abc: + user=frappe.db.get_value("User",{"mobile_no":attender['mobile_no']},["name"]) + doc=frappe.get_doc("Call Log",abc) + doc.custom_voip_user=user + doc.save(ignore_permissions=True) return twilio.generate_twilio_dial_response(self.from_number, attender['mobile_no']) else: + if abc: + doc=frappe.get_doc("Call Log",abc) + doc.custom_voip_user=attender['name'] + doc.save(ignore_permissions=True) return twilio.generate_twilio_client_response(twilio.safe_identity(attender['name'])) class TwilioCallDetails: