In watsonx Asisstant actions how can I get a list of ID's and titles through the API

53 Views Asked by At

I want to be able to pull the ID and title of each action contained within the assistant using the API. How can I do this?

1

There are 1 best solutions below

0
Simon O'Doherty On BEST ANSWER

The API does not directly have this feature. You will need to download the skill using the export skills API.

Then with the action json you can read the workspace.actions[] objects for the action (id) and title attributes.

The following is sample python code to show the values:

import json

with open('example-action.json') as file:
    skill = json.load(file)

workspace = skill.get('workspace', {})
actions = workspace.get('actions', [])

for action in actions:
    id = action.get('action', '')
    title = action.get('title', '')

    print(f'{id} : {title}')