Skip to content

Commit

Permalink
Adds the integration Twilio voice
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicola Lanzilotto committed Nov 13, 2024
1 parent 10fbce0 commit 95b9d30
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 143 deletions.
27 changes: 26 additions & 1 deletion src/app/integrations/integrations.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export class IntegrationsComponent implements OnInit, OnDestroy {
smsApp.runURL = environment['smsConfigUrl'];
smsApp.channel = "sms";
} else {
telegramApp = {
smsApp = {
runURL: environment['smsConfigUrl'],
channel: "sms"
}
Expand Down Expand Up @@ -316,6 +316,31 @@ export class IntegrationsComponent implements OnInit, OnDestroy {
}
this.availableApps.push(voiceApp);

// -------

let voiceTwiloApp = response.apps.find(a => (a.title === APPS_TITLE.TWILIO_VOICE && a.version === "v2"));

if (environment['voiceTwilioConfigUrl']) {
if (voiceTwiloApp) {
voiceTwiloApp.runURL = environment['voiceTwilioConfigUrl'];
voiceTwiloApp.channel = "voice-twilio";
} else {
voiceTwiloApp = {
voiceTwiloApp: environment['voiceTwilioConfigUrl'],
channel: "voice-twilio"
}
}
}
else {
if (voiceTwiloApp) {
voiceTwiloApp.channel = "voice-twilio";
}
}
this.availableApps.push(voiceTwiloApp);

// -------


resolve(true);

}, (error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class ExtIntegrationComponent implements OnInit {
) { }

ngOnInit(): void {
this.logger.log("Starting External App Integration");
console.log("Starting External App Integration");


}
Expand Down
5 changes: 4 additions & 1 deletion src/app/integrations/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export enum INTEGRATIONS_KEYS {
TELEGRAM = 'telegram',
TWILIO = 'twilio',
VXML_VOICE = 'voice',
TWILIO_VOICE = "voice-twilio",
WHATSAPP = 'whatsapp',
ZAPIER = 'zapier',
ZENDESK = 'zendesk',
Expand All @@ -29,7 +30,8 @@ export enum APPS_TITLE {
MESSENGER = "Facebook Messenger",
TELEGRAM = "Telegram",
VXML_VOICE = "VXML Voice",
TWILIO_SMS = "Twilio SMS"
TWILIO_SMS = "Twilio SMS",
TWILIO_VOICE = "Twilio Voice"
}

export enum INTEGRATIONS_CATEGORIES {
Expand Down Expand Up @@ -107,6 +109,7 @@ export const INTEGRATION_LIST_ARRAY = [
{ name: "Telegram", category: INTEGRATIONS_CATEGORIES.CHANNEL, key: INTEGRATIONS_KEYS.TELEGRAM, src_icon: "assets/img/int/telegram-icon.png", src_logo: "assets/img/int/telegram-logo.png", pro: false, plan: 'Sandbox' },
{ name: "Twilio SMS", category: INTEGRATIONS_CATEGORIES.CHANNEL, key: INTEGRATIONS_KEYS.TWILIO_SMS, src_icon: "assets/img/int/twilio-sms.png", src_logo: "assets/img/int/twilio-sms.png", pro: false, plan: 'Premium' },
{ name: "VXML Voice", category: INTEGRATIONS_CATEGORIES.CHANNEL, key: INTEGRATIONS_KEYS.VXML_VOICE, src_icon: "assets/img/int/vxml-icon.png", src_logo: "assets/img/int/vxml-icon.png", pro: true, plan: 'Premium' },
{ name: "Twilio Voice", category: INTEGRATIONS_CATEGORIES.CHANNEL, key: INTEGRATIONS_KEYS.TWILIO_VOICE, src_icon: "assets/img/int/voice-twilio-icon.png", src_logo: "assets/img/int/voice-twilio-icon.png", pro: true, plan: 'Premium' },
{ name: "WhatsApp", category: INTEGRATIONS_CATEGORIES.CHANNEL, key: INTEGRATIONS_KEYS.WHATSAPP, src_icon: "assets/img/int/whatsapp-icon.png", src_logo: "assets/img/int/whatsapp-logo.png", pro: true, plan: 'Premium' },
//{ name: "Zapier", category: INTEGRATIONS_CATEGORIES.INT_PLAT, key: INTEGRATIONS_KEYS.ZAPIER, src_icon: "assets/img/int/zapier-icon.png", src_logo: "assets/img/int/zapier-logo.svg", pro: true, plan: 'Basic' },
//{ name: "Zendesk", category: INTEGRATIONS_CATEGORIES.LIVE_CHAT, key: INTEGRATIONS_KEYS.ZENDESK, src_icon: "assets/img/int/zendesk-icon.png", src_logo: "assets/img/int/zendesk-logo.png", pro: true, plan: 'Premium' },
Expand Down
2 changes: 2 additions & 0 deletions src/app/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ export const CHANNELS_NAME = {
MESSANGER: 'messenger',
WHATSAPP: 'whatsapp',
VOICE_VXML: 'voice-vxml',
VOICE_TWILIO: 'voice-twilio',
SMS_TWILIO: 'sms-twilio',
}

Expand All @@ -741,6 +742,7 @@ export const CHANNELS = [
{ id: CHANNELS_NAME.MESSANGER, name: 'Facebook Messenger' },
{ id: CHANNELS_NAME.WHATSAPP, name: 'WhatsApp' },
{ id: CHANNELS_NAME.VOICE_VXML, name: 'Voice' },
{ id: CHANNELS_NAME.VOICE_TWILIO, name: 'Voice' },
{ id: CHANNELS_NAME.SMS_TWILIO, name: 'SMS' },

]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@
conversationTypeValue === CHANNELS_NAME.WHATSAPP ||
conversationTypeValue === CHANNELS_NAME.EMAIL ||
conversationTypeValue === CHANNELS_NAME.VOICE_VXML ||
conversationTypeValue === CHANNELS_NAME.VOICE_TWILIO ||
conversationTypeValue === CHANNELS_NAME.SMS_TWILIO" class="applied-filter">
<span *ngIf="conversationTypeValue === CHANNELS_NAME.CHAT21 ">
Chat
Expand Down Expand Up @@ -696,6 +697,9 @@
<span *ngIf="conversationTypeValue === CHANNELS_NAME.VOICE_VXML">
Voice
</span>
<span *ngIf="conversationTypeValue === CHANNELS_NAME.VOICE_TWILIO">
Voice
</span>
<span *ngIf="conversationTypeValue === CHANNELS_NAME.SMS_TWILIO">
SMS
</span>
Expand Down Expand Up @@ -1370,6 +1374,7 @@
<span *ngIf="request?.channel?.name === CHANNELS_NAME.MESSANGER">Facebook Messenger </span>
<span *ngIf="request?.channel?.name === CHANNELS_NAME.WHATSAPP"> WhatsApp </span>
<span *ngIf="request?.channel?.name === CHANNELS_NAME.VOICE_VXML"> Voice </span>
<span *ngIf="request?.channel?.name === CHANNELS_NAME.VOICE_TWILIO"> Voice </span>
<span *ngIf="request?.channel?.name === CHANNELS_NAME.SMS_TWILIO"> SMS </span>
</span>
</div>
Expand Down Expand Up @@ -1557,7 +1562,7 @@
<!-- ---------------------------------------- -->
<!-- Channel - Voice -->
<!-- ---------------------------------------- -->
<span *ngIf="request?.channel?.name === CHANNELS_NAME.VOICE_VXML" class="tool_tip">
<span *ngIf="request?.channel?.name === CHANNELS_NAME.VOICE_VXML || request?.channel?.name === CHANNELS_NAME.VOICE_TWILIO" class="tool_tip">

<img style="width: 24px;height: 24px;" src="assets/img/channel_icons/voice.svg"
class="img-fluid">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,63 @@ export class HistoryAndNortConvsComponent extends WsSharedComponent implements O
});
}

getCurrentProject() {
this.auth.project_bs.subscribe((project) => {
this.logger.log('[HISTORY & NORT-CONVS] - PRJCT FROM SUBSCRIPTION TO AUTH SERV ', project)
if (project) {
this.projectId = project._id;
this.findCurrentProjectAmongAll(this.projectId)
}
});
}

findCurrentProjectAmongAll(projectId: string) {

this.projectService.getProjects().subscribe((projects: any) => {
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - projects ', projects);
// const current_selected_prjct = projects.filter(prj => prj.id_project.id === projectId);
// this.logger.log('[SIDEBAR] - GET PROJECTS - current_selected_prjct ', current_selected_prjct);

this.current_selected_prjct = projects.find(prj => prj.id_project.id === projectId);
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - current_selected_prjct ', this.current_selected_prjct);
if (this.current_selected_prjct.id_project.profile) {
const projectProfile = this.current_selected_prjct.id_project.profile
// this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - current_selected_prjct > projectProfile ', projectProfile);
// this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - current_selected_prjct > conversationType ', this.conversationType);
if (projectProfile && projectProfile.customization && projectProfile.customization.voice && projectProfile.customization.voice === true) {
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - current_selected_prjct > projectProfile.customization.voice ', projectProfile.customization.voice);
if(this.payIsVisible) {
let voice_vxml_index = this.conversationType.findIndex(x => x['id'] === CHANNELS_NAME.VOICE_VXML);
this.conversationType.splice(voice_vxml_index, 1);
} else {
let voice_twilio_index = this.conversationType.findIndex(x => x['id'] === CHANNELS_NAME.VOICE_TWILIO);
this.conversationType.splice(voice_twilio_index, 1);
}
// if (projectProfile.customization.voice) {

// } else {
// this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - current_selected_prjct > projectProfile.customization.voice ', projectProfile.customization.voice);
// }
} else {
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - current_selected_prjct > projectProfile.customization ', projectProfile.customization);
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - conversationType ', this.conversationType);
let voice_vxml_index = this.conversationType.findIndex(x => x['id'] === CHANNELS_NAME.VOICE_VXML);
let voice_twilio_index = this.conversationType.findIndex(x => x['id'] === CHANNELS_NAME.VOICE_TWILIO);
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - current_selected_prjct > CHANNELS_NAME.VOICE_VXML ++++ 1 index', voice_vxml_index);
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - current_selected_prjct > CHANNELS_NAME.VOICE_TWILIO ++++ 1 index', voice_twilio_index);
this.conversationType.splice(voice_vxml_index, 1);
this.conversationType.splice(voice_twilio_index, 1);
}

}

this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - projects ', projects);
}, error => {
this.logger.error('[HISTORY & NORT-CONVS] - GET PROJECTS - ERROR: ', error);
}, () => {
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS * COMPLETE * ');
});
}

getCurrentUrlLoadRequests() {
const currentUrl = this.router.url;
Expand Down Expand Up @@ -1403,7 +1460,7 @@ export class HistoryAndNortConvsComponent extends WsSharedComponent implements O
// User Agent
// -------------------------------------------------------------------
const user_agent_result = this.parseUserAgent(request.userAgent);
// console.log('[HISTORY & NORT-CONVS] - user_agent_result ', user_agent_result);
// this.logger.log('[HISTORY & NORT-CONVS] - user_agent_result ', user_agent_result);
const ua_browser = user_agent_result.browser.name + ' ' + user_agent_result.browser.version
request['ua_browser'] = ua_browser;
const ua_os = user_agent_result.os.name + ' ' + user_agent_result.os.version
Expand Down Expand Up @@ -1948,8 +2005,6 @@ export class HistoryAndNortConvsComponent extends WsSharedComponent implements O
this.conversation_type = 'messenger'
}



if (this.conversation_type === 'email') {
// this.conversationTypeValue = 'email'
this.conversation_type = 'email'
Expand All @@ -1970,6 +2025,11 @@ export class HistoryAndNortConvsComponent extends WsSharedComponent implements O
// this.conversationTypeValue = 'whatsapp'
this.conversation_type = 'voice-vxml'
}

if (this.conversation_type === 'voice-twilio') {
// this.conversationTypeValue = 'whatsapp'
this.conversation_type = 'voice-twilio'
}
}


Expand Down Expand Up @@ -2930,52 +2990,7 @@ export class HistoryAndNortConvsComponent extends WsSharedComponent implements O
}


