Skip to content
81 changes: 16 additions & 65 deletions twilio_integration/fixtures/custom_field.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href=\"#Form/Twilio Settings\">Twilio Settings</a>.",
"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,
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions twilio_integration/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@
# "on_trash": "method"
# }
# }
fixtures = [
{
"dt": "Custom Field",
"filters": [
["name", "in", ["Event-custom_call_log"]]
]
}
]


# Scheduled Tasks
# ---------------
Expand Down
167 changes: 166 additions & 1 deletion twilio_integration/public/js/twilio_call_handler.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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',
Expand Down Expand Up @@ -192,6 +315,7 @@ class TwilioCallPopup {
}

setup_dialpad(conn) {
con=conn
let me = this;
this.dialpad = new DialPad({
twilio_device: this.twilio_device,
Expand Down Expand Up @@ -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'),
Expand All @@ -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: () => {
Expand All @@ -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();
Expand All @@ -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")
Copy link
Copy Markdown
Member

@Vigneshsekar Vigneshsekar Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you still working on this? There are many console log statements. Please remove them.

change_status_complete(this.dialog.get_value('sell_type'))
}
});
}
}

Expand Down
Loading