Is there a way to invoke a data action via the APIs/SDKs?

Hi all, I know we can invoke data actions in the agent desktop with the "Execute Data action" action type, this works well. However, in our case we cant use this directly as we need more Javascript processing before we can invoke that specific action (there is a 3rd party REST API behind this data action).
The logic we try to achieve:

  • interaction arrives to the agent desktop
  • we execute an INFRAME in the agent desktop which has some javascript logic
  • at some point the javascript logic (possibly using the JS PLatform SDK) should invoke the data action which is created in Genesys cloud. note that we need to run this data action multiple times based on the agent input and clicking a button so it cant be a single normal data action call outside the IFRAME

Is there a way to call a Genesys platform API which would execute an existing data action? I did not find any such data actions. We just cant easily invoke that 3rd party API from the INFRAME because we do not have the authentication available (and we do not want to store it in the JS code). we could use the OAuth2 SDK authentication to get access to API but I just dont find any APIs which would allow the execution of an existing data action.

One thing that came to my mind is the use of AWS Lambdas but I would like to avoid using a Lambda for this if possible.

thansk,
Zsolt

I just found that under Integration there is actually a way to execute a data action:
POST /api/v2/integrations/actions/{actionId}/execute

However, I am not sure how the body can be constructred. for example, i am getting "Id Id must have a valid action type and at least one key value" but i am not sure what action type is expected here, what is the name and what are the possible values. Is there a working example available?

Hi @beliczazsolt,

To execute a data action using the Genesys Cloud SDK, you can make a POST request to the endpoint:

/api/v2/integrations/actions/{actionId}/execute

SDK example (https://developer.genesys.cloud/devapps/sdk/docexplorer/purecloudjavascript/IntegrationsApi#postIntegrationsActionExecute)

// Browser
const platformClient = require('platformClient');
// Node
const platformClient = require('purecloud-platform-client-v2');

// Manually set auth token or use loginImplicitGrant(...) or loginClientCredentialsGrant(...)
platformClient.ApiClient.instance.setAccessToken(yourAccessToken);

let apiInstance = new platformClient.IntegrationsApi();

let actionId = "actionId_example"; // String | actionId
let body = null; // {String: Object} | Map of parameters used for variable substitution.

apiInstance.postIntegrationsActionExecute(actionId, body)
  .then((data) => {
    console.log(`postIntegrationsActionExecute success! data: ${JSON.stringify(data, null, 2)}`);
  })
  .catch((err) => {
    console.log('There was a failure calling postIntegrationsActionExecute');
    console.error(err);
  });

Here are the parameters you need to provide:

  • actionId: This is the Id of the published data action you want to execute. You can obtain it from the URL when you open the data action. The Id is a string following the format: custom_-_bxx27de3-39c9-8984-ch7f-b42zzc32a478.

  • Body: This is an object that contains all the input parameters required for variable substitution.

Here is an example to illustrate the structure of the body object.

Let's assume you have a data action that accepts three inputs: queueId, interval and media. Your body should be constructed as follows:

{
  queueuId: "Id of the queue",
  interval: "2023-06-21T22:00:00.000Z/2023-06-22T22:00:00.000Z",
  media: "voice"
}

I hope that helps :slight_smile:

BR,

Charaf

Thank you for the example, it helped. previously i though the " custom_-" part was not part if the ID (it is clearly not a 36 character UUID) and thats when you start getting this very helpful error message:
Message: Id Id must have a valid action type and at least one key value.
When i used the full name including "custom
-_" then it started to work.
thanks again

1 Like

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