Update a "InqueueCallFlow" in the Inbound call flow

return scriptingFlowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName, scriptingEnums.FLOW_TYPES.inboundCall, true, 'latest' , function (archInboundCallFlow) {
scriptingFlowFactory.getFlowInfoByFlowNameAsync('TEST 2 QUEUE FLOW MEETING1',scriptingEnums.FLOW_TYPES.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");

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.FLOW_TYPES.inqueueCall, function (archInQueueFlowInfo) {
    archInQueueInfo = archInQueueFlowInfo;
    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(true);
    });
});
// This is the workaround and won't be needed in upcoming releases
return archAsyncTracker.allSettled();
}

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.prod_us_east_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.FLOW_TYPES.inqueueCall, function (archInQueueFlowInfo) {
archInQueueInfo = archInQueueFlowInfo;
scriptingFlowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName, scriptingEnums.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(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


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.

Thanks Eric!. Noticed that before have already deleted oath client .

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));
}
1 Like

We have identified the issue in our async processing for save and should have a fix released soon for it.

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();
        });
    });
}

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


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.prod_us_east_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.FLOW_TYPES.inqueueCall, function (archInQueueFlowInfo) {
archInQueueInfo = archInQueueFlowInfo;
return scriptingFlowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName,scriptingEnums.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();
});
});

}

scriptingSession.startWithClientIdAndSecret(location, scriptMain, clientId, clientSecret);
app.listen(8080);
console.log("App listening on port 8080");

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.

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 "NA_6HELP_MAIN_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.prod_us_east_1;

function scriptMain() {

const flowName = 'NA_6HELP_MAIN_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.FLOW_TYPES.inqueueCall, function (archInQueueFlowInfo) {
archInQueueInfo = archInQueueFlowInfo;
scriptingFlowFactory.checkoutAndLoadFlowByFlowNameAsync(flowName, scriptingEnums.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], '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

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.

let archInQueueInfo;
return 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);
   });
});

Thanks Eric , it seems to be working fine now , will test this more and share the update how it goes.

Awesome. Let me know if any other issues pop up.

@Rahul_Sadana, we wanted to let you know that Architect Scripting ver. 0.2.5 is now available. While the asynchronous processing fixes that @Eric_Spence 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

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.