Bhagyaraju_Pati | 2023-03-16 09:25:08 UTC | #1
Hi, I want to create InboundMessageFlow and I want to add CallBotConnector node in the flow. Please help me how to create using Architect Flow SDK Please help me how to create using Architect Flow
wanted to create a flow like this
Bhagyaraju_Pati | 2023-03-16 10:05:55 UTC | #2
I think ArchFactoryActions#addActionCallBotConnector this function is not yet implemented in architect scripting SDk, if implemented please let me know how to use this function.
MelissaBailey | 2023-03-16 13:36:24 UTC | #3
Yes it's implemented.
var startupState = archFlow.startUpObject; var botConnectorVar = actionFactory.addActionCallBotConnector(startupState, 'Calling bot connector bot'); botConnectorVar.setBotByIdAsync('insertBotIntegrationIdHere', 'insertBotIdHere', 'insertBotVersionHere', function(bcbAsync){
//everything from here until the }); is optional and depends on how your bot is configured. //I'm just showing how to set the various fields with dummy values botConnectorVar.inputText.setExpression('Message.Message.body'); botConnectorVar.followupResponseTimeout.setExpression('MakeDuration(0, 12, 0, 0, 0)'); botConnectorVar.addSessionVariableNameValuePair('input1', '\"the 1st thing\"'); botConnectorVar.addSessionVariableOutputNameValuePair('output2', 'State.output2'); var intentOneVar = botConnectorVar.intentSlots.getNamedValueByName('IntentOne'); intentOneVar.getNamedValueByName('One').value.setVariable('State.intent1'); botConnectorVar.botConnectorOutputsFailure.getNamedValueByName('errorType').value.setVariable('Flow.errorType'); var disconnectVar = actionFactory.addActionDisconnect(botConnectorVar.getOutputByName('IntentOne', true), 'Disconnect');
});
Bhagyaraju_Pati | 2023-03-16 14:23:56 UTC | #4
Hi Melissa,
Thanks for the reply.
I am trying the below code.
// -------------------------------------------------------------------------------- // Require in the Genesys Cloud Platform SDK and Architect Scripting SDK // -------------------------------------------------------------------------------- const architectScripting = require('purecloud-flow-scripting-api-sdk-javascript'); const platformApi = require('purecloud-platform-client-v2');
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;
// const callBotConnector = architectScripting.viewModels.actions.ArchActionCallBotConnector; // -------------------------------------------------------------------------------- // See above in the readme for information on creating a client id / secret. // We will use these when starting the Architect Scripting session. // -------------------------------------------------------------------------------- const clientId = ''; const clientSecret = ''; const clientIsClientCredentials = true; // set to false if using an OAuth client // that has a code authorization grant // instead of client credentials grant. // -------------------------------------------------------------------------------- // Helpers to make sample code more readable. // -------------------------------------------------------------------------------- const archEnums = architectScripting.enums.archEnums; const archSession = architectScripting.environment.archSession; const platformApiClient = platformApi.ApiClient.instance;
// -------------------------------------------------------------------------------- // This function will be what is called by Architect Scripting since it is // specified in the start call at the bottom. // -------------------------------------------------------------------------------- function doWork(scriptSession) {
// Once the session starts you can do this to assign the authToken from // the Architect session object to the platform API client. platformApiClient.setAccessToken(scriptSession.authToken);
var startupState = scriptingFlowFactory.startUpObject; var botConnectorVar = scriptingActionFactory.addActionCallBotConnector(startupState, 'Calling bot connector bot'); botConnectorVar.setBotByIdAsync('insertBotIntegrationIdHere', 'insertBotIdHere', 'insertBotVersionHere', function(bcbAsync){
//everything from here until the }); is optional and depends on how your bot is configured. //I'm just showing how to set the various fields with dummy values botConnectorVar.inputText.setExpression('Message.Message.body'); botConnectorVar.followupResponseTimeout.setExpression('MakeDuration(0, 12, 0, 0, 0)'); botConnectorVar.addSessionVariableNameValuePair('input1', '"the 1st thing"'); botConnectorVar.addSessionVariableOutputNameValuePair('output2', 'State.output2'); var intentOneVar = botConnectorVar.intentSlots.getNamedValueByName('IntentOne'); intentOneVar.getNamedValueByName('One').value.setVariable('State.intent1'); botConnectorVar.botConnectorOutputsFailure.getNamedValueByName('errorType').value.setVariable('Flow.errorType'); var disconnectVar = scriptingActionFactory.addActionDisconnect(botConnectorVar.getOutputByName('IntentOne', true), 'Disconnect');
}); // return scriptingFlowFactory.createFlowInboundShortMessageAsync("TestFlow-Bhagi", "TestFlow", scriptingLanguages.englishUnitedStates, (data)=>{ // console.log("================================="); // console.log(scriptingFlowFactory); // console.log("=================================");
// });
}
// This will start off the Architect Scripting code and call the doWork function archSession.startWithClientIdAndSecret(archEnums.LOCATIONS.produseast1, doWork, clientId, clientSecret, void 0, clientIsClientCredentials); // archSession.startWithAuthToken(archEnums.LOCATIONS.produseast1, doWork, authToken, void 0, clientIsClientCredentials);
getting the below error
MelissaBailey | 2023-03-16 14:42:42 UTC | #5
Are you on the latest version of scripting? https://www.npmjs.com/package/purecloud-flow-scripting-api-sdk-javascript
Bhagyaraju_Pati | 2023-03-17 04:17:11 UTC | #6
Hi Melissa,
Yes, I am using the latest version of npm library. "purecloud-flow-scripting-api-sdk-javascript": "^0.36.1"
Bhagyaraju_Pati | 2023-03-29 11:05:09 UTC | #7
Hi, I am able to achieve the above flow, and got one more issue,
Can we add a transfer to ACD to the "talk to agent" intent from the above flow?
system | 2023-04-29 11:05:22 UTC | #8
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: 18945