repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
design-studio
github_2023
Tiledesk
typescript
CdsPanelButtonConfigurationComponent.onChangeTypeButton
onChangeTypeButton(typeOfButton: { label: string, value: TYPE_BUTTON }) { this.buttonType = this.button.type = typeOfButton.value; this.buttonAction = null; if(this.button.__idConnector){ const fromId = this.button.__idConnector; // this.connectorService.deleteConnectorWithIDStartingWith(fromId); // let parts = this.button.idConnector.split('/'); // if(parts && parts.length>1){ // let actionId = parts[1]; // this.logger.log('deleteConnectorsFromActionByActionId: ', actionId); // this.connectorService.deleteConnectorsFromActionByActionId(actionId); // } } this.checkAndSaveButton(); }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-button-configuration/cds-panel-button-configuration.component.ts#L231-L245
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelButtonConfigurationComponent.onBlur
public onBlur(event){ // setTimeout(() => { this.checkAndSaveButton(); // }, 100); }
/** * onBlur * @param event */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-button-configuration/cds-panel-button-configuration.component.ts#L256-L260
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelButtonConfigurationComponent.onChangeUrl
onChangeUrl(text: string) { this.buttonUrl = text; // this.checkAndSaveButton(); }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-button-configuration/cds-panel-button-configuration.component.ts#L263-L266
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelButtonConfigurationComponent.onChangeGoToBlock
onChangeGoToBlock(event: {name: string, value: string}){ this.logger.log('onChangeGoToBlock: ', event); this.buttonAction = event.value; if(this.buttonAttributes && this.buttonAttributes !== '{}'){ this.button.action = this.buttonAction + JSON.stringify(this.buttonAttributes); } else { this.button.action = this.buttonAction; } this.button.__isConnected = true; const fromId = this.button.__idConnector; let toId = ''; const posId = this.button.action.indexOf("#"); if (posId !== -1) { toId = this.button.action.slice(posId+1); this.button.__idConnection = fromId+"/"+toId; } this.logger.log('onChangeGoToBlock: ', this.button); // IMPORTANT! non salvare la modifica dei connettori ma solo la modifica della action! this.connectorService.deleteConnectorWithIDStartingWith(fromId, false, false); this.connectorService.createNewConnector(fromId, toId); this.checkAndSaveButton(); }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-button-configuration/cds-panel-button-configuration.component.ts#L269-L290
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelButtonConfigurationComponent.onChangeAttributes
onChangeAttributes(attributes:any){ // this.logger.log('attributes: ', this.button, attributes); this.button.attributes = attributes; if(attributes && attributes !== '{}'){ this.button.action = this.buttonAction + JSON.stringify(attributes); } else { this.button.action = this.buttonAction; } // this.button.action = this.buttonAction + JSON.stringify(attributes); delete(this.button.attributes); this.checkAndSaveButton(); // this.saveButton.emit(this.button); }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-button-configuration/cds-panel-button-configuration.component.ts#L308-L320
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelElementsComponent.onAddNewElement
onAddNewElement(){ // this.addNewElement.emit(); }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-elements/cds-panel-elements.component.ts#L83-L85
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelIntentListComponent.ngOnDestroy
ngOnDestroy() { if (this.subscriptionListOfIntents) { this.subscriptionListOfIntents.unsubscribe(); } if (this.subscriptionIntent) { this.subscriptionIntent.unsubscribe(); } }
/** ngOnDestroy */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-intent-list/cds-panel-intent-list.component.ts#L64-L72
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelIntentListComponent.setSubscriptions
private setSubscriptions(){ this.subscriptionListOfIntents = this.intentService.getIntents().subscribe(intents => { this.logger.log('[cds-panel-intent-list] --- AGGIORNATO ELENCO INTENTS ',intents); if(intents && intents.length>0){ this.initialize(intents); } }); /** SUBSCRIBE TO THE INTENT SELECTED */ this.subscriptionIntent = this.intentService.behaviorIntent.subscribe((intent: Intent) => { this.logger.log('[cds-panel-intent-list] --- AGGIORNATO INTENT ',intent); if (intent) { if (!intent['attributesChanged']) { this.idSelectedIntent = intent.intent_id; } } }); }
/** * Creo una sottoscrizione all'array di INTENT per averlo sempre aggiornato * ad ogni modifica (aggiunta eliminazione di un intent) */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-intent-list/cds-panel-intent-list.component.ts#L80-L97
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelIntentListComponent.initialize
private initialize(intents){ // intents = this.intentService.hiddenEmptyIntents(intents); this.internalIntents = intents.filter(obj => ( obj.intent_display_name.trim() === TYPE_INTENT_NAME.DISPLAY_NAME_START || obj.intent_display_name.trim() === TYPE_INTENT_NAME.DISPLAY_NAME_DEFAULT_FALLBACK)); this.defaultIntents = intents.filter(obj => ( obj.intent_display_name.trim() !== TYPE_INTENT_NAME.DISPLAY_NAME_START && obj.intent_display_name.trim() !== TYPE_INTENT_NAME.DISPLAY_NAME_DEFAULT_FALLBACK)); this.internalIntents = moveItemToPosition(this.internalIntents, TYPE_INTENT_NAME.DISPLAY_NAME_START, 0); this.internalIntents = moveItemToPosition(this.internalIntents, TYPE_INTENT_NAME.DISPLAY_NAME_DEFAULT_FALLBACK, 1); this.filteredIntents = this.defaultIntents; if(!this.defaultIntents || this.defaultIntents.length == 0){ this.intentService.setDefaultIntentSelected(); this.idSelectedIntent = this.intentService.intentSelected.intent_id; } this.listOfIntents = intents; const resp = this.listOfIntents.find((intent) => intent.intent_id === this.idSelectedIntent); if(!resp){ this.idSelectedIntent = null; } }
/** initialize */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-intent-list/cds-panel-intent-list.component.ts#L100-L116
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelIntentListComponent.onGetIconForName
onGetIconForName(name: string){ let icon = this.ICON_DEFAULT; if (name.trim() === TYPE_INTENT_NAME.DISPLAY_NAME_START) { icon = this.ICON_ROCKET; } else if (name.trim() === TYPE_INTENT_NAME.DISPLAY_NAME_DEFAULT_FALLBACK) { icon = this.ICON_UNDO; } return icon; }
/** onGetIconForName */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-intent-list/cds-panel-intent-list.component.ts#L122-L130
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelIntentListComponent.onLiveSearch
onLiveSearch(text: string) { this.filteredIntents = this.defaultIntents.filter(element => element.intent_display_name.toLowerCase().includes(text.toLowerCase())); }
/** Search a block... */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-intent-list/cds-panel-intent-list.component.ts#L133-L135
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelIntentListComponent.onSelectIntent
onSelectIntent(intent: Intent) { this.idSelectedIntent = intent.intent_id; this.selectIntent.emit(intent); }
/** onSelectIntent */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-intent-list/cds-panel-intent-list.component.ts#L138-L141
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelIntentListComponent.onDeleteIntent
onDeleteIntent(intent: Intent) { this.deleteIntent.emit(intent); }
/** onDeleteIntent */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-intent-list/cds-panel-intent-list.component.ts#L144-L146
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPopupComponent.diplayPopup
diplayPopup() { const hasClosedPopup = this.appStorageService.getItem('hasclosedcdspopup') this.logger.log('[CDS DSBRD] hasClosedPopup', hasClosedPopup) if (hasClosedPopup === null) { this.setPosition() this.popup_visibility = 'block' this.logger.log('[CDS DSBRD] popup_visibility', this.popup_visibility) } if (hasClosedPopup === 'true') { this.popup_visibility = 'none' } }
/* POP UP */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/utils/cds-popup/cds-popup.component.ts#L34-L45
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.setMapOfConnectors
public async setMapOfConnectors(listOfIntents){ this.mapOfConnectors = await this.createMapOfConnectors(listOfIntents); return this.mapOfConnectors; }
/*************************************************/
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L38-L41
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.createConnectorDraft
createConnectorDraft(detail){ this.connectorDraft = { fromId: detail.fromId, fromPoint: detail.fromPoint, toPoint: detail.toPoint, menuPoint: detail.menuPoint, target: detail.target } }
/** * createConnectorDraft * @param detail */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L47-L55
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.addConnectorToList
public addConnectorToList(connector){ this.listOfConnectors[connector.id] = connector; this.logger.log('[CONNECTOR-SERV] addConnector:: connector ', connector) }
/** * addConnectorToList * @param connector */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L61-L64
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.createNewConnector
async createNewConnector(fromId:string, toId:string){ this.logger.log('[CONNECTOR-SERV] createNewConnector:: fromId:', fromId, 'toId:', toId); let elFrom = await isElementOnTheStage(fromId); // sync let elTo = await isElementOnTheStage(toId); // sync this.logger.log('[CONNECTOR-SERV] createNewConnector:: ', elFrom, elTo); if (elFrom && elTo) { const fromPoint = this.tiledeskConnectors.elementLogicCenter(elFrom); const toPoint = this.tiledeskConnectors.elementLogicTopLeft(elTo); this.tiledeskConnectors.createConnector(fromId, toId, fromPoint, toPoint, false, true, null); } }
/** * createNewConnector * @param fromId * @param toId * */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L72-L82
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.createConnectors
public createConnectors(intents){ this.listOfIntents = intents; intents.forEach(intent => { this.createConnectorsOfIntent(intent); }); }
/** * createConnectors * @param intents * */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L89-L94
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.createConnectorFromId
public async createConnectorFromId(fromId, toId, notify=false, attributes=null) { const connectorID = fromId+'/'+toId; const isConnector = document.getElementById(connectorID); if (isConnector) { this.logger.log('[CONNECTOR-SERV] il connettore esiste già', connectorID); this.tiledeskConnectors.updateConnectorsOutOfItent(connectorID); return true; } let fromEle = document.getElementById(fromId); if(!fromEle) { fromEle = await isElementOnTheStage(fromId); // sync this.logger.log('[CONNECTOR-SERV] isOnTheStage fromEle:', fromEle); } let toEle = document.getElementById(toId); if(!toEle) { toEle = await isElementOnTheStage(toId); // sync this.logger.log('[CONNECTOR-SERV] isOnTheStage toEle:', toEle); } if(fromEle && toEle){ const fromPoint = this.tiledeskConnectors.elementLogicCenter(fromEle); const toPoint = this.tiledeskConnectors.elementLogicTopLeft(toEle); this.logger.log('[CONNECTOR-SERV] createConnector attributes:', attributes); this.tiledeskConnectors.createConnector(fromId, toId, fromPoint, toPoint, false, notify, attributes); return true; } else { return false; } }
/** * createConnectorFromId * @param fromId * @param toId * @param save * @returns */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L115-L142
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.createConnectorById
public async createConnectorById(connectorID) { this.logger.log('[CONNECTOR-SERV] createConnectorById: ', connectorID); const isConnector = document.getElementById(connectorID); if (isConnector) { this.logger.log('[CONNECTOR-SERV] createConnectorById il connettore esiste già', connectorID); this.tiledeskConnectors.updateConnectorsOutOfItent(connectorID); return true; } var lastIndex = connectorID.lastIndexOf("/"); if (lastIndex !== -1) { const fromId = connectorID.substring(0, lastIndex); let toId = connectorID.substring(lastIndex + 1); if (toId.startsWith('#')) { toId = toId.substring(1); } let fromEle = document.getElementById(fromId); if(!fromEle) { fromEle = await isElementOnTheStage(fromId); // sync this.logger.log('[CONNECTOR-SERV] isOnTheStageFrom', fromEle); } let toEle = document.getElementById(toId); if(!toEle) { toEle = await isElementOnTheStage(toId); // sync this.logger.log('[CONNECTOR-SERV] isOnTheStageFrom', toEle, toId); } if (toEle && fromEle) { const fromPoint = this.tiledeskConnectors.elementLogicCenter(fromEle); const toPoint = this.tiledeskConnectors.elementLogicTopLeft(toEle); this.logger.log('[CONNECTOR-SERV] createConnectorById createConnector', connectorID); this.tiledeskConnectors.createConnector(fromId, toId, fromPoint, toPoint, false, false, null); return true; } else { return false; } } else { return false; } }
/** * * @param connectorID * @returns */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L149-L186
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.intentExists
private intentExists(intentId){ const response = this.listOfIntents.some((obj) => obj.intent_id === intentId); this.logger.log('[CONNECTOR-SERV] intentExists::', intentId, this.listOfIntents, response); return response; }
/** * * @param intentId */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L193-L197
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.createConnectorsOfIntent
public createConnectorsOfIntent(intent:any){ if(intent.attributes && intent.attributes.nextBlockAction){ let idConnectorFrom = null; let idConnectorTo = null; let nextBlockAction = intent.attributes.nextBlockAction; if(nextBlockAction.intentName && nextBlockAction.intentName !== ''){ idConnectorFrom = intent.intent_id+'/'+nextBlockAction._tdActionId; idConnectorTo = nextBlockAction.intentName.replace("#", ""); if(!this.intentExists(idConnectorTo)){ nextBlockAction.intentName = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] -> CREATE CONNECTOR', idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } if(intent.actions){ intent.actions.forEach(action => { let idConnectorFrom = null; let idConnectorTo = null; this.logger.log('[CONNECTOR-SERV] createConnectors:: ACTION ', action); /** INTENT */ if(action._tdActionType === TYPE_ACTION.INTENT){ // this.logger.log('[CONNECTOR-SERV] intent_display_name', intent.intent_display_name); if(action.intentName && action.intentName !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId; idConnectorTo = action.intentName.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.intentName = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] -> CREATE CONNECTOR', idConnectorFrom, idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** CONNECT BLOCK */ if(action._tdActionType === TYPE_ACTION.CONNECT_BLOCK){ // this.logger.log('[CONNECTOR-SERV] intent_display_name', intent.intent_display_name); if(action.intentName && action.intentName !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId; idConnectorTo = action.intentName.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.intentName = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] -> CREATE CONNECTOR', idConnectorFrom, idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** REPLY RANDOM_REPLY */ if( (action._tdActionType === TYPE_ACTION.REPLY || action._tdActionType === TYPE_ACTION.RANDOM_REPLY) || (action._tdActionType === TYPE_ACTION_VXML.DTMF_FORM || action._tdActionType === TYPE_ACTION_VXML.DTMF_MENU || action._tdActionType === TYPE_ACTION_VXML.BLIND_TRANSFER)){ var buttons = this.findButtons(action); this.logger.log('buttons ----- >', buttons, action); buttons.forEach(button => { // this.logger.log('[CONNECTOR-SERV] button ----- > ', button, button.__idConnector); if(button.type === TYPE_BUTTON.ACTION && button.action){ // const idConnectorFrom = button.__idConnector; if(!button.uid || button.uid === "UUIDV4"){ button.uid = generateShortUID(); } idConnectorFrom = intent.intent_id+"/"+action._tdActionId+"/"+button.uid; this.logger.log('[CONNECTOR-SERV] -> idConnectorFrom', idConnectorFrom); var startIndex = button.action.indexOf('#') + 1; var endIndex = button.action.indexOf('{'); idConnectorTo = button.action.substring(startIndex); if(endIndex>-1){ idConnectorTo = button.action.substring(startIndex, endIndex); } if(!this.intentExists(idConnectorTo)){ button.action = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } }); /** noInput and noMatch block connectors */ if( action.settings && action.settings .noInputIntent && action.settings .noInputIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/noInput'; idConnectorTo = action.settings.noInputIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.settings.noInputIntent = ''; idConnectorTo = null; } this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.settings && action.settings.noMatchIntent && action.settings.noMatchIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/noMatch'; idConnectorTo = action.settings.noMatchIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.settings.noMatchIntent = ''; idConnectorTo = null; } this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** REPLY V2 */ if(action._tdActionType === TYPE_ACTION.REPLYV2){ var buttons = this.findButtons(action); this.logger.log('buttons ----- >', buttons, action); buttons.forEach(button => { // this.logger.log('[CONNECTOR-SERV] button ----- > ', button, button.__idConnector); if(button.type === TYPE_BUTTON.ACTION && button.action){ // const idConnectorFrom = button.__idConnector; if(!button.uid || button.uid === "UUIDV4"){ button.uid = generateShortUID(); } idConnectorFrom = intent.intent_id+"/"+action._tdActionId+"/"+button.uid; this.logger.log('[CONNECTOR-SERV] -> idConnectorFrom', idConnectorFrom); var startIndex = button.action.indexOf('#') + 1; var endIndex = button.action.indexOf('{'); idConnectorTo = button.action.substring(startIndex); if(endIndex>-1){ idConnectorTo = button.action.substring(startIndex, endIndex); } if(!this.intentExists(idConnectorTo)){ button.action = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } }); if(action.noInputIntent && action.noInputIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/noInput'; idConnectorTo = action.noInputIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.noInputIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - REPLY-V2 ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - REPLY-V2 ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.noMatchIntent && action.noMatchIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/noMatch'; idConnectorTo = action.noMatchIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.noMatchIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - REPLY-V2 ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - REPLY-V2 ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** ONLINE_AGENTS */ if(action._tdActionType === TYPE_ACTION.ONLINE_AGENTS || action._tdActionType === TYPE_ACTION.ONLINE_AGENTSV2){ if(action.trueIntent && action.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = action.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - ONLINE_AGENTS ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - ONLINE_AGENTS ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.falseIntent && action.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = action.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - ONLINE_AGENTS ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - ONLINE_AGENTS ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** OPEN_HOURS */ if(action._tdActionType === TYPE_ACTION.OPEN_HOURS){ if(action.trueIntent && action.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = action.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - OPEN_HOURS ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - OPEN_HOURS ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.falseIntent && action.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = action.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - OPEN_HOURS ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - OPEN_HOURS ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** JSON-CONDITION */ if(action._tdActionType === TYPE_ACTION.JSON_CONDITION){ if(action.trueIntent && action.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = action.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - JSON_CONDITION ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - JSON_CONDITION ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.falseIntent && action.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = action.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - JSON_CONDITION ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - JSON_CONDITION ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** ASKGPT */ if(action._tdActionType === TYPE_ACTION.ASKGPT){ if(action.trueIntent && action.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = action.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - ASKGPT ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - ASKGPT ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.falseIntent && action.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = action.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - ASKGPT ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - ASKGPT ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** ASKGPTV2 */ if(action._tdActionType === TYPE_ACTION.ASKGPTV2){ if(action.trueIntent && action.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = action.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - ASKGPTV2 ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - ASKGPTV2 ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.falseIntent && action.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = action.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - ASKGPTV2 ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - ASKGPTV2 ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** GPT-TASK */ if(action._tdActionType === TYPE_ACTION.GPT_TASK){ if(action.trueIntent && action.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = action.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - GPT-TASK ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - GPT-TASK ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.falseIntent && action.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = action.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - GPT-TASK ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - GPT-TASK ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** GPT-ASSISTANT */ if(action._tdActionType === TYPE_ACTION.GPT_ASSISTANT){ if(action.trueIntent && action.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = action.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - GPT-ASSISTANT ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - GPT-ASSISTANT ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.falseIntent && action.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = action.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - GPT-ASSISTANT ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - GPT-ASSISTANT ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** WEB-REQUEST-V2 */ if(action._tdActionType === TYPE_ACTION.WEB_REQUESTV2){ if(action.trueIntent && action.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = action.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - WEB-REQUEST-V2 ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - WEB-REQUEST-V2 ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.falseIntent && action.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = action.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - WEB-REQUEST-V2 ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - WEB-REQUEST-V2 ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** MAKE */ if(action._tdActionType === TYPE_ACTION.MAKE){ if(action.trueIntent && action.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = action.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - WEB-MAKE ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - WEB-MAKE ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.falseIntent && action.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = action.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - WEB-MAKE ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - WEB-MAKE ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** WEB-HUBSPOT */ if(action._tdActionType === TYPE_ACTION.HUBSPOT){ if(action.trueIntent && action.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = action.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - WEB-HUBSPOT ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - WEB-HUBSPOT ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.falseIntent && action.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = action.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - WEB-HUBSPOT ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - WEB-HUBSPOT ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** WEB-CUSTOMERIO */ if(action._tdActionType === TYPE_ACTION.CUSTOMERIO){ if(action.trueIntent && action.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = action.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - WEB-CUSTOMERIO ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - WEB-CUSTOMERIO ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.falseIntent && action.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = action.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - WEB-CUSTOMERIO ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - WEB-CUSTOMERIO ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** WEB-BREVO */ if(action._tdActionType === TYPE_ACTION.BREVO){ if(action.trueIntent && action.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = action.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - WEB-BREVO ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - WEB-BREVO ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.falseIntent && action.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = action.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - WEB-BREVO ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - WEB-BREVO ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** WEB-N8N */ if(action._tdActionType === TYPE_ACTION.N8N){ if(action.trueIntent && action.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = action.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - WEB-N8N ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - WEB-N8N ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.falseIntent && action.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = action.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - WEB-N8N ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - WEB-N8N ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** QAPLA' */ if(action._tdActionType === TYPE_ACTION.QAPLA){ if(action.trueIntent && action.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = action.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - QAPLA ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - QAPLA ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.falseIntent && action.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = action.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - QAPLA ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - QAPLA ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** CAPTURE USER_REPLY */ if(action._tdActionType === TYPE_ACTION.CAPTURE_USER_REPLY){ this.logger.log('[CONNECTOR-SERV] intent_display_name', intent.intent_display_name); if(action.goToIntent && action.goToIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId; idConnectorTo = action.goToIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.goToIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** DTMF_MENU' || DTMF_FORM || SPEECH_FORM */ if(action._tdActionType === TYPE_ACTION_VXML.DTMF_MENU || action._tdActionType === TYPE_ACTION_VXML.DTMF_FORM || action._tdActionType === TYPE_ACTION_VXML.SPEECH_FORM){ let settingCommand: Setting = action.attributes.commands.slice(-1)[0].settings if(settingCommand && settingCommand.noInputIntent && settingCommand.noInputIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/noInput'; idConnectorTo = settingCommand.noInputIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ settingCommand.noInputIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - DTMF_MENU ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - DTMF_MENU ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(settingCommand && settingCommand.noMatchIntent && settingCommand.noMatchIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/noMatch'; idConnectorTo = settingCommand.noMatchIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ settingCommand.noMatchIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - DTMF_MENU ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - DTMF_MENU ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** BLIND TRANSFER' */ if(action._tdActionType === TYPE_ACTION_VXML.BLIND_TRANSFER){ let settingCommand: Setting = action.attributes.commands.slice(-1)[0].settings if(settingCommand && settingCommand.trueIntent && settingCommand.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = settingCommand.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ settingCommand.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - QAPLA ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - QAPLA ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(settingCommand && settingCommand.falseIntent && settingCommand.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = settingCommand.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ settingCommand.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - QAPLA ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - QAPLA ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } /** SEND WHATSAPP */ if(action._tdActionType === TYPE_ACTION.SEND_WHATSAPP){ if(action.trueIntent && action.trueIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/true'; idConnectorTo = action.trueIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.trueIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - ONLINE_AGENTS ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - ONLINE_AGENTS ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } if(action.falseIntent && action.falseIntent !== ''){ idConnectorFrom = intent.intent_id+'/'+action._tdActionId + '/false'; idConnectorTo = action.falseIntent.replace("#", ""); if(!this.intentExists(idConnectorTo)){ action.falseIntent = ''; idConnectorTo = null; } this.logger.log('[CONNECTOR-SERV] - ONLINE_AGENTS ACTION -> idConnectorFrom', idConnectorFrom); this.logger.log('[CONNECTOR-SERV] - ONLINE_AGENTS ACTION -> idConnectorTo', idConnectorTo); // this.createConnectorFromId(idConnectorFrom, idConnectorTo); this.createConnector(intent, idConnectorFrom, idConnectorTo); } } }); } }
/** * refreshConnectorsOfIntent * @param intent * * create connectors from Intent */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L205-L870
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.removeConnectorDraft
public removeConnectorDraft(){ this.connectorDraft = null; this.tiledeskConnectors.removeConnectorDraft(); }
/** * removeConnectorDraft */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L893-L896
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.deleteConnectorsOfBlockThatDontExist
public deleteConnectorsOfBlockThatDontExist(intent_id){ this.tiledeskConnectors.deleteConnectorsOfBlockThatDontExist(intent_id); this.logger.log('[CONNECTOR-SERV] deleteConnectorsOfBlockThatDontExist intent_id ' ,intent_id); }
/** * deleteConnectorsOfBlockThatDontExist * @param intent_id */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L902-L905
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.deleteConnectorsOutOfBlock
public deleteConnectorsOutOfBlock(intent_id, save=false, notify=true){ this.tiledeskConnectors.deleteConnectorsOutOfBlock(intent_id, save, notify); // this.logger.log('[CONNECTOR-SERV] deleteConnectorsOutOfBlock intent_id ' ,intent_id); }
/** * deleteConnectorsOutOfBlock * @param intent_id * @param dispatch */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L912-L915
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.deleteConnectorsOfBlock
public deleteConnectorsOfBlock(intent_id, save=false, notify=false){ this.logger.log('[CONNECTOR-SERV] deleteConnectorsOfBlock intent_id ' ,intent_id); this.tiledeskConnectors.deleteConnectorsOfBlock(intent_id, save, notify); }
/** * deleteConnectorsOfBlock * @param intent_id */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L921-L924
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.deleteConnectorsBrokenOutOfBlock
public deleteConnectorsBrokenOutOfBlock(intent_id){ this.tiledeskConnectors.deleteConnectorsBrokenOutOfBlock(intent_id); this.logger.log('[CONNECTOR-SERV] deleteConnectorsBrokenOutOfBlock intent_id ' ,intent_id ) }
/** * deleteConnectorsBrokenOutOfBlock * @param intent_id */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L930-L933
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.deleteConnectorFromAction
public deleteConnectorFromAction(actionId, connId){ this.tiledeskConnectors.deleteConnectorFromAction(actionId, connId); this.logger.log('[CONNECTOR-SERV] deleteConnectorFromAction actionId ' ,actionId ,' connId ', connId) }
/** * deleteConnectorFromAction * @param actionId * @param connId */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L940-L943
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.deleteConnectorsFromActionByActionId
public deleteConnectorsFromActionByActionId(actionId){ this.tiledeskConnectors.deleteConnectorsFromActionByActionId(actionId); this.logger.log('[CONNECTOR-SERV] deleteConnectorsFromActionByActionId actionId ' ,actionId ) }
/** * deleteConnectorsFromActionByActionId * @param actionId */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L949-L952
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.deleteConnector
public deleteConnector(connectorID, save=false, notify=true) { this.logger.log('[CONNECTOR-SERV] deleteConnector:: connectorID ', connectorID, save, notify); this.deleteConnectorAttributes(connectorID); this.tiledeskConnectors.deleteConnector(connectorID, save, notify); }
/** * deleteConnector * @param connectorID * */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L966-L970
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.deleteConnectorToList
public deleteConnectorToList(connectorID){ // this.logger.log('[CONNECTOR-SERV] deleteConnectorToList:: connectorID ', connectorID) delete this.listOfConnectors[connectorID]; }
/** * * @param connectorID */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L977-L980
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.deleteConnectorWithIDStartingWith
public deleteConnectorWithIDStartingWith(connectorID, save=false, notify=true){ this.logger.log('[CONNECTOR-SERV] deleteConnectorWithIDStartingWith:: ', connectorID, this.tiledeskConnectors.connectors); const isConnector = document.getElementById(connectorID); if (isConnector){ const listOfConnectors = Object.keys(this.tiledeskConnectors.connectors) .filter(key => key.startsWith(connectorID)) .reduce((filteredMap, key) => { filteredMap[key] = this.tiledeskConnectors.connectors[key]; return filteredMap; }, {}); for (const [key, connector] of Object.entries(listOfConnectors)) { this.logger.log('delete connector :: ', key ); this.deleteConnector(key, save, notify); }; } }
/** * eleteConnectorWithIDStartingWith * @param connectorID * @param dispatch * * elimino il connettore creato in precedenza allo stesso punto e lo sostituisco con il nuovo */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L995-L1010
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.updateConnector
public async updateConnector(elementID){ this.logger.log('[CONNECTOR-SERV] movedConnector elementID ' ,elementID ) const elem = await isElementOnTheStage(elementID); // chiamata sincrona // const elem = document.getElementById(elementID); if(elem){ this.logger.log('[CONNECTOR-SERV] aggiorno i connettori: ', elem); //setTimeout(() => { this.tiledeskConnectors.updateConnectorsOutOfItent(elem); //}, 0); } }
/** * updateConnector * @param elementID */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L1033-L1043
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.updateConnectorsOfBlock
public async updateConnectorsOfBlock(elementID){ this.logger.log('[CONNECTOR-SERV] updateConnector2 elementID ' ,elementID); const elem = await isElementOnTheStage(elementID); //sync if(elem){ var cdsConnectors = elem.querySelectorAll('[connector]'); this.logger.log('[CONNECTOR-SERV] elem::', Array.from(cdsConnectors)); const elements = Array.from(cdsConnectors).map((element: HTMLElement) => element); elements.forEach(element => { const fromId = element.id; const connectionId = element.getAttribute('idConnection'); this.logger.log('[CONNECTOR-SERV] element::', element, connectionId, fromId); for (var connectorId in this.tiledeskConnectors.connectors) { if (connectorId.startsWith(fromId)) { this.deleteConnectorById(connectorId); } } if(connectionId){ this.createConnectorById(connectionId); } }); return true; } return true; }
/** * * @param elementID */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L1091-L1114
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.moved
public moved(element, x, y){ this.tiledeskConnectors.moved(element, x, y); // this.logger.log('[CONNECTOR-SERV] moved element ' ,element , ' x ' , x , 'y ', y ) }
/** * moved * @param element * @param x * @param y */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L1139-L1142
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.searchConnectorsInByIntent
public searchConnectorsInByIntent(intent_id: string): Array<any>{ // this.logger.log('[CONNECTOR-SERV] -----> searchConnectorsInOfIntent::: ', intent_id); // this.logger.log('[CONNECTOR-SERV] -----> searchConnectorsInOfIntent::: ', this.tiledeskConnectors.connectors); const connectors = Object.keys(this.tiledeskConnectors.connectors) .filter(key => key.includes(intent_id) && !key.startsWith(intent_id) ) .reduce((filteredMap, key) => { filteredMap[key] = this.tiledeskConnectors.connectors[key]; return filteredMap; }, {}); const arrayConnectors = Object.values(connectors); this.logger.log('[CONNECTOR-SERV] -----> arrayConnectors::: ', arrayConnectors); return arrayConnectors; }
/** * searchConnectorsInOfIntent * @param intent_id * @returns */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L1189-L1201
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.findButtons
public findButtons(obj) { var buttons = []; if(!obj) return buttons; // Verifica se l'oggetto corrente è un array if (Array.isArray(obj)) { // Itera sugli elementi dell'array for (var i = 0; i < obj.length; i++) { // Richiama la funzione findButtons in modo ricorsivo per ogni elemento buttons = buttons.concat(this.findButtons(obj[i])); } } else if (typeof obj === 'object') { // Verifica se l'oggetto corrente ha una proprietà "buttons" if (obj.hasOwnProperty('buttons')) { // Aggiungi l'array di pulsanti alla lista dei pulsanti trovati obj.buttons.forEach(button => { buttons.push(button); }); } // Itera sulle proprietà dell'oggetto for (var key in obj) { // Richiama la funzione findButtons in modo ricorsivo per ogni proprietà buttons = buttons.concat(this.findButtons(obj[key])); } } return buttons; }
/*************************************************/
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L1206-L1231
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ConnectorService.logicPoint
public logicPoint(positions){ return this.tiledeskConnectors.logicPoint(positions); }
/** * * @param positions */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/connector.service.ts#L1238-L1240
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ControllerService.openButtonPanel
public openButtonPanel(button){ this.buttonSource.next(button); }
// Buttons s
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/controller.service.ts#L35-L37
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ControllerService.openIntentDetailPanel
public openIntentDetailPanel(intent){ this.intentSource.next(intent); }
// action intent panel
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/controller.service.ts#L44-L46
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ControllerService.openActionDetailPanel
public openActionDetailPanel(type: TYPE_INTENT_ELEMENT, element: Action | string | Form){ this.actionSource.next({type, element}); }
// action detail panel
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/controller.service.ts#L53-L55
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
ControllerService.closeAddActionMenu
public closeAddActionMenu(){ this.addActionMenu.next(null); }
/** closeAddActionMenu */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/controller.service.ts#L62-L64
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.onChangedConnector
public onChangedConnector(connector){ this.logger.log('[INTENT SERVICE] ::: onChangedConnector:: ', connector); this.changedConnector.next(connector); }
/** * onChangedConnector * funzione chiamata sul 'connector-created', 'connector-deleted' * per notificare alle actions che i connettori sono cambiati */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L95-L98
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.setLiveActiveIntent
public setLiveActiveIntent(intentName: string){ let intent = this.listOfIntents.find((intent) => intent.intent_display_name === intentName); this.liveActiveIntent.next(intent) }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L206-L209
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.getIntents
getIntents() { // this.logger.log('getIntents: ', this.behaviorIntents); return this.behaviorIntents.asObservable(); }
/** * restituisce tutti gli intents */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L214-L217
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.refreshIntents
refreshIntents(){ // this.logger.log("aggiorno elenco intent: ", this.listOfIntents); this.behaviorIntents.next(this.listOfIntents); }
// START DASHBOARD FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L229-L232
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.setPreviousIntentId
setPreviousIntentId(intentId){ // this.intentSelected = intent; this.previousIntentId = intentId; }
/** setPreviousIntentId * imposta quello che è l'intent di partenza quando inizia un drag su una action dell'intent * */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L243-L246
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.getAllIntents
public async getAllIntents(id_faq_kb): Promise<boolean> { return new Promise((resolve, reject) => { this.faqService.getAllFaqByFaqKbId(id_faq_kb).subscribe((faqs: Intent[]) => { if (faqs) { this.patchActionId(faqs); this.listOfIntents = JSON.parse(JSON.stringify(faqs)); this.prevListOfIntent = JSON.parse(JSON.stringify(faqs)); } else { this.listOfIntents = []; this.prevListOfIntent = []; } this.refreshIntents(); resolve(true); }, (error) => { this.logger.error('ERROR: ', error); reject(false); }, () => { resolve(true); }); }); }
/** GET ALL INTENTS */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L265-L285
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.patchActionId
public patchActionId(faqs){ faqs.forEach(element => { element.actions.forEach(action => { if(!action._tdActionId || action._tdActionId === "UUIDV4"){ action._tdActionId = action._tdActionId?action._tdActionId:generateShortUID(); } }); }); }
/** * patchActionId * @param faqs * quando creo un nuovo bot gli elementi welcome e defaultfallback non hanno un _tdActionId * perchè generati dal server. In questo caso è necessario assegnarne uno. */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L294-L302
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.createNewIntent
public createNewIntent(id_faq_kb: string, action: any, pos:any){ let intent = new Intent(); // intent.id_faq_kb = id_faq_kb; const chatbot_id = this.dashboardService.id_faq_kb; intent.id_faq_kb = chatbot_id; intent.attributes.position = pos; intent.intent_display_name = this.setDisplayName(); // let actionIntent = this.createNewAction(TYPE_ACTION.INTENT); // intent.actions.push(actionIntent); intent.actions.push(action); this.logger.log("[INTENT SERVICE] ho creato un nuovo intent contenente l'azione ", intent, " action:", action, " in posizione ", pos); return intent; }
/** create a new intent when drag an action on the stage */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L306-L318
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.setDisplayName
public setDisplayName(){ // let listOfIntents = this.behaviorIntents.getValue(); let displayNames = this.listOfIntents.filter((element) => element.intent_display_name.startsWith(preDisplayName)) .map((element) => element.intent_display_name.replace(preDisplayName, '')); // displayNames = displayNames.slice().sort(); const numbers = displayNames.filter(el => el !== '').map((name) => parseInt(name, 10)); numbers.sort((a, b) => a - b); const lastNumber = numbers[numbers.length - 1]; if(numbers.length>0){ return preDisplayName+(lastNumber+1); } else { return preDisplayName+1; } // const filteredArray = this.listOfIntents.filter((element) => element.intent_display_name.startsWith(this.preDisplayName)); // if(filteredArray.length>0){ // const lastElement = filteredArray.slice(-1)[0]; // const intent_display_name = parseInt(lastElement.intent_display_name.substring(this.preDisplayName.length)); // return this.preDisplayName+(intent_display_name+1); // } else { // return this.preDisplayName+1; // } }
/** generate display name of intent */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L339-L360
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.patchAttributes
patchAttributes( intent: Intent, UndoRedo:boolean = true) { const intentID = intent.id; const attributes = intent.attributes; this.logger.log('[INTENT SERVICE] -> patchAttributes, ', intent); let intentPrev = this.prevListOfIntent.find((item) => item.intent_id === intent.intent_id); if(JSON.stringify(intentPrev.attributes) === JSON.stringify(intent.attributes))return; // if(intentPrev.attributes.position.x === intent.attributes.position.x && intentPrev.attributes.position.y === intent.attributes.position.y)return; // if(UndoRedo){ // const prevIntents = JSON.parse(JSON.stringify(this.prevListOfIntent)); // const nowIntents = JSON.parse(JSON.stringify(this.listOfIntents)); // let intentsToUpdateUndo = this.setListOfintentsToUpdate(intent, prevIntents); // let intentsToUpdateRedo = this.setListOfintentsToUpdate(intent, nowIntents); // let intentPrev = prevIntents.find((item) => item.intent_id === intent.intent_id)?prevIntents.find((item) => item.intent_id === intent.intent_id):intent; // let intentNow = nowIntents.find((item) => item.intent_id === intent.intent_id)?nowIntents.find((item) => item.intent_id === intent.intent_id):intent; // this.addIntentToUndoRedo('PUT', intentPrev, intentNow, intentsToUpdateUndo, intentsToUpdateRedo); // } // clearTimeout(this.setTimeoutChangeEvent); // this.setTimeoutChangeEvent = setTimeout(() => { this.faqService.patchAttributes(intentID, attributes).subscribe((data) => { if (data) { this.prevListOfIntent = JSON.parse(JSON.stringify(this.listOfIntents)); // data['attributesChanged'] = true; // this.logger.log('[INTENT SERVICE] patchAttributes OK: ', data); // this.behaviorIntent.next(data); } }, (error) => { this.logger.log('error: ', error); }, () => { this.logger.log('complete'); }); // }, 500); }
/** * patchAttributes * @param intent * @param UndoRedo * * verifica se devo o meno aggiungere l'azione ad UNDO * verifico se effettivamente c'è stato uno spostamento altrimenti esco * aggiungo PUT ad UNDO * imposto un timeout di 1/2 secondo prima di salvare la patch (questo per evitare molteplici salvataggi ravvicinati) */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L376-L408
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.updateIntentInMoveActionBetweenDifferentIntents
public updateIntentInMoveActionBetweenDifferentIntents(action, currentIntent, UndoRedo:boolean = true){ const thereIsIntent = this.listOfIntents.some((intent) => intent.intent_id === currentIntent.intent_id); this.logger.log('[INTENT SERVICE] -> updateIntentInMoveActionBetweenDifferentIntents, ', thereIsIntent, currentIntent); if(!thereIsIntent)return; let intent = JSON.parse(JSON.stringify(currentIntent)); const prevIntents = JSON.parse(JSON.stringify(this.prevListOfIntent)); const nowIntents = JSON.parse(JSON.stringify(this.listOfIntents)); this.logger.log('[INTENT SERVICE] -> updateIntentInMoveActionBetweenDifferentIntents, ',prevIntents, nowIntents); if(UndoRedo){ const tdAction = action._tdActionId; let intentOriginActionPrev = prevIntents.find((obj) => obj.actions.some((action) => action._tdActionId === tdAction)); let intentOriginActionNow = nowIntents.find((obj) => obj.intent_id === intentOriginActionPrev.intent_id); let intentPrev = prevIntents.find((item) => item.intent_id === intent.intent_id)?prevIntents.find((item) => item.intent_id === intent.intent_id):intent; let intentNow = nowIntents.find((item) => item.intent_id === intent.intent_id)?nowIntents.find((item) => item.intent_id === intent.intent_id):intent; // this.addIntentToUndoRedo('PUT', intentPrev, intentNow, [intentOriginActionPrev], [intentOriginActionNow]); } // const response = this.updateIntent(intent); }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L546-L563
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.changeIntentName
public async changeIntentName(intent){ // setTimeout(async () => { let prevIntent = this.prevListOfIntent.find((obj) => obj.intent_id === intent.intent_id); if(intent.intent_display_name !== prevIntent.intent_display_name){ // this.connectorService.updateConnector(intent.intent_id); // const response = await this.onUpdateIntentWithTimeout2(intent, 0, true); const response = await this.updateIntent(intent); // if(response){ // this.behaviorIntents.next(this.listOfIntents); // this.refreshIntent(intent); this.setDragAndListnerEventToElement(intent.intent_id); // } } // }, 500); }
/** update title of intent */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L589-L603
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.moveNewActionIntoIntent
public moveNewActionIntoIntent(currentActionIndex, action, currentIntentId): any { // this.logger.log('[INTENT-SERVICE] moveNewActionIntoIntent'); let newAction = this.createNewAction(action.value.type); let currentIntent = this.listOfIntents.find(function(obj) { return obj.intent_id === currentIntentId; }); currentIntent.actions.splice(currentActionIndex, 0, newAction); this.behaviorIntent.next(currentIntent); // this.connectorService.updateConnector(currentIntent.intent_id); // this.onUpdateIntentWithTimeout2(currentIntent, 0, true); this.updateIntent(currentIntent); // setTimeout(async () => { // const responseCurrentIntent = await this.onUpdateIntentWithTimeout2(currentIntent, 0, true); // if(responseCurrentIntent){ // // const fromEle = document.getElementById(currentIntent.intent_id); // // this.connectorService.updateConnector(currentIntent.intent_id); // this.logger.log('update current Intent: OK'); // //this.behaviorIntent.next(currentIntent); // } // }, 0); return newAction }
// moving new action in intent from panel elements
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L607-L628
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.moveActionBetweenDifferentIntents
public moveActionBetweenDifferentIntents(event, action, currentIntentId){ this.logger.log('[INTENT-SERVICE] moveActionBetweenDifferentIntents'); const that = this; // this.logger.log('moving action from another intent - action: ', currentIntentId); let currentIntent = this.listOfIntents.find(function(obj) { return obj.intent_id === currentIntentId; }); let previousIntent = this.listOfIntents.find(function(obj) { return obj.intent_id === that.previousIntentId; }); // this.logger.log('moveActionBetweenDifferentIntents: ', event, this.listOfIntents, currentIntentId, currentIntent, previousIntent); currentIntent.actions.splice(event.currentIndex, 0, action); previousIntent.actions.splice(event.previousIndex, 1); this.updateIntent(currentIntent, previousIntent); return; // this.connectorService.updateConnector(currentIntent.intent_id); // this.connectorService.updateConnector(previousIntent.intent_id); this.connectorService.deleteConnectorsFromActionByActionId(action._tdActionId); const responsePreviousIntent = this.updateIntent(previousIntent); // const responsePreviousIntent = this.onUpdateIntentWithTimeout2(previousIntent, 0, false); if(responsePreviousIntent){ this.behaviorIntent.next(previousIntent); } const responseCurrentIntent = this.updateIntentInMoveActionBetweenDifferentIntents(action,currentIntent); // devo fare una funzione che passa anche lo stato di intent prev onUpdateIntentWithTimeout2 NON va bene // const responseCurrentIntent = this.onUpdateIntentWithTimeout2(currentIntent); }
// on move action from different intents
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L631-L658
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.addNewIntentToListOfIntents
public addNewIntentToListOfIntents(intent){ // this.logger.log("[CDS-INTENT-SERVICES] aggiungo l'intent alla lista di intent"); this.listOfIntents.push(intent); this.refreshIntents(); // this.behaviorIntents.next(this.listOfIntents); }
/** * addNewIntentToListOfIntents * @param intent */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L665-L670
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.getListOfActions
public getListOfActions(){ return this.listActions; }
/** getListOfActions */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L713-L715
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.getListOfIntents
public getListOfIntents(): Array<{name: string, value: string, icon?:string}>{ return this.listOfIntents.map(a => { if (a.intent_display_name.trim() === 'start') { return { name: a.intent_display_name, value: '#' + a.intent_id, icon: 'rocket_launch' } } else if (a.intent_display_name.trim() === 'defaultFallback') { return { name: a.intent_display_name, value: '#' + a.intent_id, icon: 'undo' } } else { return { name: a.intent_display_name, value: '#' + a.intent_id, icon: 'label_important_outline' } } }); }
/** * getListOfIntents * @returns */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L721-L731
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.selectIntent
public selectIntent(intentID){ // this.logger.log('[INTENT SERVICE] --> selectIntent', this.listOfIntents, intentID); this.intentSelectedID = null; this.intentActive = false; this.intentSelected = null; this.intentSelected = this.listOfIntents.find(intent => intent.intent_id === intentID); if(this.intentSelected){ this.stageService.setDragElement(this.intentSelected.intent_id); this.intentSelectedID = this.intentSelected.intent_id; this.intentActive = true; } return this.intentSelected; }
/** selectIntent */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L735-L747
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.selectAction
public selectAction(intentID, actionId){ this.intentSelectedID = null; this.intentActive = false; this.actionSelectedID = actionId; this.intentSelected = this.listOfIntents.find(intent => intent.intent_id === intentID); this.listActions = this.intentSelected.actions; this.selectedAction = this.listActions.find(action => action._tdActionId === actionId); // this.logger.log('[INTENT SERVICE] --> selectAction: ', intentID, actionId); this.behaviorIntent.next(this.intentSelected); }
/** selectAction */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L750-L759
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.setIntentSelected
public setIntentSelected(intentID){ this.logger.log('[INTENT SERVICE] ::: setIntentSelected:: ', intentID); this.intentSelected = this.selectIntent(intentID); this.intentSelectedID = this.intentSelected.intent_id; this.intentActive = true; this.actionSelectedID = null; this.listActions = null; this.selectedAction = null; if(this.intentSelected && this.intentSelected.actions){ this.listActions = this.intentSelected.actions; } //this.listActions = this.intentSelected.actions?this.intentSelected.actions:null; // this.logger.log('[INTENT SERVICE] ::: setIntentSelected ::: ', this.intentSelected); if(this.intentSelected){ this.behaviorIntent.next(this.intentSelected); } // if(!this.intentSelected)return; // chiudo tutti i pannelli // this.controllerService.closeAllPanels(); }
/** setIntentSelected */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L762-L781
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.unselectAction
public unselectAction(){ this.actionSelectedID = null; // this.intentSelectedID = null; }
/** unselectAction */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L801-L804
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.inactiveIntent
public inactiveIntent(){ this.intentActive = false; }
/** unselectIntent */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L807-L809
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.deleteSelectedAction
public deleteSelectedAction(){ // this.logger.log('[INTENT SERVICE] ::: deleteSelectedAction', this.intentSelected.intent_id, this.actionSelectedID); if(this.intentSelected.intent_id && this.actionSelectedID){ this.connectorService.deleteConnectorsFromActionByActionId(this.actionSelectedID); let intentToUpdate = this.listOfIntents.find((intent) => intent.intent_id === this.intentSelected.intent_id); intentToUpdate.actions = intentToUpdate.actions.filter((action: any) => action._tdActionId !== this.actionSelectedID); this.listOfIntents = this.listOfIntents.map((intent) => { if (intent.intent_id === this.intentSelected.intent_id) { return intentToUpdate; } return intent; }); this.refreshIntent(intentToUpdate); // this.connectorService.updateConnector(intentToUpdate.intent_id); this.controllerService.closeAllPanels(); // this.connectorService.deleteConnectorsFromActionByActionId(this.actionSelectedID); // const responseIntent = this.onUpdateIntentWithTimeout2(intentToUpdate, 0, true); const responseIntent = this.updateIntent(intentToUpdate); if(responseIntent){ // this.connectorService.movedConnector(intentToUpdate.intent_id); this.logger.log('update Intent: OK'); } this.unselectAction(); // this.logger.log('deleteSelectedAction', intentToUpdate); } }
/** deleteSelectedAction * deleteConnectorsFromActionByActionId: elimino i connettori in uscita della action * aggiorno l'intent con la nuova action * aggiorno la lista degli intents * refreshIntent: aggiorno gli attributi della action (pallini) * updateConnector: aggiorno i connettori * closeAllPanels: chiudo i pannelli * onUpdateIntentWithTimeout2: salvo l'intent */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L821-L846
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.createNewAction
public createNewAction(typeAction: TYPE_ACTION | TYPE_ACTION_VXML) { // this.logger.log('[INTENT-SERV] createNewAction typeAction ', typeAction) let action: any; if(typeAction === TYPE_ACTION.REPLY){ action = new ActionReply(); let commandWait = new Wait(); action.attributes.commands.push(commandWait); let command = new Command(TYPE_COMMAND.MESSAGE); command.message = new Message('text', 'A chat message will be sent to the visitor'); action.attributes.commands.push(command); } if(typeAction === TYPE_ACTION.REPLYV2){ action = new ActionReplyV2(); action.noInputTimeout = 10000; let commandWait = new Wait(); action.attributes.commands.push(commandWait); let command = new Command(TYPE_COMMAND.MESSAGE); command.message = new Message('text', 'A chat message will be sent to the visitor'); action.attributes.commands.push(command); } if(typeAction === TYPE_ACTION.RANDOM_REPLY){ action = new ActionRandomReply(); let commandWait = new Wait(); action.attributes.commands.push(commandWait); let command = new Command(TYPE_COMMAND.MESSAGE); command.message = new Message('text', 'A chat message will be sent to the visitor'); action.attributes.commands.push(command); } if(typeAction === TYPE_ACTION.WEB_REQUEST){ action = new ActionWebRequest(); } if(typeAction === TYPE_ACTION.WEB_REQUESTV2){ action = new ActionWebRequestV2(); action.assignResultTo= 'result' action.assignStatusTo = 'status'; action.assignErrorTo = 'error'; } if(typeAction === TYPE_ACTION.AGENT){ action = new ActionAgent(); } if(typeAction === TYPE_ACTION.CLOSE){ action = new ActionClose(); } if(typeAction === TYPE_ACTION.WAIT){ action = new ActionWait(); } if(typeAction === TYPE_ACTION.INTENT) { action = new ActionIntentConnected(); } if(typeAction === TYPE_ACTION.CONNECT_BLOCK) { action = new ActionConnectBlock(); } if(typeAction === TYPE_ACTION.EMAIL) { action = new ActionEmail(); } if(typeAction === TYPE_ACTION.ASSIGN_VARIABLE){ action = new ActionAssignVariable(); } if(typeAction === TYPE_ACTION.ASSIGN_VARIABLE_V2){ action = new ActionAssignVariableV2(); } if(typeAction === TYPE_ACTION.DELETE_VARIABLE){ action = new ActionDeleteVariable(); } if(typeAction === TYPE_ACTION.ONLINE_AGENTS){ action = new ActionOnlineAgent(); } if(typeAction === TYPE_ACTION.ONLINE_AGENTSV2){ action = new ActionOnlineAgentV2(); } if(typeAction === TYPE_ACTION.OPEN_HOURS){ action = new ActionOpenHours(); } if(typeAction === TYPE_ACTION.REPLACE_BOT){ action = new ActionReplaceBot(); } if(typeAction === TYPE_ACTION.REPLACE_BOTV2){ action = new ActionReplaceBotV2(); action.nameAsSlug = false; } if(typeAction === TYPE_ACTION.REPLACE_BOTV3){ action = new ActionReplaceBotV3(); action.useSlug = false; } if(typeAction === TYPE_ACTION.CHANGE_DEPARTMENT) { action = new ActionChangeDepartment(); action.triggerBot = true; } if(typeAction === TYPE_ACTION.HIDE_MESSAGE){ action = new ActionHideMessage(); } if(typeAction === TYPE_ACTION.JSON_CONDITION){ action = new ActionJsonCondition(); action.groups.push( new Expression()); } if(typeAction === TYPE_ACTION.CONDITION) { action = new ActionCondition(); action.groups.push( new Expression()); } if(typeAction === TYPE_ACTION.ASSIGN_FUNCTION){ action = new ActionAssignFunction(); } if(typeAction === TYPE_ACTION.WHATSAPP_ATTRIBUTE){ action = new ActionWhatsappAttribute(); } if(typeAction === TYPE_ACTION.WHATSAPP_STATIC){ action = new ActionWhatsappStatic(); } if(typeAction === TYPE_ACTION.ASKGPT){ action = new ActionAskGPT(); action.question = '{{lastUserText}}' action.assignReplyTo = 'kb_reply'; action.assignSourceTo = 'kb_source'; } if(typeAction === TYPE_ACTION.ASKGPTV2) { action = new ActionAskGPTV2(); action.question = '{{lastUserText}}' action.assignReplyTo = 'kb_reply'; action.assignSourceTo = 'kb_source'; action.max_tokens = 256; action.temperature = 0.7; action.top_k = 5; action.model = TYPE_GPT_MODEL.find(el => el.value === 'gpt-4o').value action.preview = []; action.history = false; action.citations = false; } if(typeAction === TYPE_ACTION.GPT_TASK){ action = new ActionGPTTask(); action.max_tokens = 256; action.temperature = 0.7; action.model = TYPE_GPT_MODEL.find(el => el.value === 'gpt-4o').value action.assignReplyTo = 'gpt_reply'; action.preview = []; action.formatType = 'none' } if(typeAction === TYPE_ACTION.GPT_ASSISTANT){ action = new ActionGPTAssistant(); action.prompt ='{{lastUserText}}'; action.threadIdAttribute = 'firstThread'; action.assignResultTo = 'assistantReply'; action.assignErrorTo = 'assistantError'; } if(typeAction === TYPE_ACTION.CAPTURE_USER_REPLY) { action = new ActionCaptureUserReply(); } if(typeAction === TYPE_ACTION.QAPLA) { action = new ActionQapla(); action.assignStatusTo = 'qapla_status'; action.assignResultTo = 'qapla_result'; action.assignErrorTo = 'qapla_error'; this.segmentActionAdded(TYPE_ACTION.QAPLA); } if(typeAction === TYPE_ACTION.MAKE){ action = new ActionMake(); action.assignStatusTo = 'make_status'; action.assignErrorTo = 'make_error'; } if(typeAction === TYPE_ACTION.HUBSPOT){ action = new ActionHubspot(); action.assignStatusTo = 'hubspot_status'; action.assignErrorTo = 'hubspot_error'; } if(typeAction === TYPE_ACTION.CUSTOMERIO){ action = new ActionCustomerio(); action.assignStatusTo = 'customerio_status'; action.assignErrorTo = 'customerio_error'; } if(typeAction === TYPE_ACTION.BREVO){ action = new ActionBrevo(); action.assignStatusTo = 'brevo_status'; action.assignErrorTo = 'brevo_error'; action.assignResultTo = 'brevo_result'; } if(typeAction === TYPE_ACTION.N8N){ action = new ActionN8n(); action.assignStatusTo = 'n8n_status'; action.assignErrorTo = 'n8n_error'; action.assignResultTo = 'n8n_result'; } if(typeAction === TYPE_ACTION.CODE){ action = new ActionCode(); } if(typeAction === TYPE_ACTION.ADD_TAG){ action = new ActionAddTags(); action.target = 'request'; action.tags = ''; action.pushToList = false; } if(typeAction === TYPE_ACTION.LEAD_UPDATE){ action = new ActionLeadUpdate(); } if(typeAction === TYPE_ACTION.CLEAR_TRANSCRIPT){ action = new ActionClearTranscript(); } if(typeAction === TYPE_ACTION.MOVE_TO_UNASSIGNED){ action = new ActionMoveToUnassigned(); } /** VOICE ACTIONS: start */ if(typeAction === TYPE_ACTION_VXML.DTMF_FORM){ action = new ActionVoice(TYPE_ACTION_VXML.DTMF_FORM); let commandWait = new Wait(); commandWait.time = 0; action.attributes.commands.push(commandWait); let command = new Command(TYPE_COMMAND.MESSAGE); command.message = new Message('text', 'A chat message will be sent to the visitor'); action.attributes.commands.push(command); let commandWait2 = new Wait(); commandWait2.time = 0 action.attributes.commands.push(commandWait2); let command_form = new Command(TYPE_COMMAND.SETTINGS); command_form.settings = { minDigits: null, maxDigits: null, terminators: '#', noInputIntent: null, noInputTimeout: 5000, bargein: true} command_form.subType = TYPE_ACTION_VXML.DTMF_FORM action.attributes.commands.push(command_form); } if(typeAction === TYPE_ACTION_VXML.DTMF_MENU){ action = new ActionVoice(TYPE_ACTION_VXML.DTMF_MENU); let commandWait = new Wait(); commandWait.time = 0; (action as ActionVoice).attributes.commands.push(commandWait); let command = new Command(TYPE_COMMAND.MESSAGE); command.message = new Message('text', 'A chat message will be sent to the visitor'); (action as ActionVoice).attributes.commands.push(command); let commandWait2 = new Wait(); commandWait2.time = 0; (action as ActionVoice).attributes.commands.push(commandWait2); let command_form = new Command(TYPE_COMMAND.SETTINGS); command_form.settings = { noInputIntent: null, noMatchIntent: null, noInputTimeout: 5000, bargein: true} command_form.subType = TYPE_ACTION_VXML.DTMF_MENU; (action as ActionVoice).attributes.commands.push(command_form); } if(typeAction === TYPE_ACTION_VXML.BLIND_TRANSFER){ action = new ActionVoice(TYPE_ACTION_VXML.BLIND_TRANSFER); let commandWait = new Wait(); commandWait.time = 0; (action as ActionVoice).attributes.commands.push(commandWait); let command = new Command(TYPE_COMMAND.MESSAGE); command.message = new Message('text', 'A chat message will be sent to the visitor'); (action as ActionVoice).attributes.commands.push(command); let commandWait2 = new Wait(); commandWait2.time = 0; (action as ActionVoice).attributes.commands.push(commandWait2); let command_form = new Command(TYPE_COMMAND.SETTINGS); command_form.settings = { transferTo: '', transferType: 'consultation', trueIntent: null, falseIntent: null} command_form.subType = TYPE_ACTION_VXML.BLIND_TRANSFER; (action as ActionVoice).attributes.commands.push(command_form); } if(typeAction === TYPE_ACTION_VXML.PLAY_PROMPT){ action = new ActionVoice(TYPE_ACTION_VXML.PLAY_PROMPT); let commandWait = new Wait(); commandWait.time = 0; (action as ActionVoice).attributes.commands.push(commandWait); let command = new Command(TYPE_COMMAND.MESSAGE); command.message = new Message('text', 'A chat message will be played to the caller'); action.attributes.commands.push(command); let commandWait2 = new Wait(); commandWait2.time = 0; (action as ActionVoice).attributes.commands.push(commandWait2); let command_form = new Command(TYPE_COMMAND.SETTINGS); command_form.settings = { bargein: true }; command_form.subType = TYPE_ACTION_VXML.PLAY_PROMPT; (action as ActionVoice).attributes.commands.push(command_form); } if(typeAction === TYPE_ACTION_VXML.SPEECH_FORM){ action = new ActionVoice(TYPE_ACTION_VXML.SPEECH_FORM); // (action as ActionVoice).attributes.disableInputMessage = false let commandWait = new Wait(); commandWait.time = 0; action.attributes.commands.push(commandWait); let command = new Command(TYPE_COMMAND.MESSAGE); command.message = new Message('text', 'A chat message will be played to the caller'); action.attributes.commands.push(command); let commandWait2 = new Wait(); commandWait2.time = 0 action.attributes.commands.push(commandWait2); let command_form = new Command(TYPE_COMMAND.SETTINGS); command_form.settings = { bargein: true, noInputIntent: null, noInputTimeout: 5000, incompleteSpeechTimeout: 700} command_form.subType = TYPE_ACTION_VXML.SPEECH_FORM action.attributes.commands.push(command_form); } if(typeAction === TYPE_ACTION_VXML.AUDIO_RECORD){ action = new ActionVoice(TYPE_ACTION_VXML.AUDIO_RECORD); // (action as ActionVoice).attributes.disableInputMessage = false let commandWait = new Wait(); commandWait.time = 0; action.attributes.commands.push(commandWait); let command = new Command(TYPE_COMMAND.MESSAGE); command.message = new Message('text', 'Please, leave a message after the beep'); action.attributes.commands.push(command); let commandWait2 = new Wait(); commandWait2.time = 0 action.attributes.commands.push(commandWait2); let command_form = new Command(TYPE_COMMAND.SETTINGS); command_form.settings = { maxtime: 20, finalsilence: 3, beep: true, dtmfterm: true } command_form.subType = TYPE_ACTION_VXML.AUDIO_RECORD action.attributes.commands.push(command_form); } /** VOICE ACTIONS: end */ if(typeAction === TYPE_ACTION.SEND_WHATSAPP){ action = new ActionSendWhatsapp(); action.payload = new WhatsappBroadcast() } return action; }
/** * createNewAction * @param typeAction * @returns */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L854-L1161
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.patchButtons
public patchButtons(buttons, idAction){ // this.logger.log('patchButtons:: ', buttons); buttons.forEach((button, index) => { const checkUid = buttons.filter(btn => btn.uid === button.uid); if (checkUid.length > 1 || !button.uid && button.uid == undefined) { button.uid = generateShortUID(index); } buttons[index] = this.patchButton(button, idAction); }); return buttons; }
// END ATTRIBUTE FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L1165-L1175
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.setDragAndListnerEventToElement
public async setDragAndListnerEventToElement(intent_id) { let isOnTheStage = await isElementOnTheStage(intent_id); // sync if(isOnTheStage){ this.stageService.setDragElement(intent_id); } }
/** * setDragAndListnerEventToElement * @param intent * after the element is on the stage, set the drag on the element */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L1211-L1216
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.replaceIntent
public replaceIntent(intent){ for (let i = 0; i < this.listOfIntents.length; i++) { if (this.listOfIntents[i].intent_id === intent.intent_id) { this.listOfIntents[i] = intent; break; } } // this.logger.log('[INTENT SERVICE] -> SOSTITUISCO:', intent, this.listOfIntents); return this.listOfIntents; }
/** * replaceIntent * @param intent * @param listOfIntents * @returns */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L1225-L1234
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.setListOfintentsToUpdate
private setListOfintentsToUpdate(intent, listOfIntents){ let intentsToUpdate = []; const connectorsID = this.connectorService.searchConnectorsInByIntent(intent.intent_id); const nowIntents = JSON.parse(JSON.stringify(listOfIntents)); this.logger.log('setListOfintentsToUpdate', nowIntents, connectorsID); connectorsID.forEach(connector => { let splitFromId = connector['id'].split('/'); let intent_id = splitFromId[0]; const idEsistente = intentsToUpdate.some((obj) => obj.intent_id === intent_id); if (!idEsistente) { const intentUpdate = nowIntents.find((obj) => obj.intent_id === intent_id); intentsToUpdate.push(intentUpdate); } }); this.logger.log('setListOfintentsToUpdate', intentsToUpdate); return intentsToUpdate; }
/** * setListOfintentsToUpdate * @param intent * @param listOfIntents * @returns */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L1242-L1258
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.restoreLastUNDO
public restoreLastUNDO(){ this.logger.log('[INTENT SERVICE] -> restoreLastUNDO', this.operationsUndo); this.lastActionUndoRedo = true; if(this.arrayUNDO && this.arrayUNDO.length>0){ const objUNDO = JSON.parse(JSON.stringify(this.arrayUNDO.pop())); this.arrayREDO.push(objUNDO); // this.logger.log('[INTENT SERVICE] -> RESTORE UNDO: ', this.arrayREDO); this.payload.operations = objUNDO.undo; this.logger.log('[INTENT UNDO] -> ho aggiornato gli array dopo UNDO ', this.payload, this.arrayUNDO, this.arrayREDO); // this.refreshIntents(); this.restoreIntent(objUNDO.undo); this.setBehaviorUndoRedo(); this.opsUpdate(this.payload); } const action = this.intentSelected.actions.find((obj) => obj._tdActionId === this.actionSelectedID); this.logger.log('[INTENT SERVICE] -> è action:: ', action, this.intentSelected, this.actionSelectedID); }
/************************************************ * UNDO / REDO /************************************************ / /** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L1267-L1283
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.restoreLastREDO
public restoreLastREDO(){ this.logger.log('[INTENT SERVICE] -> restoreLastREDO', this.operationsRedo); this.lastActionUndoRedo = true; // this.logger.log('[INTENT SERVICE] -> restoreLastREDO', this.arrayREDO); if(this.arrayREDO && this.arrayREDO.length>0){ const objREDO = JSON.parse(JSON.stringify(this.arrayREDO.pop())); this.arrayUNDO.push(objREDO); // this.logger.log('[INTENT SERVICE] -> RESTORE REDO: ', objREDO); this.payload.operations = objREDO.redo; this.restoreIntent(objREDO.redo); this.setBehaviorUndoRedo(); this.logger.log('[INTENT UNDO] -> ho aggiornato gli array dopo REDO ', this.arrayUNDO, this.arrayREDO); this.opsUpdate(this.payload); } }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L1286-L1300
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.updateIntent
public async updateIntent(intent: Intent, fromIntent?: Intent){ this.logger.log('[INTENT SERVICE] -> updateIntentNew, ', intent, fromIntent); const intentPrev = this.prevListOfIntent.find((obj) => obj.intent_id === intent.intent_id); this.operationsUndo = []; this.operationsRedo = []; this.payload = { id_faq_kb: intent.id_faq_kb, operations: [] }; this.operationsRedo.push({ type: "put", intent: JSON.parse(JSON.stringify(intent)) }); this.operationsUndo.push({ type: "put", intent: JSON.parse(JSON.stringify(intentPrev)) }); if(fromIntent){ // MAI!!! da verificare!!! const fromIntentPrev = this.prevListOfIntent.find((obj) => obj.intent_id === fromIntent.intent_id); this.operationsRedo.push({ type: "put", intent: JSON.parse(JSON.stringify(fromIntent)) }); this.operationsUndo.push({ type: "put", intent: JSON.parse(JSON.stringify(fromIntentPrev)) }); } else { // quando sposto un intent sullo stage let intentsToUpdate = this.findsIntentsToUpdate(intent.intent_id); intentsToUpdate.forEach(ele => { this.operationsUndo.push({ type: "put", intent: JSON.parse(JSON.stringify(ele)) }); this.operationsRedo.push({ type: "put", intent: JSON.parse(JSON.stringify(ele)) }); }); } this.payload.operations = this.operationsRedo; let operations = {undo:this.operationsUndo, redo:this.operationsRedo}; this.arrayUNDO.push(operations); this.arrayREDO = []; this.setBehaviorUndoRedo(); this.logger.log('[INTENT SERVICE] updateIntentNew -> payload, ', this.payload, this.operationsRedo, this.operationsUndo); this.refreshIntents(); try { let intentToUpdate = this.listOfIntents.find((obj) => obj.intent_id === this.intentSelected.intent_id); this.refreshIntent(intentToUpdate) } catch (error) { this.logger.log('[INTENT SERVICE] -> error, ', error); } this.opsUpdate(this.payload); }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L1356-L1413
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.saveNewIntent
public async saveNewIntent(intent: Intent, nowIntent: Intent, prevIntent:Intent){ this.logger.log('[INTENT SERVICE] -> addIntentNew, ', intent, nowIntent, prevIntent); this.operationsUndo = []; this.operationsRedo = []; this.payload = { id_faq_kb: intent.id_faq_kb, operations: [] }; this.operationsRedo.push({ type: "post", intent: JSON.parse(JSON.stringify(intent)) }); this.operationsUndo.push({ type: "delete", intent: JSON.parse(JSON.stringify(intent)) }); // const tdActionId = intent.actions[0]._tdActionId // const prevIntent = this.prevListOfIntent.find((intent) => intent.actions.some((act) => act._tdActionId === tdActionId)); if(prevIntent){ this.operationsUndo.push({ type: "put", intent: JSON.parse(JSON.stringify(prevIntent)) }); // const nowIntent = this.listOfIntents.find((intent) => intent.intent_id === prevIntent.intent_id); this.operationsRedo.push({ type: "put", intent: JSON.parse(JSON.stringify(nowIntent)) }); } // this.deleteIntentToListOfIntents(intent.intent_id); // this.listOfIntents = insertItemInArray(this.listOfIntents, intent); this.payload.operations = this.operationsRedo; let operations = {undo:this.operationsUndo, redo:this.operationsRedo}; this.arrayUNDO.push(operations); this.arrayREDO = []; this.setBehaviorUndoRedo(); this.logger.log('[INTENT SERVICE] -> payload, ', this.payload, this.operationsRedo, this.operationsUndo); this.refreshIntents(); this.opsUpdate(this.payload); }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L1416-L1455
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.deleteIntentNew
public async deleteIntentNew(intent: Intent){ this.logger.log('[INTENT SERVICE] -> deleteIntent, ', intent); this.operationsUndo = []; this.operationsRedo = []; this.payload = { id_faq_kb: intent.id_faq_kb, operations: [] }; this.operationsRedo.push({ type: "delete", intent: JSON.parse(JSON.stringify(intent)) }); this.operationsUndo.push({ type: "post", intent: JSON.parse(JSON.stringify(intent)) }); let intentsToUpdate = this.findsIntentsToUpdate(intent.intent_id); intentsToUpdate.forEach(ele => { this.operationsUndo.push({ type: "put", intent: JSON.parse(JSON.stringify(ele)) }); }); intentsToUpdate.forEach(ele => { this.checkEndsWith(ele, intent.intent_id, this.operationsRedo, ele); }); this.listOfIntents = deleteItemInArrayForKey('intent_id', this.listOfIntents, intent); this.connectorService.deleteConnectorsOfBlock(intent.intent_id, false, true); // this.connectorService.deleteConnectorsToIntentById(intent.intent_id); this.payload.operations = this.operationsRedo; let operations = {undo:this.operationsUndo, redo:this.operationsRedo}; this.arrayUNDO.push(operations); this.arrayREDO = []; this.setBehaviorUndoRedo(); this.logger.log('[INTENT SERVICE] -> payload, ', this.payload, this.operationsRedo, this.operationsUndo); this.refreshIntents(); this.opsUpdate(this.payload); }
/** deleteIntent2 */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L1459-L1497
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.findsIntentsToUpdate
private findsIntentsToUpdate(intent_id){ let intentsToUpdate = []; let listConnectors = this.connectorService.searchConnectorsInByIntent(intent_id); listConnectors.forEach(element => { const splitFromId = element.fromId.split('/'); const intentToUpdateId = splitFromId[0]; let intent = this.listOfIntents.find((intent: any) => intent.intent_id === intentToUpdateId); intentsToUpdate.push(intent); }); return intentsToUpdate; }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L1502-L1512
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.checkEndsWith
private checkEndsWith(obj, end, array, element) { for (var key in obj) { if (typeof obj[key] === 'object') { this.checkEndsWith(obj[key], end, array, element); } else if (typeof obj[key] === 'string') { if(obj[key].endsWith(end)){ obj[key] = ""; array.push({ type: "put", intent: JSON.parse(JSON.stringify(element)) }); } } } }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L1515-L1529
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.opsUpdate
private async opsUpdate(payload: any, UndoRedo=true): Promise<boolean> { // this.logger.log('[INTENT SERVICE] -> opsUpdate, ', payload); payload = removeNodesStartingWith(payload, '__'); //this.setDragAndListnerEventToElement(intent.intent_id); return new Promise((resolve, reject) => { this.faqService.opsUpdate(payload).subscribe((resp: any) => { this.logger.log('[INTENT SERVICE] -> opsUpdate, ', resp); this.prevListOfIntent = JSON.parse(JSON.stringify(this.listOfIntents)); // this.setDragAndListnerEventToElement(intent.intent_id); resolve(true); }, (error) => { this.logger.error('ERROR: ', error); reject(false); }, () => { resolve(true); }); }); }
/** updateIntent */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L1532-L1549
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
IntentService.copyElement
public copyElement(element): {key: string, data: any} { this.logger.log('[INTENT SERVICE] -> copyElement, ', element); let value= {} if(element && element.type === 'INTENT'){ this.arrayCOPYPAST[0] = element; let key = 'copied_items'; value = { 'chatbot': element.chatbot, 'copy': this.arrayCOPYPAST } return {key: key, data: JSON.stringify(value)} // localStorage.setItem(key, JSON.stringify(value)); } else if(element && element.type === 'ACTION'){ this.arrayCOPYPAST[0] = element; let key = 'copied_items'; value = { 'chatbot': element.chatbot, 'copy': this.arrayCOPYPAST } return {key: key, data: JSON.stringify(value)} // localStorage.setItem(key, JSON.stringify(value)); } }
/************************************************ * UNDO / REDO /************************************************/
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/services/intent.service.ts#L1651-L1673
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPublishOnCommunityModalComponent.upload
upload(event) { this.logger.log('[CDS-CHATBOT-DTLS] BOT PROFILE IMAGE upload') this.showSpinnerInUploadImageBtn = true; const file = event.target.files[0] this.uploadService.uploadProfile(this.selectedChatbot._id, file).then((downloadUrl)=> { this.logger.log('[CDS-CHATBOT-DTLS] BOT PROFILE IMAGE upload with native service - RES downoloadurl', downloadUrl); this.selectedChatbot.url = downloadUrl this.showSpinnerInUploadImageBtn = false; // this.timeStamp = (new Date()).getTime(); }, (error) => { this.logger.error('[CDS-CHATBOT-DTLS] BOT PROFILE IMAGE upload with native service - ERR ', error); }) this.cdsfileInputBotProfileImage.nativeElement.value = ''; }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/modals/cds-publish-on-community-modal/cds-publish-on-community-modal.component.ts#L158-L175
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPublishOnCommunityModalComponent.editBot
editBot() { // RESOLVE THE BUG 'edit button remains focused after clicking' this.elementRef.nativeElement.blur(); // this.logger.log('[CDS-CHATBOT-DTLS] FAQ KB NAME TO UPDATE ', this.faqKb_name); // this.selectedChatbot.name = this.faqKb_name // this.selectedChatbot.description = this.faqKb_description; this.updateChatbot(this.selectedChatbot) }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/modals/cds-publish-on-community-modal/cds-publish-on-community-modal.component.ts#L235-L242
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPublishOnCommunityModalComponent.createNewTag
createNewTag = (newTag: string) => { this.logger.log("Create New TAG Clicked -> newTag: " + newTag) var index = this.tagsList.findIndex(t => t.tag === newTag); if (index === -1) { this.logger.log("Create New TAG Clicked - Tag NOT exist") this.tagsList.push(newTag) this.logger.log("Create New TAG Clicked - chatbot tag tagsList : ", this.tagsList) let self = this; this.logger.log(' this.ngSelect', this.ngSelect) if (this.ngSelect) { this.ngSelect.close() this.ngSelect.blur() } self.selectedChatbot.tags = this.tagsList self.updateChatbot(self.selectedChatbot) } else { this.logger.log("Create New TAG Clicked - Tag already exist ") } }
// --------------------------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/modals/cds-publish-on-community-modal/cds-publish-on-community-modal.component.ts#L247-L269
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPublishOnCommunityModalComponent.publishOnCommunity
publishOnCommunity() { this.selectedChatbot.public = true; this.faqKbService.updateChatbot(this.selectedChatbot).subscribe((data) => { this.logger.log('[PUBLISH-ON-COMMUNITY-MODAL-COMPONENT] publishOnCommunity - RES ', data) }, (error) => { this.logger.error('[PUBLISH-ON-COMMUNITY-MODAL-COMPONENT] publishOnCommunity ERROR ', error); }, () => { this.logger.log('[PUBLISH-ON-COMMUNITY-MODAL-COMPONENT] publishOnCommunity * COMPLETE * '); this.notify.showWidgetStyleUpdateNotification(this.translate.instant('CDSSetting.SuccessfullyDeployed'), 2, 'done'); this.dialogRef.close('has-published-on-cmnty'); }); }
// --------------------------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/modals/cds-publish-on-community-modal/cds-publish-on-community-modal.component.ts#L288-L302
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
AppConfigService.constructor
constructor(public http: HttpClient) { this.appConfig = environment; // console.log('appConfigService constructor environment:: ', environment); }
// private logger: LoggerService = LoggerInstance.getInstance()
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/app-config.ts#L14-L17
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
AppConfigService.loadAppConfig
loadAppConfig() { // const that = this; // return this.http.get(this.appConfig.remoteConfigUrl).toPromise().then(data => { // that.appConfig = data; // }).catch(err => { // console.log('error loadAppConfig' + err); // }); // ---- new return this.http.get(this.appConfig.remoteConfigUrl).toPromise().then((data: any) => { // console.log('AppConfigService loadAppConfig data: ', data); const allconfig = data // console.log('[APP-CONFIG-SERVICE] - loadAppConfig allconfig: ', allconfig); if (allconfig.hasOwnProperty('wsUrlRel')) { // console.log('[APP-CONFIG-SERVICE] - loadAppConfig allconfig !!!! exist wsUrlRel ->: ', allconfig.wsUrlRel); var wsUrlRelIsEmpty = this.isEmpty(allconfig.wsUrlRel) // console.log('[APP-CONFIG-SERVICE] - loadAppConfig allconfig !!!! exist wsUrlRel -> wsUrlRelIsEmpty ?', wsUrlRelIsEmpty); if (wsUrlRelIsEmpty === false) { // console.log('[APP-CONFIG-SERVICE]- loadAppConfig allconfig !!!! exist - SERVER_BASE_URL', data.apiUrl); // if (allconfig.apiUrl.indexOf("http://") !== -1) { // const ws_url = allconfig.apiUrl.replace("http://", "ws://").slice(0, -1) + allconfig.wsUrlRel; // // console.log('AppConfigService loadAppConfig allconfig !!!! exist - SERVER_BASE_URL protocol is HTTP - wsUrl', ws_url); // allconfig.wsUrl = ws_url // } else if (allconfig.apiUrl.indexOf("https://") !== -1) { // const ws_url = allconfig.apiUrl.replace("https://", "wss://").slice(0, -1) + allconfig.wsUrlRel; // allconfig.wsUrl = ws_url // // console.log('AppConfigService loadAppConfig allconfig !!!! exist - SERVER_BASE_URL protocol is HTTPS - wsUrl', ws_url); // } else { // console.log('AppConfigService loadAppConfig allconfig !!!! exist - SERVER_BASE_URL !!! IS RELATIVE - window.location ', window.location); // console.log(window.location) if (window.location.protocol === 'http:') { allconfig.wsUrl = 'ws://' + window.location.hostname + ':' + window.location.port + allconfig.wsUrlRel } else if (window.location.protocol === 'https:') { allconfig.wsUrl = 'wss://' + window.location.hostname + ':' + window.location.port + allconfig.wsUrlRel } else { allconfig.wsUrl = 'ws://' + window.location.hostname + ':' + window.location.port + allconfig.wsUrlRel } // } } else { // console.log('[APP-CONFIG-SERVICE] loadAppConfig allconfig !!!! exist wsUrlRel but IS EMPTY'); } } else { // console.log('[APP-CONFIG-SERVICE] loadAppConfig allconfig !!!! does not exist wsUrlRel'); } this.appConfig = allconfig; }).catch(err => { console.error('error loadAppConfig' + err); }); }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/app-config.ts#L20-L94
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
AppConfigService.getConfig
getConfig() { return this.appConfig; }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/app-config.ts#L101-L103
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
BrandService.loadBrand
async loadBrand() { // this.getData() // .subscribe(data => { // this.assetBrand = data // console.log('[BRAND-SERV] BRAND RETIEVED FROM ASSET assetBrand ', this.assetBrand); // }); // let url = '' // if (environment.remoteConfig === false) { // if (environment.hasOwnProperty("brandSrc")) { // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is false - env has Property brandSrc'); // const remoteBrandUrl = this.isEmpty(environment['brandSrc']); // if (!remoteBrandUrl) { // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is false - env brandSrc is empty ? ', remoteBrandUrl); // url = environment['brandSrc'] // } else { // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is false - env brandSrc is empty ? ', remoteBrandUrl, ' -> load from assets') // this.brand = this._brand; // } // } else { // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is false - env NOT has Property brandSrc -> load from assets'); // this.brand = this._brand; // } // } else { // const res = await this.httpClient.get(environment['remoteConfigUrl']).toPromise(); // this.logger.log('[BRAND-SERV] loadBrand - remoteConfig -> true get remoteConfig response ', res); // // const remoteConfigData = JSON.parse(res['_body']) // const remoteConfigData = res // // this.logger.log('BrandService loadBrand - remoteConfig is true - get remoteConfigData res ', remoteConfigData); // if (remoteConfigData.hasOwnProperty("brandSrc")) { // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is true - remoteConfigData has Property brandSrc'); // const remoteBrandUrl = this.isEmpty(remoteConfigData['brandSrc']); // if (!remoteBrandUrl) { // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is true - remoteConfigData brandSrc is empty ?', remoteBrandUrl); // url = remoteConfigData['brandSrc'] // } else { // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is true - remoteConfigData brandSrc is empty ?', remoteBrandUrl, ' -> load from assets'); // this.brand = this._brand; // } // } else { // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is true - remoteConfigData NOT has Property brandSrc -> load from assets'); // // this.setBrand(this.local_url) // // url = this.local_url // this.brand = this._brand; // } // } const that = this try { let url = this.appConfig.getConfig().brandSrc if (url && url !== 'CHANGEIT') { const data = await this.httpClient.get(url).toPromise(); console.log('[BRAND-SERV] **** GET BRAND FROM URL ****', url); this.brand =data console.log('[BRAND-SERV] loadBrand - brand: ', this.brand); const resources = new BrandResources(this); resources.loadResources() } } catch (err) { console.error('[BRAND-SERV] loadBrand error : ', err); this.brand = this._brand; // this.notify.showNotificationChangeProject('ops', 2, 'done'); this.displaySwalAlert(err) } }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/brand.service.ts#L129-L210
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
DashboardService.getTranslations
async getTranslations(): Promise<boolean> { return new Promise((resolve, reject) => { // this.translateCreateFaqSuccessMsg(); // this.translateCreateFaqErrorMsg(); // this.translateUpdateFaqSuccessMsg(); // this.translateUpdateFaqErrorMsg(); // this.translateWarningMsg(); // this.translateAreYouSure(); // this.translateErrorDeleting(); // this.translateDone(); // this.translateErrorOccurredDeletingAnswer(); // this.translateAnswerSuccessfullyDeleted(); resolve(true); }); }
/** GET TRANSLATIONS */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/dashboard.service.ts#L54-L68
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
DashboardService.getBotById
async getBotById(): Promise<boolean> { this.logger.log('[CDS DSHBRD] - GET BOT BY ID RES - chatbot', this.id_faq_kb); return new Promise((resolve, reject) => { this.faqKbService.getBotById(this.id_faq_kb).subscribe({ next: (chatbot: Chatbot) => { this.logger.log('[CDS DSHBRD] - GET BOT BY ID RES - chatbot', chatbot); if (chatbot) { this.selectedChatbot = chatbot; this.translateparamBotName = { bot_name: this.selectedChatbot.name } variableList.find(el => el.key ==='userDefined').elements = []; if (this.selectedChatbot && this.selectedChatbot.attributes && this.selectedChatbot.attributes.variables) { variableList.find(el => el.key ==='userDefined').elements = convertJsonToArray(this.selectedChatbot.attributes.variables); } if (this.selectedChatbot && this.selectedChatbot.attributes && this.selectedChatbot.attributes.globals) { variableList.find(el => el.key ==='globals').elements = this.selectedChatbot.attributes.globals.map(({ key: name, ...rest }) => ({ name, value: name })) } resolve(true); } }, error: (error) => { this.logger.error('[ DSHBRD-SERVICE ] getBotById ERROR: ', error); this.router.navigate([`project/unauthorized`]); reject(false); //redirect t ounauth //resolve(true) }, complete: () => { this.logger.log('COMPLETE '); resolve(true); } }) }); }
// ----------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/dashboard.service.ts#L88-L123
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
DashboardService.getCurrentProject
async getCurrentProject(): Promise<boolean> { return new Promise((resolve, reject) => { this.projectService.getProjectById(this.projectID).subscribe({ next: (project: Project)=>{ if (project) { this.project = project; this.projectID = project._id; resolve(true); } }, error: (error)=>{ this.logger.error(' [ DSHBRD-SERVICE ] getCurrentProject ERROR: ', error); reject(false); }, complete: ()=> { this.logger.log('COMPLETE '); resolve(true); }}) }); }
// ----------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/dashboard.service.ts#L128-L144
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
DashboardService.getDeptsByProjectId
getDeptsByProjectId(): Promise<boolean>{ return new Promise((resolve, reject)=>{ this.departmentService.getDeptsByProjectId().subscribe({ next: (departments: any) => { this.logger.log('[CDS DSHBRD] - DEPT GET DEPTS ', departments); if (departments) { this.departments = departments departments.forEach((dept: any) => { // this.logger.log('[CDS DSHBRD] - DEPT', dept); if (dept.default === true) { this.defaultDepartment = dept; return } }) resolve(true); } }, error: (error) => { this.logger.error('[CDS DSHBRD] - DEPT - GET DEPTS - ERROR', error); reject(false); }, complete: () => { this.logger.log('[CDS DSHBRD] - DEPT - GET DEPTS - COMPLETE'); resolve(true); }}); }) }
// ----------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/dashboard.service.ts#L150-L174
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
DepartmentService.getDeptsAsOldWidget
public getDeptsAsOldWidget(): Observable<Department[]> { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; // const url = `http://localhost:3000/app1/departments/`; // const url = `http://api.chat21.org/app1/departments/; const url = this.URL_TILEDESK_DEPARTMENTS; this.logger.log('[DEPTS-SERV] - GET DEPTS AS OLD WIDGET VERSION', url); return this.httpClient .get<Department[]>(url, httpOptions) }
// ---------------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/department.service.ts#L48-L63
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
DepartmentService.getDeptsAsNewWidget
public getDeptsAsNewWidget(): Observable<Department[]> { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; const url = this.SERVER_BASE_PATH + this.project_id + '/widgets' this.logger.log('[DEPTS-SERV] - GET DEPTS AS THE NEW WIDGET VERSION URL', url); return this.httpClient .get<Department[]>(url, httpOptions) }
// ------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/department.service.ts#L69-L82
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
DepartmentService.getVisitorCounter
public getVisitorCounter(): Observable<[any]> { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; const url = this.SERVER_BASE_PATH + this.project_id + '/visitorcounter' this.logger.log('[DEPTS-SERV] - GET DEPTS AS THE NEW WIDGET VERSION URL', url); return this.httpClient .get<[any]>(url, httpOptions) }
// ------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/department.service.ts#L87-L101
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
DepartmentService.getDeptsByProjectId
public getDeptsByProjectId(): Observable<Department[]> { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; const url = this.URL_TILEDESK_DEPARTMENTS + 'allstatus'; this.logger.log('[DEPTS-SERV] GET DEPTS ALL STATUS - DEPTS URL', url); return this.httpClient .get<Department[]>(url, httpOptions) }
/** * GET ALL DEPTS WITH THE CURRENT PROJECT ID AND WITHOUT FILTER FOR STATUS * NOTE: THE CALLBACK TO GET THE DEPTS FILTERED FOR STATUS IS RUNNED BY THE WIDGET * NOTE: the DSBRD CALL /departments/allstatus WHILE the WIDGET CALL /departments * * NOTE: chat21-api-node.js READ THE CURRENT PROJECT ID FROM THE URL SO IS NO LONGER NECESSARY TO PASS THE PROJECT ID AS PARAMETER */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/department.service.ts#L110-L123
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
DepartmentService.getDeptById
public getDeptById(id: string): Observable<Department[]> { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; let url = this.URL_TILEDESK_DEPARTMENTS + id; // url += `${id}`; this.logger.log('[DEPTS-SERV] GET DEPT BY ID - URL', url); return this.httpClient .get<Department[]>(url, httpOptions) }
/** * READ DETAIL (GET BOT BY BOT ID) * @param id */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/department.service.ts#L165-L180
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
DepartmentService.addDept
public addDept(deptName: string, deptDescription: string, id_bot: string, bot_only: boolean, id_group: string, routing: string) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; const url = this.URL_TILEDESK_DEPARTMENTS; const body = { 'name': deptName, 'description': deptDescription, 'id_group': id_group, 'routing': routing, 'id_project': this.project_id }; if (id_bot) { body['id_bot'] = id_bot; body['bot_only'] = bot_only; } else { body['id_bot'] = null; body['bot_only'] = null; } this.logger.log('[DEPTS-SERV] ADD-DEPT BODY ', body); return this.httpClient .post(url, JSON.stringify(body), httpOptions) }
/** * Create a dept * @param deptName * @param deptDescription * @param id_bot * @param bot_only * @param id_group * @param routing * @returns */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/department.service.ts#L193-L224
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
DepartmentService.deleteDeparment
public deleteDeparment(id: string) { const url = this.URL_TILEDESK_DEPARTMENTS + id; this.logger.log('[DEPTS-SERV] DELETE DEPT URL ', url); const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; return this.httpClient .delete(url, httpOptions) }
/** * DELETE (DELETE) * @param id */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/department.service.ts#L230-L244
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
DepartmentService.updateDept
public updateDept(id: string, deptName: string, deptDescription: string, id_bot: string, bot_only: boolean, id_group: string, routing: string) { const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': this.tiledeskToken }) }; let url = this.URL_TILEDESK_DEPARTMENTS + id; // url += id; this.logger.log('[DEPTS-SERV] UPDATE DEPT - URL ', url); const body = { 'name': deptName, 'description': deptDescription, 'id_group': id_group, 'routing': routing }; if (id_bot) { body['id_bot'] = id_bot; body['bot_only'] = bot_only; } else { body['id_bot'] = null; body['bot_only'] = null; } this.logger.log('[DEPTS-SERV] UPDATE DEPT - BODY ', body); return this.httpClient .put(url, JSON.stringify(body), httpOptions) }
/** * UPDATE (PUT) * @param id * @param deptName */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/services/department.service.ts#L251-L277
297d30da01d98a1299e7197eb88cff5b2390a386