diff --git a/crm/integrations/exotel/handler.py b/crm/integrations/exotel/handler.py index 78ee2942..1f01837c 100644 --- a/crm/integrations/exotel/handler.py +++ b/crm/integrations/exotel/handler.py @@ -109,6 +109,7 @@ def make_a_call(to_number, from_number=None, caller_id=None): to_number=call_payload.get("To"), medium=call_payload.get("PhoneNumberSid"), call_type="Outgoing", + agent=frappe.session.user, ) return response.json() @@ -154,7 +155,7 @@ def create_call_log( from_number, to_number, medium, - agent=frappe.session.user, + agent, status="Ringing", call_type="Incoming", ): diff --git a/frontend/src/components/Telephony/ExotelCallUI.vue b/frontend/src/components/Telephony/ExotelCallUI.vue index 1eb86cf2..6ff354c6 100644 --- a/frontend/src/components/Telephony/ExotelCallUI.vue +++ b/frontend/src/components/Telephony/ExotelCallUI.vue @@ -231,9 +231,10 @@ import NoteIcon from '@/components/Icons/NoteIcon.vue' import TaskIcon from '@/components/Icons/TaskIcon.vue' import TaskPanel from '@/components/Telephony/TaskPanel.vue' import CountUpTimer from '@/components/CountUpTimer.vue' -import { TextEditor, Avatar, Button, call, createResource } from 'frappe-ui' +import { createToast } from '@/utils' import { globalStore } from '@/stores/global' import { useDraggable, useWindowSize } from '@vueuse/core' +import { TextEditor, Avatar, Button, call, createResource } from 'frappe-ui' import { ref, onBeforeUnmount, watch } from 'vue' import { useRouter } from 'vue-router' @@ -362,12 +363,24 @@ function updateWindowHeight(condition) { function makeOutgoingCall(number) { phoneNumber.value = number - callStatus.value = 'Calling...' - showCallPopup.value = true - showSmallCallPopup.value = false - call('crm.integrations.exotel.handler.make_a_call', { - to_number: phoneNumber.value, + createResource({ + url: 'crm.integrations.exotel.handler.make_a_call', + params: { to_number: phoneNumber.value }, + auto: true, + onSuccess() { + callStatus.value = 'Calling...' + showCallPopup.value = true + showSmallCallPopup.value = false + }, + onError(err) { + createToast({ + title: 'Error', + text: err.messages[0], + icon: 'x', + iconClasses: 'text-red-600', + }) + }, }) } @@ -446,8 +459,11 @@ function updateStatus(data) { } else if ( data.EventType == 'terminal' && data.Direction == 'outbound-api' && - data.Status == 'no-answer' && - data['Legs[1][Status]'] == 'no-answer' + (data.Status == 'no-answer' || data.Status == 'busy') && + (data['Legs[1][Status]'] == 'no-answer' || + data['Legs[0][Status]'] == 'no-answer' || + data['Legs[1][Status]'] == 'busy' || + data['Legs[0][Status]'] == 'busy') ) { counterUp.value.stop() return 'No answer'