Importing previously exported flows

Hi,

I have exported a flow using ArchFlowInboundChat.exportToDirAsync.

In a subsequent script, I want to load this flow using ArchFlowInboundChat.importFromFileAsync. However, this function doesn't appear to be static, so I need to construct an ArchFlowInboundChat object to be able to call it.

When I do, and I import the data then publish it (via publishAsync), the flow created does not match the flow I imported - it just resembles an empty flow with the name/description I provided in the constructor.

Can anyone show me an example of importFromFileAsync that works correctly?

Hi Austen,

Here is an example of how to use the importFromFileAsync function.

    return scriptingFlowFactory.createFlowInboundChatAsync('MyFlowName', 'my description', architectScripting.languages.archLanguages.englishUnitedStates, (archInboundChat) => {
        return archInboundChat.importFromFileAsync(savedFilePath, () => {
            return archInboundChat.publishAsync();
        });
    });

As you can see, you first must create a new flow, then in the callback function for the flow creation you can then call the importFromFileAsync function and pass in the path to the exported file (called savedFilePath in the example above) and another callback function. Finally, in this last callback function is where you can call publishAsync. Let me know if you have any questions regarding this example or need any additional help!

Thanks,
Jon

Hi Jon,

Thanks for the reply. That code was essentially similar to what I have been trying, and unfortunately exhibits the same issues - it does create a flow called MyFlowName but this doesn't seem to have any of the characteristics of the flow being imported - the menus are missing, all the prompts etc have default values, and so on.

Which aspects of a flow are actually importable via the above method, do you know?

Thanks,

Austen

Hi Austen,

When I was testing the code that I had sent above, I was able to import the initial state/multiple reusable tasks etc for the Inbound Chat Flow. It should import everything that you have in the exported file. In the code you are running are you doing the publishAsync call in the callback from the importFromFileAsync call? If possible, could you send the code you are running without any personal information in the code?

Thanks,
Jon

Hi Jon,

This is what I'm currently running, utilizing your snipper, but with the flow type and language changed:

'use strict'

const architectScripting = require('purecloud-flow-scripting-api-sdk-javascript');

const clientId = 'CLIENTIDHERE';

const clientSecret = 'CLIENTSECRETHERE';

const clientIsClientCredentials = true; // set to false if using an OAuth client that has a code authorization grant instead of client credentials grant.

const archEnums = architectScripting.enums.archEnums;

const archSession = architectScripting.environment.archSession;

// --------------------------------------------------------------------------------

// This function will be what is called by Architect Scripting since it is

// specified in the start call at the bottom.

// --------------------------------------------------------------------------------

async function doWork(scriptSession) {

const scriptingFlowFactory   = architectScripting.factories.archFactoryFlows;   // Factory to create flows

// Import the flow

return scriptingFlowFactory.createFlowInboundCallAsync('AJCreateFlow3', 'Using forum method', architectScripting.languages.archLanguages.englishUnitedKingdom, (archInboundChat) => {

    return archInboundChat.importFromFileAsync("d:\\temp\\flowout\\AJ Test_v1-0.i3InboundFlow", () => {

        return archInboundChat.publishAsync();

    });

});    

}

// This will start off the Architect Scripting code and call the doWork function

archSession.startWithClientIdAndSecret(archEnums.LOCATIONS.prod_us_east_1, doWork, clientId, clientSecret, void 0, clientIsClientCredentials);

Thanks,

Austen

Hi Austen,

I just sent you a direct message on the developer forum.

Thanks,
Jon

Austen,

I'll continue to follow up individually for now and can update this thread later when we find the results of our discussion.

Thanks,
Jon

Austen,

I'm glad we were able to solve your issues. It seems that something happened with the original exported file and was giving you an incorrect result when importing it into your newly created flow. Please reach out to us again in the future if you require any more assistance!

Thanks,
Jon

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