Legacy Dev Forum Posts

 View Only

Sign Up

Creating inbound flow using SDK js

  • 1.  Creating inbound flow using SDK js

    Posted 06-05-2025 19:27

    varun | 2025-02-13 07:04:22 UTC | #1

    Hi, I want to create entire inbound flow using "purecloud-platform-client-v2". So when I ran below code it says it ran successfully but when I try to open in Genesys it says

    const platformClient = require('purecloud-platform-client-v2'); const client = platformClient.ApiClient.instance; const architectApi = new platformClient.ArchitectApi();

    client.setEnvironment('');

    // Authenticate client.loginClientCredentialsGrant('', '') .then(() => { console.log('Authenticated successfully');

    const flowData = { name: 'My Inbound Flow with Main Menu', type: 'inboundcall', // Inbound Call Flow type description: 'An inbound flow that plays audio, provides a main menu, and disconnects', startAction: { actionType: 'playAudio', playAudio: { text: 'Hello, thank you for calling. Please press 1 for Sales, press 2 for Support, or press 3 to speak to an operator.' } }, actions: [ { actionType: 'menu', // Main Menu action menu: { speechRecognition: { speechRecognitionEnabled: true, // Enable speech recognition for menu speechRecognitionPrompts: [ { text: 'Please choose from the following options: Press 1 for Sales, Press 2 for Support, or Press 3 for an Operator.' } ] }, options: [ { value: '1', action: { actionType: 'playAudio', playAudio: { text: 'You have selected Sales. Please hold for further assistance.' } } }, { value: '2', action: { actionType: 'playAudio', playAudio: { text: 'You have selected Support. Please hold for further assistance.' } } }, { value: '3', action: { actionType: 'playAudio', playAudio: { text: 'You have selected to speak to an operator. Please hold.' } } } ], timeoutAction: { actionType: 'playAudio', playAudio: { text: 'Sorry, I did not catch that. Please press 1 for Sales, press 2 for Support, or press 3 for an Operator.' } } } }, { actionType: 'disconnect', // Disconnect after the main menu selection disconnect: {} } ], division: { // Division parameter to specify which division the flow belongs to id: '' // Provide the actual Division ID here }, defaultLanguage: 'en-US' };

    // Create the flow using Architect API architectApi.postFlows(flowData) .then((flowResponse) => { console.log('Flow created successfully:', flowResponse);

    // Save the flow architectApi.putFlow(flowResponse.id, flowResponse) .then((savedFlow) => { console.log('Flow saved successfully:', savedFlow);

    // Mark the flow as 'published' savedFlow.state = 'published';

    // Update and publish the flow architectApi.putFlow(savedFlow.id, savedFlow) .then((publishedFlow) => { console.log('Flow published successfully:', publishedFlow); }) .catch((err) => { console.error('Error publishing flow:', err); }); }) .catch((err) => { console.error('Error saving flow:', err); }); }) .catch((err) => { console.error('Error creating flow:', err); }); }) .catch((err) => { console.error('Error authenticating', err); });


    system | 2025-03-16 07:04:39 UTC | #2

    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: 31700