Updating the audio resource of the user promt assigned to a "inqueue call flow"

In case of a prompt assigned in a "Inqueue Call flow" our requirement is to change the audio file of prompt with a new one using a self-service web page.

I can see you have a tutorial to create and upload a new prompt resource. however, our requirement is to update the audio resource of the existing prompt assigned to an "inqueue call flow" can you suggest if update of the audio file/resource of a user prompt assigned to a inqueue call flow is possible? if yes what should be the approach to do this .

Tutorial for creating and uploading a prompt which I am referring
https://developer.mypurecloud.com/api/tutorials/upload-prompts/?language=nodejs&step=1

Hi

Can anyone help on this.

You just need to do the post to upload the new wav file to the prompt resource's uploadUri. After that you will need to re-publish the in-queue flow for it to get the new audio, see https://help.mypurecloud.com/articles/user-prompts/

You could switch to using the Find Prompt action in your flow to avoid having to do the republish. https://help.mypurecloud.com/articles/work-with-dynamically-referenced-prompts/

Hi Melissa ,

I tried to use POST for updating the uploadUri in an already existing prompt resourse, but its giving an error that the "prompt Id already exist" however it allows me to create a new prompt resource but is now letting me update the existing prompt resource

Are we required to use PUT for updating the prompt resource ?

My Current code to POST a prompt is below its working fine to create a new resource but is not able to modify the already existing


const platformClient = require('purecloud-platform-client-v2');
const fs = require('fs');
const request = require('request-promise');

// Get client credentials from environment variables
const PURECLOUD_CLIENT_ID = '4';
const PURECLOUD_CLIENT_SECRET ='-';

//console.log(process.env.PURECLOUD_CLIENT_ID,process.env.PURECLOUD_CLIENT_SECRET)
// Set purecloud objects
const client = platformClient.ApiClient.instance;
const architectApi = new platformClient.ArchitectApi();

// Set PureCloud settings
client.setEnvironment('mypurecloud.com');
console.log(PURECLOUD_CLIENT_ID,PURECLOUD_CLIENT_SECRET);
// Authenticate with PureCloud
let body = {
name:'test15',
description:'testing purpose only'
}
client.loginClientCredentialsGrant(PURECLOUD_CLIENT_ID, PURECLOUD_CLIENT_SECRET)
.then(() => {

	console.log('Authenticated with PureCloud');

	// Create new prompt
	console.log('Creating new prompt...');
	return architectApi.postArchitectPrompts(body) 
	    

})

.then((data) => {
// console.log(postArchitectPrompts success! data: ${JSON.stringify(data, null, 2)});
var Id = data.id;
return Id;
})

.then((Id) => {
console.log('Data id' + Id);
console.log("This is the" + Id);
let body1 = { language: 'en-us'}

	// Create prompt resource for english
	console.log('Creating prompt resource...');
	return architectApi.postArchitectPromptResources(Id, body1
	);

})
.then((promptResource) => {
console.log(promptResource);

	// Upload WAV file to prompt
	console.log('Uploading prompt...');
    return request({
		method: 'POST',
		uri: promptResource.uploadUri,
		formData: {
			file: fs.createReadStream('C:\\code\\file\\new.wav')
		},
		headers: {
			Authorization: 'bearer ' + client.authData.accessToken
		}
	});
})



.catch((err) => console.log(err));

To upload a file for an existing prompt resource, you need to do a get to the prompt resource to get the uploadUri (unless you already know it), then just the post to the uploadUri. Don't do the posts to create a prompt or prompt resource.

Thanks Melissa , its working fine now!

Also , when I am publishing the flow getting the below response, does it means FLOW is actually publish

Do I have to publish both "Inqueue call flow" and "Inbound call flow" for changes in prompt resource to get effected

postFlowsActionsPublish success! data: {
"id": "80624028-8aa9-4187-90f6-a6748840c04d",
"complete": false,
"actionName": "PUBLISH",
"actionStatus": "STARTED"
}

Publishing a flow takes several seconds. That response indicates the publish has been started. To know when it is finished, you can either:

  1. Subscribe to the notification topic and wait until you get the SUCCESS notification (please note that there are several intermediate notifications you will receive). See https://developer.mypurecloud.com/api/rest/v2/notifications/notification_service.html. The topic will be v2.flows.{id} where id is the id of the flow.
  2. Wait ~5 seconds, then poll the flows/id endpoint and wait for the publishedVersion id to increment from what it was before (i.e. to go from 1.0 to 2.0) and/or for the currentOperation actionStatus to be SUCCESS.

I used the 2nd option , and can see the success for PUBLISH status , however the PUBLISH version is not increasing

Is that OK ?

},
"currentOperation": {
"id": "21bfb8ca-1535-4138-922a-1162a27e32cf",
"complete": true,
"user": {
"id": "3410ae41-eb54dbf1594",
"selfUri": "/api/v2/users/3410ae41-bf1594"
},
"errorDetails": [],
"actionName": "PUBLISH",
"actionStatus": "SUCCESS"
},

Are you comparing the version number to what it was from before you started the publish? i.e fetch the flow to see the published version is 8.0, do the post to publish, then poll until the version becomes 9.0

Yes, I am comparing the version number before I started the publish and post it and it's same

For Instance

Before I started the Publish


"publishedVersion": {
"id": "34.0",
"name": "34.0",
"commitVersion": "34.0",
"configurationVersion": "1.1",
"secure": false,
"createdBy": {
"id": "8fbdfc5c-801f-4d6c-b259-2b44acac14f4",
"name": "Rahul Sadhana",
"selfUri": "/api/v2/users/8fbdfc5c-801f-4d6c-b259-2b44acac14f4"
},
"configurationUri": "/api/v2/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/versions/34.0/configuration",
"dateCreated": 1551791220940,
"generationId": "ab52a096-89ef-4b55-aee4-8cf68cda3a48",
"selfUri": "/api/v2/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/versions/34.0"
},


Post I publish the flow


"publishedVersion": {
    "id": "34.0",
    "name": "34.0",
    "commitVersion": "34.0",
    "configurationVersion": "1.1",
    "secure": false,
    "createdBy": {
        "id": "8fbdfc5c-801f-4d6c-b259-2b44acac14f4",
        "name": "Rahul Sadhana",
        "selfUri": "/api/v2/users/8fbdfc5c-801f-4d6c-b259-2b44acac14f4"
    },
    "configurationUri": "/api/v2/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/versions/34.0/configuration",
    "dateCreated": 1551791220940,
    "generationId": "ab52a096-89ef-4b55-aee4-8cf68cda3a48",
    "selfUri": "/api/v2/flows/c0ae152c-8f95-4213-a4f1-1228a9e53187/versions/34.0"
},

In that case you're not actually publishing the flow. The obvious issue could be using the wrong flow id. Can you send me the correlation id of the publish?

This seems to be working fine now , I am doing a flow unlock first followed by checkout and then publish by current action flow is like this

postFlowsActionsUnlock
postFlowsActionsCheckout
postFlowsActionsPublish

Will test this more and share the update how it goes.

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