Need help to parse data table content into Architect variables

Good day Community,

Note: I have had a look at the other threads on this topic, but I'm still struggling.

It's my first time trying to use data action with a data table to populate Architect variables and I need some help to understand how to build the output contract and Response/translation for 'custom' data tables.

Using /api/v2/flows/datatables/${input.datatableid}/rows?pageSize=500&showbrief=false
Result JSON:

{
  "entities": [
    {
      "PromptVerbiage": "This is test prompt 1",
      "key": "TestPrompt1"
    },
    {
      "PromptVerbiage": "This is test prompt 2",
      "key": "TestPrompt2"
    }
  ],
  "pageSize": 500,
  "pageNumber": 1,
  "total": 2,
  "pageCount": 1
}

How would one build the output contract and response to get the data to variables that you can query?
The data table won't have hundreds of ROWS.
My thinking is that one needs an array variable with each row as a JSON Object with the two values.

Any clarity would be very welcome.

Current Contract:

{
  "type": "array",
  "properties": {
    "key": {
      "type": "string"
    },
    "PromptVerbiage": {
      "type": "string"
    }    
  },
  "additionalProperties": true
}

Current Response:

{
  "translationMap": {
    "prompt": "$.entities"
  },
  "translationMapDefaults": {},
  "successTemplate": "${prompt}"
}

image

How to get the whole array of objects?

Updated Contract:

{
  "title": "Prompts",
  "type": "array",
  "properties": {},
  "items": {
    "title": "Prompt",
    "type": "object",
    "properties": {
      "PromptVerbiage": {
        "type": "string"
      },
      "key": {
        "type": "string"
      }
    },
    "additionalProperties": true
  }
}

Updated Response:

{
  "translationMap": {
    "Prompts": "$.entities"
  },
  "translationMapDefaults": {},
  "successTemplate": "${Prompts}"
}

Getting only the first item.

Not sure what I am missing.

In this case it looks like your best bet is to model the entire response object:

{
  "title": "response",
  "type": "object",
  "properties": {
    "entities": {
      "type": "array",
      "items": {
        "title": "Item 3",
        "type": "object",
        "properties": {
          "PromptVerbiage": {
            "type": "string"
          },
          "key": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    }
  },
  "additionalProperties": true
}

And then pass that response on

{
  "translationMap": {},
  "translationMapDefaults": {},
  "successTemplate": "${rawResult}"
}

You will then have a couple of parallel lists, entities.PromptVerbiage and entities.key that you can iterate through in architect to accomplish your goal.

I suggest this approach as otherwise you are going to end up with failures because data actions are pretty picky about what can be returned when the response is flattened (which is required by architect).

A couple of other things:
I modified your posts to use the </> button on your configuration examples instead of the double quotes in order to improve how they are rendered.
Second, there is a built in "Data Table Lookup" action in architect, that I assume isn't meeting your needs. Please post your use case to Genesys Cloud Ideas Portal so that your needs can ideally be met by built-in architect capabilities.

--Jason

1 Like

Thanks Jason, will give this a try and get back to you on the use case.

Edit:

Getting the data as expected now:

The use case we are looking for here is to 'load' all the 'prompts' from the Datatable in one go to then be able to use the values in the flow for TTS responses and not needing to call Datatable lookup multiple times through the flow.
With this solution customers can update the text on a datatable and not need to have "technical" knowledge or access to architect to update TTS prompts.

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