getCurrentProject() {
this.auth.project_bs.subscribe((project) => {
this.logger.log('[HISTORY & NORT-CONVS] - PRJCT FROM SUBSCRIPTION TO AUTH SERV ', project)
if (project) {
this.projectId = project._id;
this.findCurrentProjectAmongAll(this.projectId)
}
});
}

findCurrentProjectAmongAll(projectId: string) {

this.projectService.getProjects().subscribe((projects: any) => {
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - projects ', projects);
// const current_selected_prjct = projects.filter(prj => prj.id_project.id === projectId);
// this.logger.log('[SIDEBAR] - GET PROJECTS - current_selected_prjct ', current_selected_prjct);

this.current_selected_prjct = projects.find(prj => prj.id_project.id === projectId);
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - current_selected_prjct ', this.current_selected_prjct);
if (this.current_selected_prjct.id_project.profile) {
const projectProfile = this.current_selected_prjct.id_project.profile
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - current_selected_prjct > projectProfile ', projectProfile);
if (projectProfile && projectProfile.customization && projectProfile.customization.voice && projectProfile.customization.voice === true) {
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - current_selected_prjct > projectProfile.customization.voice ', projectProfile.customization.voice);
// if (projectProfile.customization.voice) {

// } else {
// this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - current_selected_prjct > projectProfile.customization.voice ', projectProfile.customization.voice);
// }
} else {
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - current_selected_prjct > projectProfile.customization ', projectProfile.customization);
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - conversationType ', this.conversationType);
let index = this.conversationType.findIndex(x => x['id'] === CHANNELS_NAME.VOICE_VXML);
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - current_selected_prjct > CHANNELS_NAME.VOICE_VXML ++++ 1 index', index);
this.conversationType.splice(index, 1);
}

}

this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS - projects ', projects);
}, error => {
this.logger.error('[HISTORY & NORT-CONVS] - GET PROJECTS - ERROR: ', error);
}, () => {
this.logger.log('[HISTORY & NORT-CONVS] - GET PROJECTS * COMPLETE * ');
});
}


getRequestText(text: string): string {
if (text) {
Expand Down
Loading

0 comments on commit 95b9d30

Please sign in to comment.