Rahul_Sadana | 2018-12-27 15:03:33 UTC | #1
We are looking to update (ie replace) the "in queue call flow" assigned to an Inbound call flow can anyone please advise, what is the right API and the sequence of steps to this, we have tried to do this using the REST API put the PUT API is actually creating a new "InqueueCallflow"
MelissaBailey | 2019-01-02 16:07:14 UTC | #2
If you're wanting to modify the inbound call flow, you need to either do it using the UI or architect scripting.
https://mypurecloud.github.io/purecloud-flow-scripting-api-sdk-javascript/
anon28066628 | 2019-01-03 19:33:30 UTC | #3
The InQueue flow used is also set as a default in the ACD Queue settings. There should be a REST call to update that. The Inbound Flow only dictates the InQueue flow if you override the default settings ("Override default in-queue handling").
https://help.mypurecloud.com/articles/about-in-queue-flow-precedence/
If you're overriding the InQueue flow setting in your Inbound Flow, then you'd need to use the Architect Scripting library Melissa linked. If you can re-work your design so the default InQueue flow on the Queue settings is used, then a REST call can change it.
Rahul_Sadana | 2019-01-07 13:31:06 UTC | #4
Hi ,
I am trying to do update the "Inqueue Call Flow" using the "purecloud-flow-scripting-api-sdk-javascript" , able to fetch inbound call flow information but now struck on which exact factory or method I can use to go to the Reusable menu inside the Inbound call flow and then go to the "transfer to acd" and update the "Inqueue call flow" assigned to the "transfer to acd"
Can you please help me with the factory and methods names for: -For getting a reusable menu inside the inbound call flow. -For getting the "Transfer to ACD" task used inside a reusable menu. -For updating the "inqueue call flow" assigned to "Transfer to ACD"
Actually I am having time to search the above information in the documentation, will really appreciate if you help me above info
Rahul_Sadana | 2019-01-10 10:15:33 UTC | #5
Can anyone help on this please !
Eric_Spence | 2019-01-10 15:13:00 UTC | #6
Hi @Rahul_Sadana,
So to manipulate the In-Queue value on a Transfer to ACD you can follow these steps.
- Traverse all of the reusable menu choices, which are stored off the flow in a flows.menusResuable. A common thing to compare is the name/trackingId of a reusable menu.
- Traverse all of the child menus under the chosen reusable menu. This property is childMenus. Note you may have to recursively search here if the Target Transfer To ACD action is nested under several menus. Here is an example of how this may look
`archInboundCallFlow.menusReusable[0].childMenus` - Save the found menu choice to a variable.
- Next use getFlowInfoByFlowNameAsync to retrieve the flow infromation for the target inqueue flow.
- In the
`callbackFunctionopt` of getFlowInfoByFlowNameAsync assign the property
actionTransferToAcd = `<saved-variable>`
- Outside that callback save/publish the flow.
- The In-Queue Call Flow should now point to the correct flow.
Let me know if this either doesn't match your use case or is unclear. If this doesn't get you pointed in the right direction let me know and I can throw together some sample code for you.
Eric Spence
Rahul_Sadana | 2019-01-11 07:56:32 UTC | #7
Hi Eric ,
Thanks! for sharing the details , tried this again , It will be great if you share a sample code , it will go a long way in guiding me with and help me also in further planned automation with pure cloud scripting.
Eric_Spence | 2019-01-11 15:16:42 UTC | #8
Here is an example snippet of recursively searching through all reusable menus to find the correct Transfer To ACD Action. Disclaimer this code is just example code and I can't guarantee that it will work in all scenarios but this should get you headed in the right direction. Feel free to let me know if you need anymore help
function scriptMain() { const flowName = 'ExampleFlow';
/**
- Recursively search nested menu choices for
- the first menu choice by name
- @param archMenu - the parent menu
- @param menuChoiceName - name of the action to search for
- @return {*}
*/ const findFirst = (archMenu, menuChoiceName) => { let currentArchChildMenu, foundArchTargetAction; for (let i = 0; i < archMenu.childMenus.length; i++) { currentArchChildMenu = archMenu.childMenus[i]; if (currentArchChildMenu.childMenus) { foundArchTargetAction = findFirst(currentArchChildMenu, menuChoiceName); } if (foundArchTargetAction) { return foundArchTargetAction; } if (currentArchChildMenu.name === menuChoiceName) { return currentArchChildMenu; } } return void 0; };
return flowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName, enums.FLOWTYPES.inboundCall, true, 'latest' , function (archInboundCallFlow) { flowFactory.getFlowInfoByFlowNameAsync('InqueueTarget',enums.FLOWTYPES.inqueueCall, function (archInQueueFlowInfo) { let archTransferToAcdMenuChoice; // Iterate through all reusable menus until we find the action for (let i = 0; i < archInboundCallFlow.menusReusable.length; i++) { archTransferToAcdMenuChoice = findFirst(archInboundCallFlow.menusReusable[i], 'Transfer to ACD'); // Currently this only searches an single reusable task. // If we found the transfer to acd action let's go ahead and set the inQueueHandlingFlowInfo. if (archTransferToAcdMenuChoice && archTransferToAcdMenuChoice.isArchMenuTransferToAcd) { archTransferToAcdMenuChoice.actionTransferToAcd.inQueueHandlingFlowInfo = archInQueueFlowInfo; break; } } }); // Here you can either saveAsync or publishAsync return archInboundCallFlow.saveAsync(true); }); }
Rahul_Sadana | 2019-01-15 17:34:17 UTC | #9
Thanks!! Eric really appreciate your help on this. , will try this out and let you know how it goes.
Rahul_Sadana | 2019-01-28 08:38:38 UTC | #10
Hi Eric ,
I was able to use this script fine , however there is one issue , this script is able to update an "In-queue call flow" assigned to "Transfer to ACD" action when its directly under a reusable menu, I am not able to update the "In-queue call flow" when its assigned to a task under a reusable menu.
To illustrate this sharing an example
Able to update the below script as in this "Transfer to ACD" action is directly under a reusable menu
However not able to update the below script example on which a "Transfer to ACD1" action comes under a task "ITSD main menu" which is under a reusable menu "ITSD main menu"
Tried to traverse the objects under the reusable menu but getting undefined, can you please help on this whit what is the exact method/factory to reach the "transfer to acd" actions assigned inside a task, as this will help me to close this.
Thanks!!!!
Eric_Spence | 2019-01-28 20:04:02 UTC | #11
Hi @Rahul_Sadana,
The reason it isn't searching the tasks is that code chunk I added did not have include searching tasks. When I wrote that example I didn't realize you wanted to search tasks as well, sorry about that. So, I went ahead and updated the code chunk that I posted before to search tasks that are nested under a reusable menu. Note currently this doesn't search through reusable tasks but the logic would be the same to do that. Another disclaimer that this is just example code and is not guaranteed to work in all cases. If you have any other questions feel free to ask.
Eric Spence
function scriptMain() {
const flowName = 'ExampleFlow'; /**
- Recursively search an action container for an action by its name.
- @param archContainer - the action container to search such as a task or state
- @param nameToFind - the name of the action to find
- @return {ArchBaseAction}
*/ const findFirstInContainer = (archContainer, nameToFind) => { let currentArchBaseAction, foundArchBaseAction; for (let i = 0; i < archContainer.actions.length; i++) { currentArchBaseAction = archContainer.actions[i]; if (currentArchBaseAction.name === nameToFind) { return currentArchBaseAction; } // If the action has outputs search through all those outputs if (currentArchBaseAction.isArchBaseActionWithOutputs) { for (let outputIndex = 0; outputIndex < currentArchBaseAction.outputCount; outputIndex++) { foundArchBaseAction = findFirstInContainer(currentArchBaseAction.getOutputByIndex(outputIndex), nameToFind); if (foundArchBaseAction) { return foundArchBaseAction; } } } } return void 0; };
/**
- Recursively search nested menu choices for
- the first menu choice by name
- @param archMenu - the parent menu
- @param nameToFind - the name of the action to find
- @return {*}
*/ const findFirst = (archMenu, nameToFind) => { let currentArchChildMenu, foundArchTargetAction; for (let i = 0; i < archMenu.childMenus.length; i++) { currentArchChildMenu = archMenu.childMenus[i]; if (currentArchChildMenu.childMenus) { foundArchTargetAction = findFirst(currentArchChildMenu, nameToFind); } if (currentArchChildMenu.actionTask) { foundArchTargetAction = findFirstInContainer(currentArchChildMenu.actionTask.task, nameToFind); } if (foundArchTargetAction) { return foundArchTargetAction; } if (currentArchChildMenu.name === nameToFind) { return currentArchChildMenu; } } return void 0; };
return flowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName, enums.FLOWTYPES.inboundCall, true, 'latest' , function (archInboundCallFlow) { flowFactory.getFlowInfoByFlowNameAsync('InqueueTarget',enums.FLOWTYPES.inqueueCall, function (archInQueueFlowInfo) { let archTransferAction; // Iterate through all reusable menus until we find the action for (let i = 0; i < archInboundCallFlow.menusReusable.length; i++) { archTransferAction = findFirst(archInboundCallFlow.menusReusable[i], 'Transfer to ACD'); // Currently this only searches an single reusable task. // If we found the transfer to acd action let's go ahead and set the inQueueHandlingFlowInfo. if (archTransferAction && archTransferAction.isArchMenuTransferToAcd) { archTransferAction.actionTransferToAcd.inQueueHandlingFlowInfo = archInQueueFlowInfo; break; } else if (archTransferAction && archTransferAction.isArchActionTransferToAcd) { archTransferAction.inQueueHandlingFlowInfo = archInQueueFlowInfo; break; } } }); // Here you can either saveAsync or publishAsync return archInboundCallFlow.saveAsync(true); }); }
Rahul_Sadana | 2019-02-10 03:11:38 UTC | #12
Hi Eric,
Having few issues with this script, on first instance this script runs fine with no errors, but the "inqueue call flow" is not updated when I go and check the script.
on subsequent instances, I get two different types of errors.
1.Cannot read property 'toLowerCase' of undefined:
- Ending session. Exception info: TypeError: Cannot read property 'exception' of undefined
Please note executing the script on same inbound call flow in all three instances
Logs for when the script is running without any errors but not updating (have removed/updated with dummy values for all tokens and other security related info )
c:\code\PureCloud-automation>node sdktest5.js Architect Scripting running under Node version '8.9.3' ArchSessionId:XXXXXXX
setting session status to 'running'. -- [ArchSession, ArchSessionId:'XXXXXXX'] navigator unavailable - setting operating system to unknown architect scripting version: 0.1.0 -- [ArchSession, ArchSessionId:'XXXXXXX'] core environment configuration. env: 'prod', host: 'apps.mypurecloud.com', region: 'us-east-1', clientId: 'e6XXXXX57-f815e6b4d640', clientSecret: '-dCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXyNULo' -- [ArchSession, ArchSessionId:'S14XXXXXXXXX4'] getting discovery properties... -- [ArchSession, ArchSessionId:'XXXXXXX'] calling url -- [GET::https://apps.mypurecloud.com/services/discovery.properties] App listening on port 8080 response received - statusCode:200, statusMessage:OK, correlationId:undefined -- [GET::https://apps.mypurecloud.com/services/discovery.properties] core environment discovery properties loaded. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXX'] core environment initialized. Now logging in... -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXX'] calling url -- [POST::https://login.mypurecloud.com/token] response received - statusCode:200, statusMessage:OK, correlationId:2109b0d8-778d-4115-42f6-0a04f4da6b09 -- [POST::https://login.mypurecloud.com/token] setting auth token 'yWI8olaP8BTqi8aJA-FjPUK2bqdhTnGdcu10UaXXFHqRSkuiahdu1nYd3LeAbuqMRms5RBeHtW9mpmdDTyS4Q' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXX'] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization] response received - statusCode:200, statusMessage:OK, correlationId:f118-- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization] authenticated name: 'Rahul Sadhana' , id: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxx4' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'S14E4'] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000] obtaining organization information -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXX'] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me] response received - statusCode:200, statusMessage:OK, correlationId:e8b1d837-3a04-4a33-95c3-2311bd6cb9c6 -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000] response received - statusCode:200, statusMessage:OK, correlationId:05443996-a556-49fd-93cf-7d83408ac306 -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me] obtained organization information. organization name: 'xyz', id: 'XXXXXXXXXXXXXX' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXX', OrgName:'xyz', OrgId:'XXXXXXXXXXXXXX'] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=archVoiceXml&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=workflowClient&feature=workflowMessagingLex&feature=authorization.division.management&feature=authorization.division.management.outbound.lists] response received - statusCode:200, statusMessage:OK, correlationId:ab21eae2-d119-47de-a037-c60be796a6d0 -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=archVoiceXml&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=workflowClient&feature=workflowMessagingLex&feature=authorization.division.management&feature=authorization.division.management.outbound.lists] calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes] response received - statusCode:200, statusMessage:OK, correlationId:dfa9b5f4-0cab-4192-b558-46d5b72b767f -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels] response received - statusCode:200, statusMessage:OK, correlationId:83f2615d-da34-43cf-8985-e17e929a2335 -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes] ArchFactoryFlows startup initialization - begin. -- [ArchFactoryFlows] ArchFactoryFlows startup initialization - end. -- [ArchFactoryFlows] session startup initialization for startWithClientIdAndSecret complete. Calling callback function. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXX', OrgName:'xyz', OrgId:'XXXXXXXXXXXXXX'] find 'flow name' by property value where 'name' = 'NA6HELPMAINSTAGE' -- [ArchNetworkValueRetrieval] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=NA_6HELP_MAIN_STAGE] session startup initialization for startWithClientIdAndSecret complete. Callback function execution complete. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXX', OrgName:'xyz', OrgId:'XXXXXXXXXXXXXX'] session startup initialization for startWithClientIdAndSecret complete. Callback function returned a promise. Waiting until it resolves. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXX', OrgName:'xyz', OrgId:'XXXXXXXXXXXXXX'] response received - statusCode:200, statusMessage:OK, correlationId:8c9e89b1-447c-4a38-96ea-20da11d77998 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=NA_6HELP_MAIN_STAGE] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/XXXXXXXXXXXXXXXXXXXXXXXXXXX/latestConfiguration?deleted=true] response received - statusCode:200, statusMessage:OK, correlationId:609e0b37-5a62-41e7-97fd-b0d146e525ab -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/XXXXXXXXXXXXXXXXXXXXXXXXXXX/latestConfiguration?deleted=true] calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/jqn0fm509bbbjsk0c6iugc5ksm/subscriptions] response received - statusCode:200, statusMessage:OK, correlationId:bb9bd4e5-4445-481d-bf95-566c7cffa65b -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/jqn0fm509bbbjsk0c6iugc5ksm/subscriptions] calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=XXXXXXXXXXXXXXXXXXXXXXXXXXX&flowType=inboundcall] response received - statusCode:202, statusMessage:Accepted, correlationId:5196b058-e926-483f-a401-0124fa913f1e -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=XXXXXXXXXXXXXXXXXXXXXXXXXXX&flowType=inboundcall] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/XXXXXXXXXXXXXXXXXXXXXXXXXXX/validate/b2d5af22-c765-47f59] response received - statusCode:200, statusMessage:OK, correlationId:4bcd7469-b8e8-410c-bb78-c94a2809bc27 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/XXXXXXXXXXXXXXXXXXXXXXXXXXX/validate/b2d5af22-c765-47f0-9f33-7fba88583e59] async processing for checkoutAndLoadFlowByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows] find 'flow name' by property value where 'name' = 'Ca In queue' -- [ArchNetworkValueRetrieval] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=Ca%20In%20queue] saveAsync - saving flow... -- [Name:'NA6HELPMAINSTAGE', Type:'ArchFlowInboundCall', Id:'XXXXXXXXXXXXXXXXXXXXXXXXXXX'] iteration 0: Waiting for 2 async operation(s) to complete... -- [ArchAsyncTracker] async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function execution complete. -- [ArchFactoryFlows] async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function returned a promise. Waiting until it resolves. -- [ArchFactoryFlows] response received - statusCode:200, statusMessage:OK, correlationId:3263db9e-05b6-446b-bce3-6d1d4f31760f -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=Ca%20In%20queue] async processing for getFlowInfoByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows] setting the in-queue flow 'Ca In queue' to be used for the in-queue handling of the call. -- [TrackingID:249, Name:'Transfer to ACD', Type:'ArchActionTransferToAcd'] async processing for getFlowInfoByFlowNameAsync complete. Callback function execution complete. -- [ArchFactoryFlows] calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/XXXXXXXXXXXXXXXXXXXXXXXXXXX/versions] response received - statusCode:200, statusMessage:OK, correlationId:02821084-ff1d-48e9-807b-8422ff0bafe4 -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/XXXXXXXXXXXXXXXXXXXXXXXXXXX/versions] saveAsync - save successful. -- [Name:'NA6HELPMAINSTAGE', Type:'ArchFlowInboundCall', Id:'XXXXXXXXXXXXXXXXXXXXXXXXXXX'] flow url: https://apps.mypurecloud.com/architect/#/inboundcall/flows/XXXXXXXXXXXXXXXXXXXXXXXXXXX/latest/menu/1ddcddab-6f8c-46fb-be1a-d8024766bee2 -- [Name:'NA6HELPMAIN_STAGE', Type:'ArchFlowInboundCall', Id:'XXXXXXXXXXXXXXXXXXXXXXXXXXX'] async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function returned promise successfully resolved. -- [ArchFactoryFlows] session startup initialization for startWithClientIdAndSecret complete. Callback function returned promise successfully resolved. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXX', OrgName:'xyz', OrgId:'XXXXXXXXXXXXXX'] setting session status to 'ended'. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXX', OrgName:'xyz', OrgId:'XXXXXXXXXXXXXX'] ending with exit code: 0 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXX', OrgName:'xyz', OrgId:'XXXXXXXXXXXXXX'] session is configured to terminate the process when ending. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXX', OrgName:'xyz', OrgId:'XXXXXXXXXXXXXX'] now exiting the process with exit code: 0 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXX', OrgName:'xyz', OrgId:'XXXXXXXXXXXXXX']
Rahul_Sadana | 2019-02-10 03:13:49 UTC | #13
1.Logs when the script throws the error "Cannot read property 'toLowerCase' of undefined"
c:\code\PureCloud-automation>node sdktest5.js Architect Scripting running under Node version '8.9.3' ArchSessionId:XXXXX
setting session status to 'running'. -- [ArchSession, ArchSessionId:'XXXXX'] navigator unavailable - setting operating system to unknown architect scripting version: 0.1.0 -- [ArchSession, ArchSessionId:'XXXXX'] core environment configuration. env: 'prod', host: 'apps.mypurecloud.com', region: 'us-east-1', clientId: '12345', clientSecret: '-d7878787878' -- [ArchSession, ArchSessionId:'XXXXX'] getting discovery properties... -- [ArchSession, ArchSessionId:'XXXXX'] calling url -- [GET::https://apps.mypurecloud.com/services/discovery.properties] App listening on port 8080 response received - statusCode:200, statusMessage:OK, correlationId:undefined -- [GET::https://apps.mypurecloud.com/services/discovery.properties] core environment discovery properties loaded. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXX'] core environment initialized. Now logging in... -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXX'] calling url -- [POST::https://login.mypurecloud.com/token] response received - statusCode:200, statusMessage:OK, correlationId:743f36a2-9102-423b-5b2e-24a0421f11f9 -- [POST::https://login.mypurecloud.com/token] setting auth token 'oiueroieuroeurourouewoue' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXX'] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization] response received - statusCode:200, statusMessage:OK, correlationId:3c319835-98de-4f56-84e3-df8c5b362fac -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization] authenticated name: 'Rahul Sadhana' , id: '898989898989898' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXX'] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000] obtaining organization information -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXX'] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me] response received - statusCode:200, statusMessage:OK, correlationId:8408162f-4864-4ad2-b0e8-705d916a3a33 -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000] response received - statusCode:200, statusMessage:OK, correlationId:14d42604-6429-436b-9686-7eb30897ec77 -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me] obtained organization information. organization name: 'Adobe', id: '4214e8bd-987b-45f9-b865-62d8c47c0d55' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXX', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55'] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=archVoiceXml&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=workflowClient&feature=workflowMessagingLex&feature=authorization.division.management&feature=authorization.division.management.outbound.lists] response received - statusCode:200, statusMessage:OK, correlationId:d1aa7356-d4ca-42db-baac-5c4ec3eed080 -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=archVoiceXml&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=workflowClient&feature=workflowMessagingLex&feature=authorization.division.management&feature=authorization.division.management.outbound.lists] calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes] response received - statusCode:200, statusMessage:OK, correlationId:b578bcf6-e577-4f04-ac6f-13d78ec649de -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels] response received - statusCode:200, statusMessage:OK, correlationId:ecb441e9-e052-4718-9036-a7580df0751b -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes] ArchFactoryFlows startup initialization - begin. -- [ArchFactoryFlows] ArchFactoryFlows startup initialization - end. -- [ArchFactoryFlows] session startup initialization for startWithClientIdAndSecret complete. Calling callback function. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXX', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55'] find 'flow name' by property value where 'name' = 'NA6HELPMAINSTAGE' -- [ArchNetworkValueRetrieval] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=NA6HELPMAINSTAGE] session startup initialization for startWithClientIdAndSecret complete. Callback function execution complete. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXX', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55'] session startup initialization for startWithClientIdAndSecret complete. Callback function returned a promise. Waiting until it resolves. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXX', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55'] response received - statusCode:200, statusMessage:OK, correlationId:eb221cf0-fb88-4b72-bda5-e1dc6263b92e -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=NA_6HELP_MAIN_STAGE] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/33d98738-2af6-4f93-858b-7f707a2f9c20/latestConfiguration?deleted=true] response received - statusCode:200, statusMessage:OK, correlationId:b8c93f4a-d2d1-47f5-8b8c-5d7aebd64b9d -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/33d98738-2af6-4f93-858b-7f707a2f9c20/latestConfiguration?deleted=true] calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/1lptj7aaibee40615gv17km26c/subscriptions] response received - statusCode:200, statusMessage:OK, correlationId:8ded1466-2a99-461c-a3df-6c97834fefdb -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/1lptj7aaibee40615gv17km26c/subscriptions] calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=33d98738-2af6-4f93-858b-7f707a2f9c20&flowType=inboundcall] response received - statusCode:202, statusMessage:Accepted, correlationId:9492a958-5f64-4e61-a794-817574899be0 -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=33d98738-2af6-4f93-858b-7f707a2f9c20&flowType=inboundcall] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/33d98738-2af6-4f93-858b-7f707a2f9c20/validate/5a601447-9285-4735-9617-4d2f58168740] response received - statusCode:200, statusMessage:OK, correlationId:b2879a23-aae2-4ee2-868c-e0bfc5cc49fd -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/33d98738-2af6-4f93-858b-7f707a2f9c20/validate/5a601447-9285-4735-9617-4d2f58168740] async processing for checkoutAndLoadFlowByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows] find 'flow name' by property value where 'name' = 'Ca In queue' -- [ArchNetworkValueRetrieval] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=Ca%20In%20queue] saveAsync - saving flow... -- [Name:'NA_6HELPMAINSTAGE', Type:'ArchFlowInboundCall', Id:'33d98738-2af6-4f93-858b-7f707a2f9c20'] iteration 0: Waiting for 2 async operation(s) to complete... -- [ArchAsyncTracker] async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function execution complete. -- [ArchFactoryFlows] async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function returned a promise. Waiting until it resolves. -- [ArchFactoryFlows] response received - statusCode:200, statusMessage:OK, correlationId:0ea0f954-1c8b-4264-b655-771dd3f4c15f -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=Ca%20In%20queue] async processing for getFlowInfoByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows] ERROR! ArchFactoryFlows.getFlowInfoByFlowNameAsync - Caught unhandled exception during callback function execution. Ending session. Exception info: TypeError: Cannot read property 'toLowerCase' of undefined -- [ArchFactoryFlows] ERROR! ending the Session. Setting the exit code to 99. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXX', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55'] setting session status to 'ended'. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXX', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55'] ending with exit code: 99 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXX', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55'] session is configured to terminate the process when ending. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXX', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55'] now exiting the process with exit code: 99 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXX', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
2.Logs with scripts exit with an error "TypeError: Cannot read property 'exception' of undefined"
c:\code\PureCloud-automation>node sdktest5.js Architect Scripting running under Node version '8.9.3' ArchSessionId:XXXXXXXX
setting session status to 'running'. -- [ArchSession, ArchSessionId:'XXXXXXXX'] navigator unavailable - setting operating system to unknown architect scripting version: 0.1.0 -- [ArchSession, ArchSessionId:'XXXXXXXX'] core environment configuration. env: 'prod', host: 'apps.mypurecloud.com', region: 'us-east-1', clientId: '', clientSecret: '-d' -- [ArchSession, ArchSessionId:'XXXXXXXX'] getting discovery properties... -- [ArchSession, ArchSessionId:'XXXXXXXX'] calling url -- [GET::https://apps.mypurecloud.com/services/discovery.properties] App listening on port 8080 response received - statusCode:200, statusMessage:OK, correlationId:undefined -- [GET::https://apps.mypurecloud.com/services/discovery.properties] core environment discovery properties loaded. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX'] core environment initialized. Now logging in... -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX'] calling url -- [POST::https://login.mypurecloud.com/token] response received - statusCode:200, statusMessage:OK, correlationId:32684a05-76af-4918-67d4-98ddcea340a9 -- [POST::https://login.mypurecloud.com/token] setting auth token 'n,n,n,n,n,n,n' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX'] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization] response received - statusCode:200, statusMessage:OK, correlationId:d4eb6c3e-93b4-4986-8cb6-c9e446fc50eb -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization] authenticated name: 'Rahul' , id: 'xyz' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX'] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000] obtaining organization information -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX'] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me] response received - statusCode:200, statusMessage:OK, correlationId:ed24eece-758c-4c72-9281-24ea4fa74023 -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000] response received - statusCode:200, statusMessage:OK, correlationId:aea8b217-5856-4ea3-a67a-2442422e30b5 -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me] obtained organization information. organization name: 'Adobe', id: 'XXXX' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX', OrgName:'Adobe', OrgId:'XXXX'] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=archVoiceXml&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=workflowClient&feature=workflowMessagingLex&feature=authorization.division.management&feature=authorization.division.management.outbound.lists] response received - statusCode:200, statusMessage:OK, correlationId:505b581b-79d7-4b26-8d17-75e2ef96731f -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=archVoiceXml&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=workflowClient&feature=workflowMessagingLex&feature=authorization.division.management&feature=authorization.division.management.outbound.lists] calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes] response received - statusCode:200, statusMessage:OK, correlationId:7501a712-7909-4b9b-b086-8c453422ae1a -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels] response received - statusCode:200, statusMessage:OK, correlationId:7e34698b-8b0c-4fcf-b665-c263c429211a -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes] ArchFactoryFlows startup initialization - begin. -- [ArchFactoryFlows] ArchFactoryFlows startup initialization - end. -- [ArchFactoryFlows] session startup initialization for startWithClientIdAndSecret complete. Calling callback function. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX', OrgName:'Adobe', OrgId:'XXXX'] find 'flow name' by property value where 'name' = 'NA6HELPMAINSTAGE' -- [ArchNetworkValueRetrieval] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=NA6HELPMAINSTAGE] session startup initialization for startWithClientIdAndSecret complete. Callback function execution complete. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX', OrgName:'Adobe', OrgId:'XXXX'] session startup initialization for startWithClientIdAndSecret complete. Callback function returned a promise. Waiting until it resolves. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX', OrgName:'Adobe', OrgId:'XXXX'] response received - statusCode:200, statusMessage:OK, correlationId:c130711a-40e7-4178-9bf4-5347b7c65bfb -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=NA_6HELP_MAIN_STAGE] calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/checkOut?flow=33d98738-2af6-4f93-858b-7f707a2f9c20] response received - statusCode:200, statusMessage:OK, correlationId:073dcf18-91a0-4cb9-b774-29dc2cfb12d7 -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/checkOut?flow=33d98738-2af6-4f93-858b-7f707a2f9c20] calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/33d98738-2af6-4f93-858b-7f707a2f9c20/latestConfiguration?deleted=true] response received - statusCode:200, statusMessage:OK, correlationId:7a57ecfb-13ff-4a5c-a08a-5770ab2a35ba -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/33d98738-2af6-4f93-858b-7f707a2f9c20/latestConfiguration?deleted=true] ERROR! promise unhandled exception caught. Error: TypeError: Cannot read property 'exception' of undefined -- [ArchAsyncTracker] ERROR! session startup initialization for startWithClientIdAndSecret complete. Caught unhandled exception waiting for callback function returned promise to resolve. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX', OrgName:'Adobe', OrgId:'XXXX'] ERROR! ArchSession.startWithClientIdAndSecret - Caught unhandled exception during callback function execution. Ending session. Exception info: TypeError: Cannot read property 'exception' of undefined -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX', OrgName:'Adobe', OrgId:'XXXX'] ERROR! ending the Session. Setting the exit code to 99. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX', OrgName:'Adobe', OrgId:'XXXX'] setting session status to 'ended'. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX', OrgName:'Adobe', OrgId:'XXXX'] ending with exit code: 99 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX', OrgName:'Adobe', OrgId:'XXXX'] session is configured to terminate the process when ending. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX', OrgName:'Adobe', OrgId:'XXXX'] now exiting the process with exit code: 99 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'XXXXXXXX', OrgName:'Adobe', OrgId:'XXXX']
Rahul_Sadana | 2019-02-10 03:15:12 UTC | #14
Current version of the script I am trying with is below
// -------------------------------------------------------------------------------- // Require in the PureCloud Architect Scripting SDK // -------------------------------------------------------------------------------- const architectScripting = require('purecloud-flow-scripting-api-sdk-javascript'); const express = require('express'); const app = express() // -------------------------------------------------------------------------------- // See above in the readme for information on creating a client id / secret. // We will use these when starting the Architect Scripting session below. // Remember, the Architect Scripting session object also has a way to start // with you supplying an auth token too. // -------------------------------------------------------------------------------- const clientId = ''; const clientSecret = '';
// -------------------------------------------------------------------------------- // Flow name and description constants for the flow that will be created. // --------------------------------------------------------------------------------
// -------------------------------------------------------------------------------- // Helpers to make sample code more readable below. // -------------------------------------------------------------------------------- const scriptingActionFactory = architectScripting.factories.archFactoryActions; // Factory to create actions const scriptingEnums = architectScripting.enums.archEnums; // Enum support const scriptingFlowFactory = architectScripting.factories.archFactoryFlows; // Factory to create flows const scriptingLanguages = architectScripting.languages.archLanguages; // Language support const scriptingSession = architectScripting.environment.archSession; // Session support const scriptingTaskFactory = architectScripting.factories.archFactoryTasks; // Factory to create tasks const scriptingLogger = architectScripting.services.archLogging; // Logging support
// -------------------------------------------------------------------------------- // Enables additional logging during execution. It definitely helps when // debugging your code so we want to show how to enable it in this example. // -------------------------------------------------------------------------------- scriptingLogger.logNotesVerbose = true;
// -------------------------------------------------------------------------------- // Set up a constant for the organization's location. // -------------------------------------------------------------------------------- const location = scriptingEnums.LOCATIONS.produseast_1;
function scriptMain() {
const flowName = 'NA6HELPMAIN_STAGE'; /**
- Recursively search an action container for an action by its name.
- @param archContainer - the action container to search such as a task or state
- @param nameToFind - the name of the action to find
- @return {ArchBaseAction}
*/ const findFirstInContainer = (archContainer, nameToFind) => { let currentArchBaseAction, foundArchBaseAction; for (let i = 0; i < archContainer.actions.length; i++) { currentArchBaseAction = archContainer.actions[i]; if (currentArchBaseAction.name === nameToFind) { return currentArchBaseAction; } // If the action has outputs search through all those outputs if (currentArchBaseAction.isArchBaseActionWithOutputs) { for (let outputIndex = 0; outputIndex < currentArchBaseAction.outputCount; outputIndex++) { foundArchBaseAction = findFirstInContainer(currentArchBaseAction.getOutputByIndex(outputIndex), nameToFind); if (foundArchBaseAction) { return foundArchBaseAction; } } } } return void 0; };
/**
- Recursively search nested menu choices for
- the first menu choice by name
- @param archMenu - the parent menu
- @param nameToFind - the name of the action to find
- @return {*}
*/ const findFirst = (archMenu, nameToFind) => { let currentArchChildMenu, foundArchTargetAction; for (let i = 0; i < archMenu.childMenus.length; i++) { currentArchChildMenu = archMenu.childMenus[i]; if (currentArchChildMenu.childMenus) { foundArchTargetAction = findFirst(currentArchChildMenu, nameToFind); } if (currentArchChildMenu.actionTask) { foundArchTargetAction = findFirstInContainer(currentArchChildMenu.actionTask.task, nameToFind); } if (foundArchTargetAction) { return foundArchTargetAction; } if (currentArchChildMenu.name === nameToFind) { return currentArchChildMenu; } } return void 0; };
return scriptingFlowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName, scriptingEnums.FLOWTYPES.inboundCall, true, 'latest' , function (archInboundCallFlow) { scriptingFlowFactory.getFlowInfoByFlowNameAsync('Ca In queue',scriptingEnums.FLOWTYPES.inqueueCall, function (archInQueueFlowInfo) {
let archTransferAction; // Iterate through all reusable menus until we find the action for (let i = 0; i < archInboundCallFlow.menusReusable.length; i++) { archTransferAction = findFirst(archInboundCallFlow.menusReusable[i], 'Transfer to ACD'); // Currently this only searches an single reusable task. // If we found the transfer to acd action let's go ahead and set the inQueueHandlingFlowInfo. if (archTransferAction && archTransferAction.isArchMenuTransferToAcd) { archTransferAction.actionTransferToAcd.inQueueHandlingFlowInfo = archInQueueFlowInfo; break; } else if (archTransferAction && archTransferAction.isArchActionTransferToAcd) { archTransferAction.inQueueHandlingFlowInfo = archInQueueFlowInfo; break; } } }); // Here you can either saveAsync or publishAsync
return archInboundCallFlow.saveAsync(true); }); }
scriptingSession.startWithClientIdAndSecret(location, scriptMain, clientId, clientSecret); app.listen(8080); console.log("App listening on port 8080");
Eric_Spence | 2019-02-11 13:52:15 UTC | #15
Hi @Rahul_Sadana, I noticed that you are running on version 0.1.0. I believe it could be possible your are running into an issue that was fixed in version 0.2.0. This may fix your TypeError. In regards to the traversal issue I noticed in the first set of logs that an in-queue call flow does seem to be getting set. setting the in-queue flow 'Ca In queue' to be used for the in-queue handling of the call. -- [TrackingID:249, Name:'Transfer to ACD', Type:'ArchActionTransferToAcd'] Is it possible you have multiple actions with the same name?
Rahul_Sadana | 2019-02-12 00:57:13 UTC | #16
Thanks! for getting back on this.
I have upgraded to 0.2.0, post that had "type error" only once since than have executed this multiple times not able to reproduce the type error since then , will test this more and update you.
Also you are correct there were actually multiple "Transfer to ACD" actions in the same Architect script on the PureCloud
Getting Closer!!!
Eric_Spence | 2019-02-12 04:45:32 UTC | #17
Excellent! If anymore issues popup let me know and I am more than willing to look into it.
Rahul_Sadana | 2019-02-12 18:32:07 UTC | #18
Hi Eric ,
"Type error" is now coming in all tests I am running , have tried with different Architect Inbound calls flows and the result is same.
Exact error showing up is -" ERROR! ArchFactoryFlows.getFlowInfoByFlowNameAsync - Caught unhandled exception during callback function execution. Ending session. Exception info: TypeError: Cannot read property 'toLowerCase' of undefined "
Somehow its now coming up on every test, there was no change in the code.
Tried by creating a new "Inbound Call flow" with "Test3" and ran the script with this new flow and surprisingly there is no type error on first instance , now when I try this running the script again with same "Test3" call flow same error shows up again , it seems somehow when the same inbound call flow is used repeatedly the issue shows up .
Including logs for: 1.For Inbound call flow "NA6HELPMAIN_STAGE" giving type error on repeated attempts. 2.For Inbound call flow "Test3" on first instance with no type error 3.For Inbound call flow "Test3" on subsequent instances every time with same type error
1.Logs for NA6HELPMAIN_STAGE with type error
c:\code\PureClou-automation1>node updateInqueuCallflow.js Architect Scripting running under Node version '8.9.3' ArchSessionId:test
- setting session status to 'running'. -- [ArchSession, ArchSessionId:'test']
navigator unavailable - setting operating system to unknown
- architect scripting version: 0.2.1 -- [ArchSession, ArchSessionId:'test']
- core environment configuration. env: 'prod', host: 'apps.mypurecloud.com', region: 'us-east-1', clientId: '', clientSecret: '-' -- [ArchSession, ArchSessionId:'test']
- getting discovery properties... -- [ArchSession, ArchSessionId:'test']
- calling url -- [GET::https://apps.mypurecloud.com/services/discovery.properties]
App listening on port 8080
- response received - statusCode:200, statusMessage:OK, correlationId:undefined -- [GET::https://apps.mypurecloud.com/services/discovery.properties]
- core environment discovery properties loaded. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test']
- core environment initialized. Now logging in... -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test']
- calling url -- [POST::https://login.mypurecloud.com/token]
- response received - statusCode:200, statusMessage:OK, correlationId:c23b6d21-fcdf-4335-79dd-2fcf19179765 -- [POST::https://login.mypurecloud.com/token]
- setting auth token '-TJEhJARQECISTLadvOSe0Y5bF8E19mgrGiyEcmbvAw7IMH21DfT9LeUPfgMrQhBIV6n7d5hkoG_rQ9uZoRg' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization]
- response received - statusCode:200, statusMessage:OK, correlationId:5ad12891-71bb-453d-92a9-f90689932174 -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization]
- authenticated name: 'Rahul Sadhana' , id: '8fbdfc5c-801f-4d6c-b259-2b44acac14f4' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000]
- obtaining organization information -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'NA6HELPMAIN_STAGEtest']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me]
- response received - statusCode:200, statusMessage:OK, correlationId:f290cb31-6452-426e-bdc0-691691410c7d -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000]
- response received - statusCode:200, statusMessage:OK, correlationId:ee21adde-dd98-4a3d-ae78-091509580687 -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me]
- obtained organization information. organization name: 'Adobe', id: '4214e8bd-987b-45f9-b865-62d8c47c0d55' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'r1FI_KgS4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeVoicemailTransferFailureHandling&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=InboundMessagingWhatsApp&feature=workflowClient&feature=workflowMessagingLex&feature=authorization.division.management&feature=authorization.division.management.outbound.lists]
- response received - statusCode:200, statusMessage:OK, correlationId:90788eab-cafe-4a08-bafb-7938945f31a7 -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeVoicemailTransferFailureHandling&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=InboundMessagingWhatsApp&feature=workflowClient&feature=workflowMessagingLex&feature=authorization.division.management&feature=authorization.division.management.outbound.lists]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes]
- response received - statusCode:200, statusMessage:OK, correlationId:86b0c679-b475-41ad-962f-05a4dcf10ed1 -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels]
- response received - statusCode:200, statusMessage:OK, correlationId:2020880c-a04f-4396-988a-d54037644a64 -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes]
- ArchFactoryFlows startup initialization - begin. -- [ArchFactoryFlows]
- ArchFactoryFlows startup initialization - end. -- [ArchFactoryFlows]
- session startup initialization for startWithClientIdAndSecret complete. Calling callback function. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'r1FI_KgS4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- find 'flow name' by property value where 'name' = 'NA6HELPMAIN_STAGE' -- [ArchNetworkValueRetrieval]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=NA_6HELP_MAIN_STAGE]
- session startup initialization for startWithClientIdAndSecret complete. Callback function execution complete. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'r1FI_KgS4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- session startup initialization for startWithClientIdAndSecret complete. Callback function returned a promise. Waiting until it resolves. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'r1FI_KgS4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- response received - statusCode:200, statusMessage:OK, correlationId:974fd587-9b9c-4dad-9cb0-1005fd2c22bb -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=NA_6HELP_MAIN_STAGE]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/33d98738-2af6-4f93-858b-7f707a2f9c20/latestConfiguration?deleted=true]
- response received - statusCode:200, statusMessage:OK, correlationId:7aa75b84-a173-47bd-96ac-3d63c47187f0 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/33d98738-2af6-4f93-858b-7f707a2f9c20/latestConfiguration?deleted=true]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/mhrbpurg8p6a7rsp94tbcpeejg/subscriptions]
- response received - statusCode:200, statusMessage:OK, correlationId:6d1437cf-4ca9-425c-af48-b7f4dd6c1946 -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/mhrbpurg8p6a7rsp94tbcpeejg/subscriptions]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=33d98738-2af6-4f93-858b-7f707a2f9c20&flowType=inboundcall]
- response received - statusCode:202, statusMessage:Accepted, correlationId:8cab288c-4ba9-49d9-aeee-977588707a6b -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=33d98738-2af6-4f93-858b-7f707a2f9c20&flowType=inboundcall]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/33d98738-2af6-4f93-858b-7f707a2f9c20/validate/907e1e8b-dca2-4bd8-89ff-a23c716b1ba6]
- response received - statusCode:200, statusMessage:OK, correlationId:f5c0671c-76ed-4b6a-82fd-3591b54043da -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/33d98738-2af6-4f93-858b-7f707a2f9c20/validate/907e1e8b-dca2-4bd8-89ff-a23c716b1ba6]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows]
- find 'flow name' by property value where 'name' = 'TEST 2 QUEUE FLOW MEETING1' -- [ArchNetworkValueRetrieval]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=TEST%202%20QUEUE%20FLOW%20MEETING1]
- saveAsync - saving flow... -- [Name:'NA6HELPMAIN_STAGE', Type:'ArchFlowInboundCall', Id:'33d98738-2af6-4f93-858b-7f707a2f9c20']
- iteration 0: Waiting for 2 async operation(s) to complete... -- [ArchAsyncTracker]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function execution complete. -- [ArchFactoryFlows]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function returned a promise. Waiting until it resolves. -- [ArchFactoryFlows]
- response received - statusCode:200, statusMessage:OK, correlationId:3f74305b-b55e-46fb-aeb9-a8c0ca1c3cc5 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=TEST%202%20QUEUE%20FLOW%20MEETING1]
- async processing for getFlowInfoByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows]
- ERROR! ArchFactoryFlows.getFlowInfoByFlowNameAsync - Caught unhandled exception during callback function execution. Ending session. Exception info: TypeError: Cannot read property 'toLowerCase' of undefined -- [ArchFactoryFlows]
- ERROR! ending the Session. Setting the exit code to 99. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'r1FI_KgS4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- setting session status to 'ended'. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'r1FI_KgS4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- ending with exit code: 99 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'r1FI_KgS4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- session is configured to terminate the process when ending. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'r1FI_KgS4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- now exiting the process with exit code: 99 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'r1FI_KgS4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
2.Logs for "Test3" with no errors
c:\code\PureClou-automation1>node updateInqueuCallflow.js Architect Scripting running under Node version '8.9.3' ArchSessionId:H1HCcter4
- setting session status to 'running'. -- [ArchSession, ArchSessionId:'H1HCcter4']
navigator unavailable - setting operating system to unknown
- architect scripting version: 0.2.1 -- [ArchSession, ArchSessionId:'H1HCcter4']
- core environment configuration. env: 'prod', host: 'apps.mypurecloud.com', region: 'us-east-1', clientId: '', clientSecret: '' -- [ArchSession, ArchSessionId:'H1HCcter4']
- getting discovery properties... -- [ArchSession, ArchSessionId:'H1HCcter4']
- calling url -- [GET::https://apps.mypurecloud.com/services/discovery.properties]
App listening on port 8080
- response received - statusCode:200, statusMessage:OK, correlationId:undefined -- [GET::https://apps.mypurecloud.com/services/discovery.properties]
- core environment discovery properties loaded. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'H1HCcter4']
- core environment initialized. Now logging in... -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'H1HCcter4']
- calling url -- [POST::https://login.mypurecloud.com/token]
- response received - statusCode:200, statusMessage:OK, correlationId:8e0ed57e-da94-43e1-4ba5-a11cabf6620d -- [POST::https://login.mypurecloud.com/token]
- setting auth token 'PCzYfM1oP1Y9G54tTPTguniajdL-JxsiMEK3K7psS3bONrkwTS6iIrQ6OPvtmSqyS7NVx2pSnn1WwEMUrJfg' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'H1HCcter4']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization]
- response received - statusCode:200, statusMessage:OK, correlationId:78e53459-19ae-4ebf-903f-0a0cdf01d0ed -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization]
- authenticated name: 'Rahul Sadhana' , id: '8fbdfc5c-801f-4d6c-b259-2b44acac14f4' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'H1HCcter4']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000]
- obtaining organization information -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'H1HCcter4']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me]
- response received - statusCode:200, statusMessage:OK, correlationId:63e7eadf-e296-4ecf-bdd9-f57ccae21f27 -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000]
- response received - statusCode:200, statusMessage:OK, correlationId:51c5cbac-80fc-42b2-949f-0adca3744e84 -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me]
- obtained organization information. organization name: 'Adobe', id: '4214e8bd-987b-45f9-b865-62d8c47c0d55' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'H1HCcter4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeVoicemailTransferFailureHandling&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=InboundMessagingWhatsApp&feature=workflowClient&feature=workflowMessagingLex&feature=authorization.division.management&feature=authorization.division.management.outbound.lists]
- response received - statusCode:200, statusMessage:OK, correlationId:31180124-26ee-4607-8381-d68b8589c013 -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeVoicemailTransferFailureHandling&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=InboundMessagingWhatsApp&feature=workflowClient&feature=workflowMessagingLex&feature=authorization.division.management&feature=authorization.division.management.outbound.lists]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes]
- response received - statusCode:200, statusMessage:OK, correlationId:c92450a1-c9a6-4b74-9895-0a6c948e1e05 -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels]
- response received - statusCode:200, statusMessage:OK, correlationId:8484fed8-2989-434c-bde9-dc6b84793ffd -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes]
- ArchFactoryFlows startup initialization - begin. -- [ArchFactoryFlows]
- ArchFactoryFlows startup initialization - end. -- [ArchFactoryFlows]
- session startup initialization for startWithClientIdAndSecret complete. Calling callback function. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'H1HCcter4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- find 'flow name' by property value where 'name' = 'Test3' -- [ArchNetworkValueRetrieval]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=Test3]
- session startup initialization for startWithClientIdAndSecret complete. Callback function execution complete. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'H1HCcter4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- session startup initialization for startWithClientIdAndSecret complete. Callback function returned a promise. Waiting until it resolves. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'H1HCcter4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- response received - statusCode:200, statusMessage:OK, correlationId:5850311d-fd58-427c-a068-aade15cf1c54 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=Test3]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/4/latestConfiguration?deleted=true]
- response received - statusCode:200, statusMessage:OK, correlationId:1b8978a1-2599-4d42-93ab-7cdf8c89b2c7 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/4/latestConfiguration?deleted=true]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/foa7jlfvjrc4f4lotuc8rk55da/subscriptions]
- response received - statusCode:200, statusMessage:OK, correlationId:8fafd6fe-bf93-40ee-ade8-0d672552bbdf -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/foa7jlfvjrc4f4lotuc8rk55da/subscriptions]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=4&flowType=inboundcall]
- response received - statusCode:202, statusMessage:Accepted, correlationId:242c2edd-346a-45eb-a814-29dc65c8e75f -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=4&flowType=inboundcall]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/4/validate/cc8ba2c6-1b2a-40ff-bacd-ab319c6f1e0e]
- response received - statusCode:200, statusMessage:OK, correlationId:8ee82930-7af7-437b-9da9-3805942bd1d5 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/4/validate/cc8ba2c6-1b2a-40ff-bacd-ab319c6f1e0e]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows]
- find 'flow name' by property value where 'name' = 'TEST 2 QUEUE FLOW MEETING1' -- [ArchNetworkValueRetrieval]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=TEST%202%20QUEUE%20FLOW%20MEETING1]
- saveAsync - saving flow... -- [Name:'Test3', Type:'ArchFlowInboundCall', Id:'4']
- iteration 0: Waiting for 2 async operation(s) to complete... -- [ArchAsyncTracker]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function execution complete. -- [ArchFactoryFlows]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function returned a promise. Waiting until it resolves. -- [ArchFactoryFlows]
- response received - statusCode:200, statusMessage:OK, correlationId:48eaa093-aeb8-4eb8-a994-b2a25f026be6 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=TEST%202%20QUEUE%20FLOW%20MEETING1]
- async processing for getFlowInfoByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows]
- setting the in-queue flow 'TEST 2 QUEUE FLOW MEETING1' to be used for the in-queue handling of the call. -- [TrackingID:15, Name:'Transfer to ACD', Type:'ArchActionTransferToAcd']
- async processing for getFlowInfoByFlowNameAsync complete. Callback function execution complete. -- [ArchFactoryFlows]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/4/versions]
- response received - statusCode:200, statusMessage:OK, correlationId:775a7842-0f5c-4046-b53d-2636b2dd80e6 -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/4/versions]
- saveAsync - save successful. -- [Name:'Test3', Type:'ArchFlowInboundCall', Id:'4']
- flow url: https://apps.mypurecloud.com/architect/#/inboundcall/flows/4/latest/menu/test -- [Name:'Test3', Type:'ArchFlowInboundCall', Id:'4']
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function returned promise successfully resolved. -- [ArchFactoryFlows]
- session startup initialization for startWithClientIdAndSecret complete. Callback function returned promise successfully resolved. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'H1HCcter4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- setting session status to 'ended'. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'H1HCcter4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- ending with exit code: 0 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'H1HCcter4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- session is configured to terminate the process when ending. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'H1HCcter4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- now exiting the process with exit code: 0 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'H1HCcter4', OrgName:'Adobe', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
Rahul_Sadana | 2019-02-12 18:36:29 UTC | #19
3.Logs for "Test3" script running with errors
c:\code\PureClou-automation1>node updateInqueuCallflow.js Architect Scripting running under Node version '8.9.3' ArchSessionId:S1W8AKgr4
- setting session status to 'running'. -- [ArchSession, ArchSessionId:'S1W8AKgr4']
navigator unavailable - setting operating system to unknown
- architect scripting version: 0.2.1 -- [ArchSession, ArchSessionId:'S1W8AKgr4']
- core environment configuration. env: 'prod', host: 'apps.mypurecloud.com', region: 'us-east-1', clientId: '', clientSecret: '-' -- [ArchSession, ArchSessionId:'S1W8AKgr4']
- getting discovery properties... -- [ArchSession, ArchSessionId:'S1W8AKgr4']
- calling url -- [GET::https://apps.mypurecloud.com/services/discovery.properties]
App listening on port 8080
- response received - statusCode:200, statusMessage:OK, correlationId:undefined -- [GET::https://apps.mypurecloud.com/services/discovery.properties]
- core environment discovery properties loaded. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'S1W8AKgr4']
- core environment initialized. Now logging in... -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'S1W8AKgr4']
- calling url -- [POST::https://login.mypurecloud.com/token]
- response received - statusCode:200, statusMessage:OK, correlationId:test[POST::https://login.mypurecloud.com/token]
- setting auth token 'cmI77o7O1VlG9pgZsRyGYmhlOzvJGVpYP4n1MlHenxZWP_vW2gDRkTBS--09RBLiTm0chaBOY-8ilXYptJYJ0w' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'S1W8AKgr4']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization]
- response received - statusCode:200, statusMessage:OK, correlationId:9b25029b-cb7c-4479-b3aa-82f05edc7f7b -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization]
- authenticated name: 'test test' , id: '8fbdfc5c-801f-4d6c-b259-2b44acac14f4' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'S1W8AKgr4']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000]
- obtaining organization information -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'S1W8AKgr4']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me]
- response received - statusCode:200, statusMessage:OK, correlationId:b772e4c2-46dc-4680-9450-c5ec3a648690 -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000]
- response received - statusCode:200, statusMessage:OK, correlationId:cd23d6a1-45ab-4d9c-9149-85488c74fbac -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me]
- obtained organization information. organization name: 'Adobe', id: 'test' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'S1W8AKgr4', OrgName:'Adobe', OrgId:'test']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeVoicemailTransferFailureHandling&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=InboundMessagingWhatsApp&feature=workflowClient&feature=workflowMessagingLex&feature=authorization.division.management&feature=authorization.division.management.outbound.lists]
- response received - statusCode:200, statusMessage:OK, correlationId:a1d35764-06b9-4f7a-9878-a7910a843beb -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeVoicemailTransferFailureHandling&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=InboundMessagingWhatsApp&feature=workflowClient&feature=workflowMessagingLex&feature=authorization.division.management&feature=authorization.division.management.outbound.lists]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes]
- response received - statusCode:200, statusMessage:OK, correlationId:7cfc8589-6d1d-4e9b-8892-ec5b96ec26cc -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels]
- response received - statusCode:200, statusMessage:OK, correlationId:bb8108ef-8a58-48ff-baf8-3c5a7faff074 -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes]
- ArchFactoryFlows startup initialization - begin. -- [ArchFactoryFlows]
- ArchFactoryFlows startup initialization - end. -- [ArchFactoryFlows]
- session startup initialization for startWithClientIdAndSecret complete. Calling callback function. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'S1W8AKgr4', OrgName:'Adobe', OrgId:'test']
- find 'flow name' by property value where 'name' = 'Test3' -- [ArchNetworkValueRetrieval]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=Test3]
- session startup initialization for startWithClientIdAndSecret complete. Callback function execution complete. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'S1W8AKgr4', OrgName:'Adobe', OrgId:'test']
- session startup initialization for startWithClientIdAndSecret complete. Callback function returned a promise. Waiting until it resolves. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'S1W8AKgr4', OrgName:'Adobe', OrgId:'test']
- response received - statusCode:200, statusMessage:OK, correlationId:ab011a19-3a46-497e-8729-4f425a7ca3f8 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=Test3]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/b8272325-a37e-4f04-9f3c-4cc5ae3ff6b5/latestConfiguration?deleted=true]
- response received - statusCode:200, statusMessage:OK, correlationId:d3fd0d5a-0b55-4aa0-8a98-b0f163146d80 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/b8272325-a37e-4f04-9f3c-4cc5ae3ff6b5/latestConfiguration?deleted=true]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/6r4c6ikbvprcotkqpq0k66ghdu/subscriptions]
- response received - statusCode:200, statusMessage:OK, correlationId:b7f9edd3-5524-49d3-acc2-8bfbd2cf6e86 -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/6r4c6ikbvprcotkqpq0k66ghdu/subscriptions]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=b8272325-a37e-4f04-9f3c-4cc5ae3ff6b5&flowType=inboundcall]
- response received - statusCode:202, statusMessage:Accepted, correlationId:0b0e5717-7f08-45ac-9894-9387ba4fdf98 -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=b8272325-a37e-4f04-9f3c-4cc5ae3ff6b5&flowType=inboundcall]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/b8272325-a37e-4f04-9f3c-4cc5ae3ff6b5/validate/fd560d83-0fad-4fef-ae5f-c0a2b7553a9e]
- response received - statusCode:200, statusMessage:OK, correlationId:01436315-1471-4112-bb6c-014edc2504cd -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/b8272325-a37e-4f04-9f3c-4cc5ae3ff6b5/validate/fd560d83-0fad-4fef-ae5f-c0a2b7553a9e]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows]
- find 'flow name' by property value where 'name' = 'TEST 2 QUEUE FLOW MEETING1' -- [ArchNetworkValueRetrieval]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=TEST%202%20QUEUE%20FLOW%20MEETING1]
- saveAsync - saving flow... -- [Name:'Test3', Type:'ArchFlowInboundCall', Id:'b8272325-a37e-4f04-9f3c-4cc5ae3ff6b5']
- iteration 0: Waiting for 2 async operation(s) to complete... -- [ArchAsyncTracker]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function execution complete. -- [ArchFactoryFlows]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function returned a promise. Waiting until it resolves. -- [ArchFactoryFlows]
- response received - statusCode:200, statusMessage:OK, correlationId:e798aa21-41f4-4b5e-a4c6-7f7d1098ef29 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=TEST%202%20QUEUE%20FLOW%20MEETING1]
- async processing for getFlowInfoByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows]
- ERROR! ArchFactoryFlows.getFlowInfoByFlowNameAsync - Caught unhandled exception during callback function execution. Ending session. Exception info: TypeError: Cannot read property 'toLowerCase' of undefined -- [ArchFactoryFlows]
- ERROR! ending the Session. Setting the exit code to 99. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'S1W8AKgr4', OrgName:'Adobe', OrgId:'test']
- setting session status to 'ended'. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'S1W8AKgr4', OrgName:'Adobe', OrgId:'test']
- ending with exit code: 99 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'S1W8AKgr4', OrgName:'Adobe', OrgId:'test']
- session is configured to terminate the process when ending. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'S1W8AKgr4', OrgName:'Adobe', OrgId:'test']
- now exiting the process with exit code: 99 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'S1W8AKgr4', OrgName:'Adobe', OrgId:'test']
Eric_Spence | 2019-02-12 18:58:18 UTC | #20
Hi @Rahul_Sadana,
Looking at the logs it appears the problem maybe in the callback you are supplying for `getFlowInfoByFlowNameAsync`. Would you mind posting that snippet so that I can look into and make sure that the sdk is passing the data back properly.
Rahul_Sadana | 2019-02-12 19:05:10 UTC | #21
return scriptingFlowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName, scriptingEnums.FLOWTYPES.inboundCall, true, 'latest' , function (archInboundCallFlow) { scriptingFlowFactory.getFlowInfoByFlowNameAsync('TEST 2 QUEUE FLOW MEETING1',scriptingEnums.FLOWTYPES.inqueueCall, function (archInQueueFlowInfo) {
let archTransferAction; // Iterate through all reusable menus until we find the action for (let i = 0; i < archInboundCallFlow.menusReusable.length; i++) { console.log() archTransferAction = findFirst(archInboundCallFlow.menusReusable[i], 'Transfer to ACD'); // Currently this only searches an single reusable task. // If we found the transfer to acd action let's go ahead and set the inQueueHandlingFlowInfo. if (archTransferAction && archTransferAction.isArchMenuTransferToAcd) { archTransferAction.actionTransferToAcd.inQueueHandlingFlowInfo = archInQueueFlowInfo; break; } else if (archTransferAction && archTransferAction.isArchActionTransferToAcd) { archTransferAction.inQueueHandlingFlowInfo = archInQueueFlowInfo; break; } } }); // Here you can either saveAsync or publishAsync
return archInboundCallFlow.saveAsync(true); }); }
scriptingSession.startWithClientIdAndSecret(location, scriptMain, clientId, clientSecret); app.listen(8080); console.log("App listening on port 8080");
Eric_Spence | 2019-02-12 21:10:24 UTC | #22
Hi @Rahul_Sadana, I have taken a look into this issue and found a bug on our end and am looking into it. I did find a work around for the issue.
function scriptMain() { let archInQueueInfo; // Other workaround. Swap the order of these two calls. // There is an issue if checkoutAndLoadFlowByFlowNameAsync is called // before getFlowInfoByFlowNameAsync. Note we are working // to resolve this issue flowFactory.getFlowInfoByFlowNameAsync('TEST 2 QUEUE FLOW MEETING1',enums.FLOWTYPES.inqueueCall, function (archInQueueFlowInfo) { archInQueueInfo = archInQueueFlowInfo; flowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName, enums.FLOWTYPES.inboundCall, true, 'latest' , function (archInboundCallFlow) { let archTransferAction; // Iterate through all reusable menus until we find the action for (let i = 0; i < archInboundCallFlow.menusReusable.length; i++) { archTransferAction = findFirst(archInboundCallFlow.menusReusable[i], 'Transfer to ACD'); // Currently this only searches an single reusable task. // If we found the transfer to acd action let's go ahead and set the inQueueHandlingFlowInfo. if (archTransferAction && archTransferAction.isArchMenuTransferToAcd) { archTransferAction.actionTransferToAcd.inQueueHandlingFlowInfo = archInQueueInfo; break; } else if (archTransferAction && archTransferAction.isArchActionTransferToAcd) { archTransferAction.inQueueHandlingFlowInfo = archInQueueInfo; break; } } return archInboundCallFlow.saveAsync(true); }); }); // This is the workaround and won't be needed in upcoming releases return archAsyncTracker.allSettled(); }
Rahul_Sadana | 2019-02-14 23:59:43 UTC | #23
Hi Eric
Post changes script is not giving the type error , but its not able to update "InqueueCallFlow" tried multiple times on different inbound call flow architect scripts
My current script version post the changes recommeded by you is :
// -------------------------------------------------------------------------------- // Require in the PureCloud Architect Scripting SDK // -------------------------------------------------------------------------------- const architectScripting = require('purecloud-flow-scripting-api-sdk-javascript'); const express = require('express'); const app = express() // -------------------------------------------------------------------------------- // See above in the readme for information on creating a client id / secret. // We will use these when starting the Architect Scripting session below. // Remember, the Architect Scripting session object also has a way to start // with you supplying an auth token too. // -------------------------------------------------------------------------------- const clientId = 'e6add382-313a-4ffb-aa57-f815e6b4d640'; const clientSecret = '-dCzPOg1jeMOqJne9UNCyuBxHTDfq3EjUCSemuyNULo';
// -------------------------------------------------------------------------------- // Flow name and description constants for the flow that will be created. // --------------------------------------------------------------------------------
// -------------------------------------------------------------------------------- // Helpers to make sample code more readable below. // -------------------------------------------------------------------------------- const scriptingActionFactory = architectScripting.factories.archFactoryActions; // Factory to create actions const scriptingEnums = architectScripting.enums.archEnums; // Enum support const scriptingFlowFactory = architectScripting.factories.archFactoryFlows; // Factory to create flows const scriptingLanguages = architectScripting.languages.archLanguages; // Language support const scriptingSession = architectScripting.environment.archSession; // Session support const scriptingTaskFactory = architectScripting.factories.archFactoryTasks; // Factory to create tasks const scriptingLogger = architectScripting.services.archLogging; // Logging support const scriptingService = architectScripting.services.archAsyncTracker; // Track Promises
//scriptingEnums.FLOW_TYPES.inqueueCall // -------------------------------------------------------------------------------- // Enables additional logging during execution. It definitely helps when // debugging your code so we want to show how to enable it in this example. // -------------------------------------------------------------------------------- scriptingLogger.logNotesVerbose = true;
// -------------------------------------------------------------------------------- // Set up a constant for the organization's location. // -------------------------------------------------------------------------------- const location = scriptingEnums.LOCATIONS.produseast_1;
function scriptMain() {
const flowName = 'Test 2'; /**
- Recursively search an action container for an action by its name.
- @param archContainer - the action container to search such as a task or state
- @param nameToFind - the name of the action to find
- @return {ArchBaseAction}
*/ const findFirstInContainer = (archContainer, nameToFind) => { let currentArchBaseAction, foundArchBaseAction; for (let i = 0; i < archContainer.actions.length; i++) { currentArchBaseAction = archContainer.actions[i]; if (currentArchBaseAction.name === nameToFind) { return currentArchBaseAction; } // If the action has outputs search through all those outputs if (currentArchBaseAction.isArchBaseActionWithOutputs) { for (let outputIndex = 0; outputIndex < currentArchBaseAction.outputCount; outputIndex++) { foundArchBaseAction = findFirstInContainer(currentArchBaseAction.getOutputByIndex(outputIndex), nameToFind); if (foundArchBaseAction) { return foundArchBaseAction; } } } } return void 0; };
/**
- Recursively search nested menu choices for
- the first menu choice by name
- @param archMenu - the parent menu
- @param nameToFind - the name of the action to find
- @return {*}
*/ const findFirst = (archMenu, nameToFind) => { let currentArchChildMenu, foundArchTargetAction; for (let i = 0; i < archMenu.childMenus.length; i++) { currentArchChildMenu = archMenu.childMenus[i]; if (currentArchChildMenu.childMenus) { foundArchTargetAction = findFirst(currentArchChildMenu, nameToFind); } if (currentArchChildMenu.actionTask) { foundArchTargetAction = findFirstInContainer(currentArchChildMenu.actionTask.task, nameToFind); } if (foundArchTargetAction) { return foundArchTargetAction; } if (currentArchChildMenu.name === nameToFind) { return currentArchChildMenu; } } return void 0; };
let archInQueueInfo; // Other workaround. Swap the order of these two calls. // There is an issue if checkoutAndLoadFlowByFlowNameAsync is called // before getFlowInfoByFlowNameAsync. Note we are working // to resolve this issue scriptingFlowFactory.getFlowInfoByFlowNameAsync('INDIA ERC QUEUE',scriptingEnums.FLOWTYPES.inqueueCall, function (archInQueueFlowInfo) { archInQueueInfo = archInQueueFlowInfo; scriptingFlowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName, scriptingEnums.FLOWTYPES.inboundCall, true, 'latest' , function (archInboundCallFlow) { let archTransferAction; // Iterate through all reusable menus until we find the action for (let i = 0; i < archInboundCallFlow.menusReusable.length; i++) { archTransferAction = findFirst(archInboundCallFlow.menusReusable[i], 'Transfer to ACD'); // Currently this only searches an single reusable task. // If we found the transfer to acd action let's go ahead and set the inQueueHandlingFlowInfo. if (archTransferAction && archTransferAction.isArchMenuTransferToAcd) { archTransferAction.actionTransferToAcd.inQueueHandlingFlowInfo = archInQueueInfo; break; } else if (archTransferAction && archTransferAction.isArchActionTransferToAcd) { archTransferAction.inQueueHandlingFlowInfo = archInQueueInfo; break; } } return archInboundCallFlow.saveAsync(true); }); }); // This is the workaround and won't be needed in upcoming releases return scriptingService.allSettled();
}
scriptingSession.startWithClientIdAndSecret(location, scriptMain, clientId, clientSecret); app.listen(8080); console.log("App listening on port 8080");
Logs for one of the script instance executed where there is no type error but the "InqueueCallflow" does not get updated in spite of the fact the logs shows that mentioned below "setting the in-queue flow 'INDIA ERC QUEUE' to be used for the in-queue handling of the call"
Architect Scripting running under Node version '8.9.3' ArchSessionId:test
- setting session status to 'running'. -- [ArchSession, ArchSessionId:'test']
navigator unavailable - setting operating system to unknown
- architect scripting version: 0.2.1 -- [ArchSession, ArchSessionId:'test']
- core environment configuration. env: 'prod', host: 'apps.mypurecloud.com', region: 'us-east-1', clientId: '', clientSecret: '' -- [ArchSession, ArchSessionId:'test']
- getting discovery properties... -- [ArchSession, ArchSessionId:'test']
- calling url -- [GET::https://apps.mypurecloud.com/services/discovery.properties]
App listening on port 8080
- response received - statusCode:200, statusMessage:OK, correlationId:undefined -- [GET::https://apps.mypurecloud.com/services/discovery.properties]
- core environment discovery properties loaded. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test']
- core environment initialized. Now logging in... -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test']
- calling url -- [POST::https://login.mypurecloud.com/token]
- response received - statusCode:200, statusMessage:OK, correlationId:ea38b8b4-6b71-4cea-4a2c-66b03e49cf9e -- [POST::https://login.mypurecloud.com/token]
- setting auth token 'T0Jjt-sPtIfIDm761dOtUWkZHakzvAbyIxKmIlp4MAYKuRRUss3jAdeO1jvOSuTYFqdEhhcL6B14RdYePtLg' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization]
- response received - statusCode:200, statusMessage:OK, correlationId:839a61a0-cef9-4a7c-8bf4-fda28d3c0ce0 -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization]
- authenticated name: 'Rahul Sadhana' , id: '8fbdfc5c-801f-4d6c-b259-2b44acac14f4' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000]
- obtaining organization information -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me]
- response received - statusCode:200, statusMessage:OK, correlationId:9afaa6c8-c552-44c3-aa96-041f37c6b1db -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000]
- response received - statusCode:200, statusMessage:OK, correlationId:a645633d-e2fe-4a01-8ec8-33f2346cc455 -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me]
- obtained organization information. organization name: 'test', id: '4214e8bd-987b-45f9-b865-62d8c47c0d55' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test', OrgName:'test', OrgId:'']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeVoicemailTransferFailureHandling&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=InboundMessagingWhatsApp&feature=workflowClient&feature=workflowMessagingLex&feature=authorization.division.management&feature=authorization.division.management.outbound.lists]
- response received - statusCode:200, statusMessage:OK, correlationId:6e64f469-3fa7-418a-8b49-3781415f3dd1 -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeVoicemailTransferFailureHandling&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=InboundMessagingWhatsApp&feature=workflowClient&feature=workflowMessagingLex&feature=authorization.division.management&feature=authorization.division.management.outbound.lists]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes]
- response received - statusCode:200, statusMessage:OK, correlationId:8e6d5d50-2708-4637-88fe-216aa6a5756f -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels]
- response received - statusCode:200, statusMessage:OK, correlationId:3c127bdb-b8cf-44d6-8be8-4557376ab2de -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes]
- ArchFactoryFlows startup initialization - begin. -- [ArchFactoryFlows]
- ArchFactoryFlows startup initialization - end. -- [ArchFactoryFlows]
- session startup initialization for startWithClientIdAndSecret complete. Calling callback function. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test', OrgName:'test', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- find 'flow name' by property value where 'name' = 'INDIA ERC QUEUE' -- [ArchNetworkValueRetrieval]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=INDIA%20ERC%20QUEUE]
- iteration 0: Waiting for 1 async operation(s) to complete... -- [ArchAsyncTracker]
- session startup initialization for startWithClientIdAndSecret complete. Callback function execution complete. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test', OrgName:'test', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- session startup initialization for startWithClientIdAndSecret complete. Callback function returned a promise. Waiting until it resolves. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test', OrgName:'test', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- response received - statusCode:200, statusMessage:OK, correlationId:50bd7950-28ea-426b-b4d9-f69aba46dc32 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=INDIA%20ERC%20QUEUE]
- async processing for getFlowInfoByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows]
- find 'flow name' by property value where 'name' = 'Test 2' -- [ArchNetworkValueRetrieval]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=Test%202]
- async processing for getFlowInfoByFlowNameAsync complete. Callback function execution complete. -- [ArchFactoryFlows]- need to wait for more async operations(s) to complete... -- [ArchAsyncTracker]
- iteration 1: Waiting for 1 async operation(s) to complete... -- [ArchAsyncTracker]
- response received - statusCode:200, statusMessage:OK, correlationId:905d4fa1-4316-4aab-ad3a-72697091a61b -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=Test%202]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/latestConfiguration?deleted=true]
- need to wait for more async operations(s) to complete... -- [ArchAsyncTracker]
- iteration 2: Waiting for 2 async operation(s) to complete... -- [ArchAsyncTracker]
- response received - statusCode:200, statusMessage:OK, correlationId:468582a0-2799-48f3-8072-b5756bb1ab92 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/latestConfiguration?deleted=true]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/qn1kmevhra1lbnq536mdpslkg7/subscriptions]
- response received - statusCode:200, statusMessage:OK, correlationId:858b5494-5500-4a08-91ce-ca9baf91f615 -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/qn1kmevhra1lbnq536mdpslkg7/subscriptions]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=c0ae152c-8f95-4213-a4f1-1228a9e53187&flowType=inboundcall]
- response received - statusCode:202, statusMessage:Accepted, correlationId:04157668-f2bb-4d7a-a27c-b903f8df535c -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=c0ae152c-8f95-4213-a4f1-1228a9e53187&flowType=inboundcall]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/validate/a1e3dfac-01c3-4aa8-a9a6-031216cc8365]
- response received - statusCode:200, statusMessage:OK, correlationId:82a2d534-000c-4132-8ff2-7f6a9a7a003a -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/validate/a1e3dfac-01c3-4aa8-a9a6-031216cc8365]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows]
- setting the in-queue flow 'INDIA ERC QUEUE' to be used for the in-queue handling of the call. -- [TrackingID:33, Name:'Transfer to ACD', Type:'ArchActionTransferToAcd']
- saveAsync - saving flow... -- [Name:'TEST 2', Type:'ArchFlowInboundCall', Id:'c0ae152c-8f95-4213-a4f1-1228a9e53187']
- iteration 0: Waiting for 1 async operation(s) to complete... -- [ArchAsyncTracker]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function execution complete. -- [ArchFactoryFlows]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function returned a promise. Waiting until it resolves. -- [ArchFactoryFlows]
- session startup initialization for startWithClientIdAndSecret complete. Callback function returned promise successfully resolved. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test', OrgName:'test', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/versions]
- setting session status to 'ended'. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test', OrgName:'test', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- ending with exit code: 0 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test', OrgName:'test', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- session is configured to terminate the process when ending. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test', OrgName:'test', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
- now exiting the process with exit code: 0 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'test', OrgName:'test', OrgId:'4214e8bd-987b-45f9-b865-62d8c47c0d55']
Eric_Spence | 2019-02-15 16:49:03 UTC | #24
Hi @Rahul_Sadana, I will look into this some more. I did notice that you accidentally posted your clientId and secret. I would advise swapping to a new oauth client.
Rahul_Sadana | 2019-02-15 03:58:48 UTC | #25
Thanks Eric!. Noticed that before have already deleted oath client .
Eric_Spence | 2019-02-15 04:42:38 UTC | #26
Hi @Rahul_Sadana, So I messed around with that script for a little bit and tweaked the work-around in order to get you up and running. Note this will be a temp measure and we will be working on removing the need for this.
function scriptMain() {
const flowName = 'new';
// WORKAROUND: add a temp holder for the checked out flow
let archInQueueInfo, archInboundCallFlowHolder;
flowFactory.getFlowInfoByFlowNameAsync('InqueueTarget',enums.FLOW_TYPES.inqueueCall, function (archInQueueFlowInfo) {
archInQueueInfo = archInQueueFlowInfo;
flowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName, enums.FLOW_TYPES.inboundCall, true, 'latest' , function (archInboundCallFlow) {
archInboundCallFlowHolder = archInboundCallFlow;
let archTransferAction;
// Iterate through all reusable menus until we find the action
for (let i = 0; i < archInboundCallFlow.menusReusable.length; i++) {
archTransferAction = findFirst(archInboundCallFlow.menusReusable[i], 'Transfer to ACD');
// Currently this only searches an single reusable task.
// If we found the transfer to acd action let's go ahead and set the inQueueHandlingFlowInfo.
if (archTransferAction && archTransferAction.isArchMenuTransferToAcd) {
archTransferAction.actionTransferToAcd.inQueueHandlingFlowInfo = archInQueueInfo;
break;
} else if (archTransferAction && archTransferAction.isArchActionTransferToAcd) {
archTransferAction.inQueueHandlingFlowInfo = archInQueueInfo;
break;
}
}
// Workaround: assign flow to tmp variable
archInboundCallFlowHolder = archInboundCallFlow;
});
});
// This is the workaround and won't be needed in upcoming releases
// WORKAROUND: Move the save call to this allSettled() promise.
return archAsyncTracker.allSettled().then(()=>
archInboundCallFlowHolder.saveAsync(true));
}
Eric_Spence | 2019-02-15 14:09:26 UTC | #27
We have identified the issue in our async processing for save and should have a fix released soon for it.
Eric_Spence | 2019-02-15 16:48:32 UTC | #28
Hi @Rahul_Sadana, I just wanted to shoot you an update that we have released build 0.2.3 of purecloud-flow-scripting-api-sdk-javascript which will render those work arounds no longer necessary. The only workaround you will need to keep is the changed ordering. That issue requires a service side work and should deployed in the upcoming days.
Here is an example of code that I got working locally. As usually if anything else comes up please let me know.
Thanks, Eric Spence
function scriptMain() {
const flowName = 'new';
let archInQueueInfo;
return flowFactory.getFlowInfoByFlowNameAsync('InqueueTarget',enums.FLOW_TYPES.inqueueCall, function (archInQueueFlowInfo) {
archInQueueInfo = archInQueueFlowInfo;
return flowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName, enums.FLOW_TYPES.inboundCall, true, 'latest' , function (archInboundCallFlow) {
let archTransferAction;
// Iterate through all reusable menus until we find the action
for (let i = 0; i < archInboundCallFlow.menusReusable.length; i++) {
archTransferAction = findFirst(archInboundCallFlow.menusReusable[i], 'Transfer to ACD');
// Currently this only searches an single reusable task.
// If we found the transfer to acd action let's go ahead and set the inQueueHandlingFlowInfo.
if (archTransferAction && archTransferAction.isArchMenuTransferToAcd) {
archTransferAction.actionTransferToAcd.inQueueHandlingFlowInfo = archInQueueInfo;
break;
} else if (archTransferAction && archTransferAction.isArchActionTransferToAcd) {
archTransferAction.inQueueHandlingFlowInfo = archInQueueInfo;
break;
}
}
return archInboundCallFlow.saveAsync();
});
});
}
Rahul_Sadana | 2019-02-21 08:43:53 UTC | #29
Hi Eric
Tried running this and is executing fine with no errors, however it is not updating the Inqueue call flow , have tried it multiple times to ensure I am no missing any thing here.
Sharing the logs and my current script
Logs
Architect Scripting running under Node version '8.9.3' ArchSessionId:rJaBJk3HE
- setting session status to 'running'. -- [ArchSession, ArchSessionId:'rJaBJk3HE']
navigator unavailable - setting operating system to unknown
- architect scripting version: 0.2.3 -- [ArchSession, ArchSessionId:'rJaBJk3HE']
- core environment configuration. env: 'prod', host: 'apps.mypurecloud.com', region: 'us-east-1', clientId: 'c', clientSecret: '' -- [ArchSession, ArchSessionId:'rJaBJk3HE']
- getting discovery properties... -- [ArchSession, ArchSessionId:'rJaBJk3HE']
- calling url -- [GET::https://apps.mypurecloud.com/services/discovery.properties]
App listening on port 8080
- response received - statusCode:200, statusMessage:OK, correlationId:undefined -- [GET::https://apps.mypurecloud.com/services/discovery.properties]
- core environment discovery properties loaded. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE']
- core environment initialized. Now logging in... -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE']
- calling url -- [POST::https://login.mypurecloud.com/token]
- response received - statusCode:200, statusMessage:OK, correlationId:a0b8582a-10af-4320-5118-28d6215aa4e9 -- [POST::https://login.mypurecloud.com/token]
- setting auth token 'MeUkHVEBnb4UWQxNt3TuIRU01RVd0T4WlWx1u0w51chfrnv4DgjRBfU95gMfWFVJePa_sKr-ZfNN4ikQSy1g' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization]
- response received - statusCode:200, statusMessage:OK, correlationId:974d3bca-08fa-4d5e-9419-93b3cd7638ed -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization]
- authenticated name: 'Rahul Sadhana' , id: '8fbdfc5c-801f-4d6c-b259-2b44acac14f4' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000]
- obtaining organization information -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me]
- response received - statusCode:200, statusMessage:OK, correlationId:facacea3-f8db-405a-9abb-f3411bb7a29f -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me]
- obtained organization information. organization name: '', id: '55' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE', OrgName:'Adobe', OrgId:'sds']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeVoicemailTransferFailureHandling&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=InboundMessagingWhatsApp&feature=workflowClient&feature=authorization.division.management&feature=authorization.division.management.outbound.lists]
- response received - statusCode:200, statusMessage:OK, correlationId:ade7b454-d0a9-4b2b-adce-339ff3a14541 -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000]
- response received - statusCode:200, statusMessage:OK, correlationId:973a8fc6-5934-439b-930a-f481212ae6ad -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeVoicemailTransferFailureHandling&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=InboundMessagingWhatsApp&feature=workflowClient&feature=authorization.division.management&feature=authorization.division.management.outbound.lists]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes]
- response received - statusCode:200, statusMessage:OK, correlationId:e6a362d3-7a8d-4f24-8070-8bb8d600c65b -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels]
- response received - statusCode:200, statusMessage:OK, correlationId:0b1136a9-a2af-4efd-a9b0-7a959e6760d1 -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes]
- ArchFactoryFlows startup initialization - begin. -- [ArchFactoryFlows]
- ArchFactoryFlows startup initialization - end. -- [ArchFactoryFlows]
- session startup initialization for startWithClientIdAndSecret complete. Calling callback function. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE', OrgName:'Adobe', OrgId:'sds']
- find 'flow name' by property value where 'name' = 'TEST 2 QUEUE FLOW MEETING' -- [ArchNetworkValueRetrieval]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=TEST%202%20QUEUE%20FLOW%20MEETING]
- session startup initialization for startWithClientIdAndSecret complete. Callback function execution complete. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE', OrgName:'Adobe', OrgId:'sds']
- session startup initialization for startWithClientIdAndSecret complete. Callback function returned a promise. Waiting until it resolves. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE', OrgName:'Adobe', OrgId:'sds']
- response received - statusCode:200, statusMessage:OK, correlationId:5cadedbd-0674-4b53-8d69-34ca037016b4 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=TEST%202%20QUEUE%20FLOW%20MEETING]
- async processing for getFlowInfoByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows]
- find 'flow name' by property value where 'name' = 'Test 2' -- [ArchNetworkValueRetrieval]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=Test%202]
- async processing for getFlowInfoByFlowNameAsync complete. Callback function execution complete. -- [ArchFactoryFlows]- async processing for getFlowInfoByFlowNameAsync complete. Callback function returned a promise. Waiting until it resolves. -- [ArchFactoryFlows]
- response received - statusCode:200, statusMessage:OK, correlationId:4dd7558e-621f-4956-8ddb-dcbf06eccd81 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=Test%202]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/checkOut?flow=c0ae152c-8f95-4213-a4f1-1228a9e53187]
- response received - statusCode:200, statusMessage:OK, correlationId:53f9b4ce-5900-4ad2-b407-d43d51083e11 -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/checkOut?flow=c0ae152c-8f95-4213-a4f1-1228a9e53187]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/latestConfiguration?deleted=true]
- response received - statusCode:200, statusMessage:OK, correlationId:26e5dce7-46ec-48fa-8a1d-a7c73247e886 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/latestConfiguration?deleted=true]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/n3d9mv48vrrhvpevac51n8ed3b/subscriptions]
- response received - statusCode:200, statusMessage:OK, correlationId:d38f8e29-42d9-4c73-8b0b-b9c652df9f49 -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/n3d9mv48vrrhvpevac51n8ed3b/subscriptions]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=c0ae152c-8f95-4213-a4f1-1228a9e53187&flowType=inboundcall]
- response received - statusCode:202, statusMessage:Accepted, correlationId:1914af3e-8d8b-476c-8c8b-94deefc35656 -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=c0ae152c-8f95-4213-a4f1-1228a9e53187&flowType=inboundcall]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/validate/e4b72af6-4785-494c-865c-58ec8ae5a864]
- response received - statusCode:200, statusMessage:OK, correlationId:5155c26d-f834-477f-9c32-a623ec885ef6 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/validate/e4b72af6-4785-494c-865c-58ec8ae5a864]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows]
- setting the in-queue flow 'TEST 2 QUEUE FLOW MEETING' to be used for the in-queue handling of the call. -- [TrackingID:33, Name:'Transfer to ACD', Type:'ArchActionTransferToAcd']
- saveAsync - saving flow... -- [Name:'TEST 2', Type:'ArchFlowInboundCall', Id:'c0ae152c-8f95-4213-a4f1-1228a9e53187']
- iteration 0: Waiting for 1 async operation(s) to complete... -- [ArchAsyncTracker]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function execution complete. -- [ArchFactoryFlows]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function returned a promise. Waiting until it resolves. -- [ArchFactoryFlows]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/versions]
- response received - statusCode:200, statusMessage:OK, correlationId:c46f9948-c27d-4039-929f-fc3ae03335be -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/versions]
- saveAsync - save successful. -- [Name:'TEST 2', Type:'ArchFlowInboundCall', Id:'c0ae152c-8f95-4213-a4f1-1228a9e53187']- flow url: https://apps.mypurecloud.com/architect/#/inboundcall/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/latest/menu/1755b1de-fb94-4a8c-a186-34c463670087 -- [Name:'TEST 2', Type:'ArchFlowInboundCall', Id:'c0ae152c-8f95-4213-a4f1-1228a9e53187']
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function returned promise successfully resolved. -- [ArchFactoryFlows]
- async processing for getFlowInfoByFlowNameAsync complete. Callback function returned promise successfully resolved. -- [ArchFactoryFlows]
- session startup initialization for startWithClientIdAndSecret complete. Callback function returned promise successfully resolved. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE', OrgName:'Adobe', OrgId:'sds']
- waiting for any pending work to complete before ending the session -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE', OrgName:'Adobe', OrgId:'sds']
- setting session status to 'ended'. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE', OrgName:'Adobe', OrgId:'sds']
- waiting for any pending work to complete before ending the session -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE', OrgName:'Adobe', OrgId:'sds']
- ending with exit code: 0 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE', OrgName:'Adobe', OrgId:'sds']
- session is configured to terminate the process when ending. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE', OrgName:'Adobe', OrgId:'42']
- now exiting the process with exit code: 0 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'rJaBJk3HE', OrgName:'Adobe', OrgId:'sds']
Code // -------------------------------------------------------------------------------- // Require in the PureCloud Architect Scripting SDK // -------------------------------------------------------------------------------- const architectScripting = require('purecloud-flow-scripting-api-sdk-javascript'); const express = require('express'); const app = express() // -------------------------------------------------------------------------------- // See above in the readme for information on creating a client id / secret. // We will use these when starting the Architect Scripting session below. // Remember, the Architect Scripting session object also has a way to start // with you supplying an auth token too. // -------------------------------------------------------------------------------- const clientId = ''; const clientSecret = 'l;
// -------------------------------------------------------------------------------- // Flow name and description constants for the flow that will be created. // --------------------------------------------------------------------------------
// -------------------------------------------------------------------------------- // Helpers to make sample code more readable below. // -------------------------------------------------------------------------------- const scriptingActionFactory = architectScripting.factories.archFactoryActions; // Factory to create actions const scriptingEnums = architectScripting.enums.archEnums; // Enum support const scriptingFlowFactory = architectScripting.factories.archFactoryFlows; // Factory to create flows const scriptingLanguages = architectScripting.languages.archLanguages; // Language support const scriptingSession = architectScripting.environment.archSession; // Session support const scriptingTaskFactory = architectScripting.factories.archFactoryTasks; // Factory to create tasks const scriptingLogger = architectScripting.services.archLogging; // Logging support const scriptingService = architectScripting.services.archAsyncTracker; // Track Promises
//scriptingEnums.FLOW_TYPES.inqueueCall // -------------------------------------------------------------------------------- // Enables additional logging during execution. It definitely helps when // debugging your code so we want to show how to enable it in this example. // -------------------------------------------------------------------------------- scriptingLogger.logNotesVerbose = true;
// -------------------------------------------------------------------------------- // Set up a constant for the organization's location. // -------------------------------------------------------------------------------- const location = scriptingEnums.LOCATIONS.produseast_1;
function scriptMain() {
const flowName = 'Test 2'; /**
- Recursively search an action container for an action by its name.
- @param archContainer - the action container to search such as a task or state
- @param nameToFind - the name of the action to find
- @return {ArchBaseAction}
*/ const findFirstInContainer = (archContainer, nameToFind) => { let currentArchBaseAction, foundArchBaseAction; for (let i = 0; i < archContainer.actions.length; i++) { currentArchBaseAction = archContainer.actions[i]; if (currentArchBaseAction.name === nameToFind) { return currentArchBaseAction; } // If the action has outputs search through all those outputs if (currentArchBaseAction.isArchBaseActionWithOutputs) { for (let outputIndex = 0; outputIndex < currentArchBaseAction.outputCount; outputIndex++) { foundArchBaseAction = findFirstInContainer(currentArchBaseAction.getOutputByIndex(outputIndex), nameToFind); if (foundArchBaseAction) { return foundArchBaseAction; } } } } return void 0; };
/**
- Recursively search nested menu choices for
- the first menu choice by name
- @param archMenu - the parent menu
- @param nameToFind - the name of the action to find
- @return {*}
*/ const findFirst = (archMenu, nameToFind) => { let currentArchChildMenu, foundArchTargetAction; for (let i = 0; i < archMenu.childMenus.length; i++) { currentArchChildMenu = archMenu.childMenus[i]; if (currentArchChildMenu.childMenus) { foundArchTargetAction = findFirst(currentArchChildMenu, nameToFind); } if (currentArchChildMenu.actionTask) { foundArchTargetAction = findFirstInContainer(currentArchChildMenu.actionTask.task, nameToFind); } if (foundArchTargetAction) { return foundArchTargetAction; } if (currentArchChildMenu.name === nameToFind) { return currentArchChildMenu; } } return void 0; };
//let archInQueueInfo; // Other workaround. Swap the order of these two calls. // There is an issue if checkoutAndLoadFlowByFlowNameAsync is called // before getFlowInfoByFlowNameAsync. Note we are working // to resolve this issue let archInQueueInfo; return scriptingFlowFactory.getFlowInfoByFlowNameAsync('TEST 2 QUEUE FLOW MEETING',scriptingEnums.FLOWTYPES.inqueueCall, function (archInQueueFlowInfo) { archInQueueInfo = archInQueueFlowInfo; return scriptingFlowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName,scriptingEnums.FLOWTYPES.inboundCall, true, 'latest' , function (archInboundCallFlow) { let archTransferAction; // Iterate through all reusable menus until we find the action for (let i = 0; i < archInboundCallFlow.menusReusable.length; i++) { archTransferAction = findFirst(archInboundCallFlow.menusReusable[i], 'Transfer to ACD'); // Currently this only searches an single reusable task. // If we found the transfer to acd action let's go ahead and set the inQueueHandlingFlowInfo. if (archTransferAction && archTransferAction.isArchMenuTransferToAcd) { archTransferAction.actionTransferToAcd.inQueueHandlingFlowInfo = archInQueueInfo; break; } else if (archTransferAction && archTransferAction.isArchActionTransferToAcd) { archTransferAction.inQueueHandlingFlowInfo = archInQueueInfo; break; } } return archInboundCallFlow.saveAsync(); }); });
}
scriptingSession.startWithClientIdAndSecret(location, scriptMain, clientId, clientSecret); app.listen(8080); console.log("App listening on port 8080");
Eric_Spence | 2019-02-21 15:11:57 UTC | #30
Hi @Rahul_Sadana, I looked into your flow config and I see an action called `Transfer to ACD` with the Inqueue flow set to `TEST 2 QUEUE FLOW MEETING`. I also see logs that `TEST 2 QUEUE FLOW MEETING` was updated. Is it possible that it is updating an unexpected action? ` [TrackingID:33, Name:'Transfer to ACD', Type:'ArchActionTransferToAcd']` I would test changing the name of the action to a unique name.
Rahul_Sadana | 2019-03-06 16:18:26 UTC | #31
Hi Eric,
Missed the notification for your message, due to which there was a delay in responding , I tired to run this script on a different flow with a unique action to avoid any conflict ,script is running fine with no errors however the in queue flow is still not getting updated
Now the inbound queue flow is "NA6HELPMAIN_STAGE" inqueue call flow is "INDIA ERC QUEUE" ACD action is "ACTION11'
Current version of the script is
// -------------------------------------------------------------------------------- // Require in the PureCloud Architect Scripting SDK // -------------------------------------------------------------------------------- const architectScripting = require('purecloud-flow-scripting-api-sdk-javascript'); const express = require('express'); const app = express() // -------------------------------------------------------------------------------- // See above in the readme for information on creating a client id / secret. // We will use these when starting the Architect Scripting session below. // Remember, the Architect Scripting session object also has a way to start // with you supplying an auth token too. // -------------------------------------------------------------------------------- const clientId = ''; const clientSecret = '';
// -------------------------------------------------------------------------------- // Flow name and description constants for the flow that will be created. // --------------------------------------------------------------------------------
// -------------------------------------------------------------------------------- // Helpers to make sample code more readable below. // -------------------------------------------------------------------------------- const scriptingActionFactory = architectScripting.factories.archFactoryActions; // Factory to create actions const scriptingEnums = architectScripting.enums.archEnums; // Enum support const scriptingFlowFactory = architectScripting.factories.archFactoryFlows; // Factory to create flows const scriptingLanguages = architectScripting.languages.archLanguages; // Language support const scriptingSession = architectScripting.environment.archSession; // Session support const scriptingTaskFactory = architectScripting.factories.archFactoryTasks; // Factory to create tasks const scriptingLogger = architectScripting.services.archLogging; // Logging support const scriptingService = architectScripting.services.archAsyncTracker; // Track Promises
//scriptingEnums.FLOW_TYPES.inqueueCall // -------------------------------------------------------------------------------- // Enables additional logging during execution. It definitely helps when // debugging your code so we want to show how to enable it in this example. // -------------------------------------------------------------------------------- scriptingLogger.logNotesVerbose = true;
// -------------------------------------------------------------------------------- // Set up a constant for the organization's location. // -------------------------------------------------------------------------------- const location = scriptingEnums.LOCATIONS.produseast_1;
function scriptMain() {
const flowName = 'NA6HELPMAIN_STAGE'; /**
- Recursively search an action container for an action by its name.
- @param archContainer - the action container to search such as a task or state
- @param nameToFind - the name of the action to find
- @return {ArchBaseAction}
*/ const findFirstInContainer = (archContainer, nameToFind) => { let currentArchBaseAction, foundArchBaseAction; for (let i = 0; i < archContainer.actions.length; i++) { currentArchBaseAction = archContainer.actions[i]; if (currentArchBaseAction.name === nameToFind) { return currentArchBaseAction; } // If the action has outputs search through all those outputs if (currentArchBaseAction.isArchBaseActionWithOutputs) { for (let outputIndex = 0; outputIndex < currentArchBaseAction.outputCount; outputIndex++) { foundArchBaseAction = findFirstInContainer(currentArchBaseAction.getOutputByIndex(outputIndex), nameToFind); if (foundArchBaseAction) { return foundArchBaseAction; } } } } return void 0; };
/**
- Recursively search nested menu choices for
- the first menu choice by name
- @param archMenu - the parent menu
- @param nameToFind - the name of the action to find
- @return {*}
*/ const findFirst = (archMenu, nameToFind) => { let currentArchChildMenu, foundArchTargetAction; for (let i = 0; i < archMenu.childMenus.length; i++) { currentArchChildMenu = archMenu.childMenus[i]; if (currentArchChildMenu.childMenus) { foundArchTargetAction = findFirst(currentArchChildMenu, nameToFind); } if (currentArchChildMenu.actionTask) { foundArchTargetAction = findFirstInContainer(currentArchChildMenu.actionTask.task, nameToFind); } if (foundArchTargetAction) { return foundArchTargetAction; } if (currentArchChildMenu.name === nameToFind) { return currentArchChildMenu; } } return void 0; };
let archInQueueInfo; // Other workaround. Swap the order of these two calls. // There is an issue if checkoutAndLoadFlowByFlowNameAsync is called // before getFlowInfoByFlowNameAsync. Note we are working // to resolve this issue scriptingFlowFactory.getFlowInfoByFlowNameAsync('INDIA ERC QUEUE',scriptingEnums.FLOWTYPES.inqueueCall, function (archInQueueFlowInfo) { archInQueueInfo = archInQueueFlowInfo; scriptingFlowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName, scriptingEnums.FLOWTYPES.inboundCall, true, 'latest' , function (archInboundCallFlow) { let archTransferAction; // Iterate through all reusable menus until we find the action for (let i = 0; i < archInboundCallFlow.menusReusable.length; i++) { archTransferAction = findFirst(archInboundCallFlow.menusReusable[i], 'ACTION11'); // Currently this only searches an single reusable task. // If we found the transfer to acd action let's go ahead and set the inQueueHandlingFlowInfo. if (archTransferAction && archTransferAction.isArchMenuTransferToAcd) { archTransferAction.actionTransferToAcd.inQueueHandlingFlowInfo = archInQueueInfo; break; } else if (archTransferAction && archTransferAction.isArchActionTransferToAcd) { archTransferAction.inQueueHandlingFlowInfo = archInQueueInfo; break; } } return archInboundCallFlow.saveAsync(true); }); }); // This is the workaround and won't be needed in upcoming releases return scriptingService.allSettled();
}
scriptingSession.startWithClientIdAndSecret(location, scriptMain, clientId, clientSecret); app.listen(8080); console.log("App listening on port 8080");
Logs of the script
:\code\PureClou-automation1>node updateInqueuCallflowv1.js Architect Scripting running under Node version '8.9.3' ArchSessionId:BJ5YpDpLN
- setting session status to 'running'. -- [ArchSession, ArchSessionId:'BJ5YpDpLN']
navigator unavailable - setting operating system to unknown
- architect scripting version: 0.2.3 -- [ArchSession, ArchSessionId:'BJ5YpDpLN']
- core environment configuration. env: 'prod', host: 'apps.mypurecloud.com', region: 'us-east-1', clientId: '', clientSecret: '' -- [ArchSession, ArchSessionId:'BJ5YpDpLN']
- getting discovery properties... -- [ArchSession, ArchSessionId:'BJ5YpDpLN']
- calling url -- [GET::https://apps.mypurecloud.com/services/discovery.properties]
App listening on port 8080
- response received - statusCode:200, statusMessage:OK, correlationId:undefined -- [GET::https://apps.mypurecloud.com/services/discovery.properties]
- core environment discovery properties loaded. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN']
- core environment initialized. Now logging in... -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN']
- calling url -- [POST::https://login.mypurecloud.com/token]
- response received - statusCode:200, statusMessage:OK, correlationId:b2318c67-2cb0-4afa-60a3-d548c294faea -- [POST::https://login.mypurecloud.com/token]
- setting auth token 'mQ' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization]
- response received - statusCode:200, statusMessage:OK, correlationId:bb5136a5-814f-4d46-bc6f-e5b40494e32c -- [GET::https://apps.mypurecloud.com/platform/api/v2/users/me?expand=token,authorization]
- authenticated name: 'Rahul Sadhana' , id: '8f' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000]
- obtaining organization information -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me]
- response received - statusCode:200, statusMessage:OK, correlationId:91a5ed74-c253-4ddb-856e-d8db076235b3 -- [GET::https://apps.mypurecloud.com/platform/api/v2/organizations/me]
- obtained organization information. organization name: 'xyz', id: 'xyz' -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN', OrgName:'xyz', OrgId:'xyz']
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeVoicemailTransferFailureHandling&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=InboundMessagingWhatsApp&feature=workflowClient&feature=authorization.division.management&feature=authorization.division.management.outbound.lists]
- response received - statusCode:200, statusMessage:OK, correlationId:b7afd3e9-4b1f-466e-82f5-094f8892d12c -- [GET::https://apps.mypurecloud.com/platform/api/v2/telephony/providers/edges/timezones?pageSize=1000]
- response received - statusCode:200, statusMessage:OK, correlationId:b98e8071-37c7-4ea9-8826-2e7af48f76ab -- [GET::https://apps.mypurecloud.com/platform/api/v2/featuretoggles?feature=archAmbiguousAudioSettings&feature=archBusyProcessingPrompt&feature=archCallSecureActionErrorSupport&feature=archDynamicQueues&feature=archDynamicSkills&feature=archExpressionBuilders&feature=archExpressionNoConfigError&feature=archFuncToAudioTTSWithLang&feature=archPhoneNumberPhase2&feature=archRenumber&feature=archShortcuts&feature=archSpeechFlows&feature=communicate&feature=disable-announcements&feature=edgeEnableOutboundRLT&feature=edgeVoicemailTransferFailureHandling&feature=edgeTtsEngines&feature=engage&feature=inAppNotifications&feature=InboundMessagingWhatsApp&feature=workflowClient&feature=authorization.division.management&feature=authorization.division.management.outbound.lists]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes]
- response received - statusCode:200, statusMessage:OK, correlationId:5a5788cc-396b-436d-8d17-0f0798fd6a8a -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels]
- response received - statusCode:200, statusMessage:OK, correlationId:6bf975df-783c-44e8-9268-ddde36fe0d48 -- [GET::https://apps.mypurecloud.com/platform/api/v2/architect/configuration?expand=languages,actions,functions,flowtypes]
- ArchFactoryFlows startup initialization - begin. -- [ArchFactoryFlows]
- ArchFactoryFlows startup initialization - end. -- [ArchFactoryFlows]
- session startup initialization for startWithClientIdAndSecret complete. Calling callback function. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN', OrgName:'xyz', OrgId:'xyz']
- find 'flow name' by property value where 'name' = 'INDIA ERC QUEUE' -- [ArchNetworkValueRetrieval]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=INDIA%20ERC%20QUEUE]
- iteration 0: Waiting for 1 async operation(s) to complete... -- [ArchAsyncTracker]
- session startup initialization for startWithClientIdAndSecret complete. Callback function execution complete. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN', OrgName:'xyz', OrgId:'xyz']
- session startup initialization for startWithClientIdAndSecret complete. Callback function returned a promise. Waiting until it resolves. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN', OrgName:'xyz', OrgId:'xyz']
- response received - statusCode:200, statusMessage:OK, correlationId:f51d808d-43df-48ca-9e19-7a2b2c25d029 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inqueuecall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=INDIA%20ERC%20QUEUE]
- async processing for getFlowInfoByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows]
- find 'flow name' by property value where 'name' = 'NA6HELPMAIN_STAGE' -- [ArchNetworkValueRetrieval]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=NA_6HELP_MAIN_STAGE]
- async processing for getFlowInfoByFlowNameAsync complete. Callback function execution complete. -- [ArchFactoryFlows]
- need to wait for more async operations(s) to complete... -- [ArchAsyncTracker]
- iteration 1: Waiting for 1 async operation(s) to complete... -- [ArchAsyncTracker]
- response received - statusCode:200, statusMessage:OK, correlationId:be90e5ef-6df3-4781-a4f7-b1f29ee7c85e -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows?type=inboundcall&pageNumber=1&pageSize=25&sortBy=name&sortOrder=ASC&name=NA_6HELP_MAIN_STAGE]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/33d98738-2af6-4f93-858b-7f707a2f9c20/latestConfiguration?deleted=true]
- need to wait for more async operations(s) to complete... -- [ArchAsyncTracker]
- iteration 2: Waiting for 2 async operation(s) to complete... -- [ArchAsyncTracker]
- response received - statusCode:200, statusMessage:OK, correlationId:4c6d2212-d6c7-43f5-9567-c65b47b61fd8 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/33d98738-2af6-4f93-858b-7f707a2f9c20/latestConfiguration?deleted=true]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/i13j0251bnccsqittfk6i84vvo/subscriptions]
- response received - statusCode:200, statusMessage:OK, correlationId:0b9d708e-b5f7-49d4-a9ed-8fa1e5ac47c5 -- [POST::https://apps.mypurecloud.com/platform/api/v2/notifications/channels/i13j0251bnccsqittfk6i84vvo/subscriptions]
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=33d98738-2af6-4f93-858b-7f707a2f9c20&flowType=inboundcall]
- response received - statusCode:202, statusMessage:Accepted, correlationId:4b3f319d-7b4f-488c-be7f-caedb3d364cc -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/actions/validate?flow=33d98738-2af6-4f93-858b-7f707a2f9c20&flowType=inboundcall]
- calling url -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/33d98738-2af6-4f93-858b-7f707a2f9c20/validate/747a8785-0d94-4890-915d-600f89649132]
- response received - statusCode:200, statusMessage:OK, correlationId:c9fdb7a1-9d0e-49c5-a2fd-bed9f25ee174 -- [GET::https://apps.mypurecloud.com/platform/api/v2/flows/33d98738-2af6-4f93-858b-7f707a2f9c20/validate/747a8785-0d94-4890-915d-600f89649132]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Calling callback function. -- [ArchFactoryFlows]
- setting the in-queue flow 'INDIA ERC QUEUE' to be used for the in-queue handling of the call. -- [TrackingID:249, Name:'ACTION11', Type:'ArchActionTransferToAcd']
- saveAsync - saving flow... -- [Name:'NA6HELPMAIN_STAGE', Type:'ArchFlowInboundCall', Id:'33d98738-2af6-4f93-858b-7f707a2f9c20']
- iteration 0: Waiting for 1 async operation(s) to complete... -- [ArchAsyncTracker]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function execution complete. -- [ArchFactoryFlows]
- async processing for checkoutAndLoadFlowByFlowNameAsync complete. Callback function returned a promise. Waiting until it resolves. -- [ArchFactoryFlows]
- session startup initialization for startWithClientIdAndSecret complete. Callback function returned promise successfully resolved. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN', OrgName:'xyz', OrgId:'xyz']
- calling url -- [POST::https://apps.mypurecloud.com/platform/api/v2/flows/33d98738-2af6-4f93-858b-7f707a2f9c20/versions]
- waiting for any pending work to complete before ending the session -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN', OrgName:'xyz', OrgId:'xyz']
- setting session status to 'ended'. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN', OrgName:'xyz', OrgId:'xyz']
- waiting for any pending work to complete before ending the session -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN', OrgName:'xyz', OrgId:'xyz']
- ending with exit code: 0 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN', OrgName:'xyz', OrgId:'xyz']
- session is configured to terminate the process when ending. -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN', OrgName:'xyz', OrgId:'xyz']
- now exiting the process with exit code: 0 -- [ArchSession, Environment:'prod', Host:'apps.mypurecloud.com', Region:'us-east-1', ArchSessionId:'BJ5YpDpLN', OrgName:'xyz', OrgId:'xyz']
Eric_Spence | 2019-03-06 16:53:39 UTC | #32
Hi @Rahul_Sadana, So I took a look at your code and it looks like you missed returning a promise. I went ahead and reworked your code that should get you up and running.
et archInQueueInfo;
eturn scriptingFlowFactory.getFlowInfoByFlowNameAsync('INDIA ERC QUEUE',scriptingEnums.FLOW_TYPES.inqueueCall, function (archInQueueFlowInfo) {
archInQueueInfo = archInQueueFlowInfo;
return scriptingFlowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName, scriptingEnums.FLOW_TYPES.inboundCall, true, 'latest' , function (archInboundCallFlow) {
let archTransferAction;
for (let i = 0; i < archInboundCallFlow.menusReusable.length; i++) {
archTransferAction = findFirst(archInboundCallFlow.menusReusable[i], 'ACTION11');
if (archTransferAction && archTransferAction.isArchMenuTransferToAcd) {
archTransferAction.actionTransferToAcd.inQueueHandlingFlowInfo = archInQueueInfo;
break;
} else if (archTransferAction && archTransferAction.isArchActionTransferToAcd) {
archTransferAction.inQueueHandlingFlowInfo = archInQueueInfo;
break;
}
}
return archInboundCallFlow.saveAsync(true);
});
);
Rahul_Sadana | 2019-03-21 06:25:34 UTC | #33
Thanks Eric , it seems to be working fine now , will test this more and share the update how it goes.
Eric_Spence | 2019-03-21 14:36:15 UTC | #34
Awesome. Let me know if any other issues pop up.
Ullyot_Jim | 2019-04-04 21:57:35 UTC | #35
@RahulSadana, we wanted to let you know that Architect Scripting ver. 0.2.5 is now available. While the asynchronous processing fixes that @EricSpence talked about were available in the 0.2.3 release, one thing which is now available is a traverse helper method available off of ArchBaseCoreObject objects which you might find useful for scenarios where you have a flow loaded and want to spin through it looking for objects that match certain criteria and then modify them similar to what some of the code does here in this thread.
One thing to remember is that logic like this:
if (archTransferAction && archTransferAction.isArchMenuTransferToAcd) {
can be done either in the traverse callback itself or you can use some of the filtering capabilities supported by traverse to only be called back when filter criteria is met which in this case is an object having an isArchMenuTransferToAcd property with the value of true.
While I haven't run the code below, here's one way you could update all transfer to ACD actions in the inbound call flow like this:
archInQueueInfo = archInQueueFlowInfo; flowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName, enums.FLOW_TYPES.inboundCall, true, 'latest' , function (archInboundCallFlow) {
// ************************ // Traverse the flow and for anything that's a transfer to ACD action // set the inQueueHandlingFlowInfo to archInQueueInfo. We'll get // called back for lots of objects in the flow and it's in the callback where // we look at the match object to see if it's a Transfer to ACD action. // For other objects we simply let execution fall through. // ************************ archInboundCallFlow.traverse(function(traverseInfo) { if (traverseInfo.matchObject.isArchActionTransferToAcd) { traverseInfo.matchObject.inQueueHandlingFlowInfo = archInQueueInfo; } });
or if you wanted to use a filter with traverse:
// ************************ // Traverse the flow and for anything that's a transfer to ACD action // set the inQueueHandlingFlowInfo to archInQueueInfo using a filter. // ************************
// Create a filter let filter = filterFactory.createFilterObject();
// Add a clause to the filter to check if an object's isArchActionTransferToAcd // property has the boolean value of true filter.addClausePropertyValueEquals('isArchActionTransferToAcd', true);
// Call the traverse method using the filter above so we only receive callbacks // for Transfer to ACD actions archInboundCallFlow.traverse(function(traverseInfo) { traverseInfo.matchObject.inQueueHandlingFlowInfo = archInQueueInfo; }, filter);
Hope this helps!
Jim
system | 2019-05-04 14:17:16 UTC | #36
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 4243