Configuring inputs and outputs types for your skills

Configure inputs and outputs types to give a better experience for users when they use imported skills from OpenAPI specification (OAS).

When you import an OAS file, its operations are converted to skills and their schemas are converted to skill inputs and outputs for the users to provide the data required for the use of the skill. The requestBody and parameters schemas are converted to skills inputs and responseBody schemas are converted to skills output.

This topic covers only the skill inputs and output types configuration. Configurations like show or hide fields can also be made with the x-ibm properties. For more information, see x-ibm properties to configure input, output, and parameter schemas of skills.

Object inputs and outputs

An object is a collection of property and value pairs. With it, you can configure multiple inputs and outputs for your skill by grouping its schemas inside the object.

As watsonx Orchestrate accepts only APIs that uses the application/json content type for the requestBody and responseBody, each schema for requestBody and responseBody is based on an object schema, even if you want to configure only one input or output.

To configure an object input or output, add the type: object property in your skill schema and combine it with the properties property. In the properties property, configure the input or output schemas for your skill.

{
  "type": "object",
  "properties": {
    "id": {
      "type": "integer"
    },
    "name": {
      "type": "string"
    }
  }
}

In your API you might have a complex structure for requests or responses. You can handle this complex structure by adding an object schema inside another object schema. On watsonx Orchestrate each input or output of a complex structure are displayed individually, but if a custom name is not configured with the x-ibm-label property, their names turn the complete structure of your schemas.

{
  "type": "object",
  "properties": {
    "user": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        }
      }
    },
    "admin": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        }
      }
    }
  }
}

Object input and output example
Figure 1: The image shows how an complex object input and output looks like in an form.

Text inputs and outputs

To configure a text input or output use the type: string property inside your input or output schema. You can use text inputs and outputs to configure the strings requests and responses that you have in your API.

{
  "type": "string"
}

Text inputs and outputs can be displayed for users as fields in a form or as turns in a conversation thread when users use the skill. It depends whether the skill is used from the legacy chat or AI chat. For multi-turn conversation in the AI chat, the inputs and outputs must adhere to the criteria defined for it. For more information, see Defining how to interact with a skill in a conversation.

Text input and output example
Figure 2: The image shows how an text input and output looks like.

For the field format, extra configurations can be made to enhance the user experience. These configurations are:

  • Multiline text field

    To configure a multiline text, add the x-ibm-multiline inside your input or output schema and set it to true. For more information about the x-ibm-multiline, see Configuring inputs and outputs as multiline.

    {
      "type": "string",
      "x-ibm-multiline": true
    }
    

    Configure an input or output as a multiline text for cases that your skill requires or returns a long text information. This configuration gives more space for the text in the user interface.

    Multiline text input and output example
    Figure 3: The image shows how a multiline text input and output looks like.

  • Password text field

    To configure a password text, add the format property inside your input or output schema and set it to password.

    {
      "type": "string",
      "format": "password"
    }
    

    Configure input or output as a password for cases that your skill requires or returns a password information. This configuration hides the password data in the user interface.

    Password text input and output example
    Figure 4: The image shows how a password text input and output looks like.

Numeric inputs and outputs

Numeric inputs and outputs can be whether an integer or a floating number, it depends on what type of information the skill needs to receive or returns to the user. Use numeric inputs and outputs for the numeric requests and responses that you have in your API.

To configure an integer input or output add a type: integer property inside your skill schema.

{
  "type": "integer"
}

To configure a float input or output add a type: number property inside your skill schema.

{
  "type": "number"
}

Numeric inputs and outputs can be displayed for a user as fields in a form or as turns in conversation thread when users use the skill. It depends whether the skill is used from the legacy chat or the AI chat. For multi-turn conversation in the AI chat, the inputs and outputs must adhere to the criteria defined for it. For more information, see Defining how to interact with a skill in a conversation.

Numeric input and output example
Figure 5: The image shows how a numeric input and output looks like.

Date inputs and outputs

On watsonx Orchestrate, you can configure date inputs and outputs in three different formats for your users. Theses formats are: date, date and time, EPOCH.

Date

To configure a date input or output combine a type: string property with the format: date property in your input or output schema.

{
  "type": "string",
  "format": "date"
}

The date format is a simple date field where is requested or displayed for the user a year, month, and day of the date.

Date input and output example
Figure 6: The image shows how a date input and output looks like.

Date and time

To configure a date and time input or output, combine a type: string property with the format: date property in your input or output schema.

{
  "type": "string",
  "format": "date-time"
}

The date and time format requests or displays for the user a year, month, day, hour, minute, period, and time zone of the date.

Date input and output example
Figure 7: The image shows how a date and time input and output looks like.

EPOCH

You can use type: string or type: integer properties with the format: epoch property to configure dates in EPOCH format.

{
  "type": "integer",
  "format": "epoch"
}

When an EPOCH date is configured, for an input it is displayed for the user as a text or numeric input field. In the other hand, for outputs the EPOCH date is displayed in a human readable format. It follows the structure: YYYY-MM-DD.

EPOCH input and output example
Figure 8: The image shows how a EPOCH input and output looks like.

Note: When you configure an output as EPOCH format, the date is displayed in a human readable format. However, the value continues in the EPOCH format if you use that date output as input for another skill in skill flows or skill sequencing.

Checkbox inputs and outputs

To configure a checkbox input and output, add the type: boolean property inside your skill schema. Use the checkbox input and output to configure the boolean values that you have in your API.

{
  "type": "boolean"
}

For the checkbox created for the users, marked means true and unmarked means false.

Checkbox input and output example
Figure 9: The image shows how a checkbox input and output looks like.

Collection inputs and outputs

A collection input and output is a data structure type when more than one information can be added in just one input or output field.

To configure a collection, add the type: array property in your skill schema and configure the input or output schema that needs to be structured in the collection. Use a collection inputs and outputs to configure the arrays that you have in your API.

{
  "type": "array",
  "items": {
    "type": "string"
  }
}

As an input field, a collection enables users to pass more than one information of the same type in it by clicking the Add + button. As an output field, a collection shows to users all returned information from the API of the same information.

Collection input and output example
Figure 10: The image shows how a collection input and output looks like.

Note: In arrays, you can use the oneOf property to create mixed-type arrays, minItems and maxItems properties to define the minimum and maximum length of the array, and uniqueItems to specify that all items in the array must be unique.

Table inputs and outputs

A table input and output is a complex data structure based on an array of objects. When you add this structure in the input or output of your skill schema, it is automatically converted to a table on watsonx Orchestrate.

To configure a table, add the type: array property in your skill schema and then in the items property, configure an object schema to create a table.

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "id": {
        "type": "integer"
      },
      "name": {
        "type": "string"
      },
      "age": {
        "type": "integer"
      }
    }
  }
}

On watsonx Orchestrate, each schema that is configured inside the object is converted to a column in the table.

Table input and output example
Figure 11: The image shows how a table input and output looks like.

Queryable parameters inputs

A queryable parameter connects multiple information in just one parameter; you can configure queryable parameters for watsonx Orchestrate using the x-ibm-queryable-fields property.

On watsonx Orchestrate, a queryable parameter is displayed as a filter input parameter.

Queryable parameter input example
Figure 12: The image shows how a queryable parameter input looks like.

To configure the x-ibm-queryable-fields property, add the property to the parameter object; it converts the input parameter in one queryable parameter field.

Then, in the x-ibm-queryable-fields property configure:

Property Description
type The type of the queryable parameter. It must be object.
properties The schema of the elements that presents on the queryable parameter. In that schema, configure the following objects:
  • type: The type of the element.
  • description: The description of the element.
  • title: The name of the element.
  • x-ibm-supported-operators: A list of the operators supported by the element in the queryable parameter. For more information about operators, see Configuring operators of elements in queryable parameters.

The following example shows how to configure the x-ibm-queryable-fields property.

{
  "parameters": [
    {
      "name": "filter",
      "in": "query",
      "schema": {
        "type": "string"
      },
      "x-ibm-queryable-fields": {
        "type": "object",
        "properties": {
          "id": {
            "type": "number",
            "description": "The unique user identifier",
            "title": "ID",
            "x-ibm-supported-operators": {
              "and": [
                "eq"
              ]
            }
          },
          "name": {
            "type": "string",
            "description": "The name of the user",
            "title": "Name",
            "x-ibm-supported-operators": {
              "and": [
                "eq"
              ]
            }
          }
        }
      }
    }
  ]
}

Configuring operators of elements in queryable parameters

Use the x-ibm-supported-operators property to configure the operators of an element in a queryable parameter.

To configure the x-ibm-supported-operators property, add the property inside the schema of the queryable parameter. Then, in the property configure a list with of operations the element supports.

On watsonx Orchestrate, only the equivalence operator is supported. Therefore, configure the and list and then use eq to configure the equivalence operation.

The following example shows how to configure the x-ibm-supported-operators property:

{
  "parameters": [
    {
      "x-ibm-queryable-fields": {
        "properties": {
          "id": {
            "x-ibm-supported-operators": {
              "and": [
                "eq"
              ]
            }
          }
        }
      }
    }
  ]
}

List of options inputs

A list of options gives the user a previously configured list of possible inputs for an input field. On watsonx Orchestrate, a list of options can be either fixed or dynamically generated.

A list of options as inputs can be displayed to a user as fields in a form or as turns in a conversation thread when the users use the skill. It depends whether the skill is used from the legacy chat or the AI chat. For a multi-turn conversation in the AI chat, the inputs and outputs must adhere to the criteria defined for it. For more information, see Defining how to interact with a skill in a conversation.

List of options input example
Figure 13: The image shows how a list of options input looks like.

Fixed list of options

A fixed list of options is the one that you as a developer, previously configured for the user.

You can configure the values of the list of options directly in the OAS file. To do it, configure an enum list in the OAS file.

To configure a fixed list of options, add the enum list in the input schema and then list all possible input options. The options that are listed in that enum list need to be in the same type of the input schema. For example, whether or input is a string all values that are listed in that list need to be a string type.

{
  "type": "string",
  "enum": [
    "A",
    "B",
    "C"
  ]
}

Dynamic list of options

A dynamic list of options is generated automatically in a dynamic form based on the output of other skills. You configure a dynamic list of options with the x-ibm-ui-extension.

To use the x-ibm-ui-extension property, add the property in the skill input schema and then configure:

Property Required Description
component Yes The field type, must be dropdown.
pagination Optional Define the skip and limit in the list of options.
  • For skip, set the interval to skip items in the list of options.
  • For limit, set the limit of items in the list of options.
actions Yes Define the skill_id, type, mappings, and params of the skill that you want to pull data to the list of options.

The following example shows how to use the x-ibm-ui-extension property to create a list of options with dynamic values from other skills.

{
  "x-ibm-ui-extension": {
    "component": "dropdown",
    "actions": [
      {
        "skill_id": "<skill_id>",
        "type": "data",
        "mappings": {
          "labels": "<link_to_object_property_name>",
          "values": "<link_to_object_property_name>"
        },
        "params": {}
      }
    ]
  }
}

Mapping items for list of options

In the mappings specify the values and labels, it defines how the data gathered from a specific skill can populate a list of options:

Property Required Description
values Yes The value that the field receives when the user selects it from the drop-down.
labels Optional The values displayed in the drop-down list for the users. You can use this resource in cases where values are not simple to understand for the user, for example
If your values link to an object that returns language codes, you can use labels to link to an object that returns the language names. Therefore, the language names are displayed in the drop-down while the values received to the input are the language code.

To map the values and labels properties, create a link to the output object that populates the list of values. The link is based on the hierarchy of object properties in the response schema.

You can create a link for simple objects, complex objects, or arrays at the root level. The structure of these links might vary based on how an object is built. The following are examples of these structures:

Link to a simple object:

<object_property_name>

Link to a simple object with multiple properties:

<object_property_name>.properties.<object_property_name>

Link to a complex object that nest an array:

<object_property_name>.items

Link to a complex object that nest an array of objects

<object_property_name>.items.properties.<object_property_name>

Link to an array at the root level

items.properties.<object_property_name>
Note: For complex objects and arrays, you need to specify the mappings section. Otherwise, the mappings section isn't needed.

Mapping inputs of the skill that generate the list of options

If the skill used to generate the list of options has inputs, you can map the inputs by using params. In the params property, you can map a static value or a dynamic value based on other skill input.

To map params with a static value, in the params property add the input from the skill you want to map and set a static value for the input. The following snippet exemplifies a static mapping:

{
  "params": {
    "input": "value"
  }
}

To map params with a dynamic value, in the params property add the input from the skill that you want to map and then map the input that receives the dynamic value by the user when the skill is used. To map that input, use the following properties:

Property Required Description
name Yes The name of the input to be mapped with the input of the skill that generates the list of options. The input can be one input that your skill already has or you can create one input in your skill only for propose.
value Yes The value received from the mapped input. It must be __reference__ to pass the value the user set in the input field.

The following snippet exemplifies a dynamic mapping:

{
  "params": {
    "input": {
      "name": "inputMapped",
      "value": "__reference__"
    }
  }
}

Example:

To examplify the input mapping, suppose the skill that generates the data for the list of options has one input named startWith as shown below:

{
  "paths": {
    "/skill1": {
      "post": {
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "startWith": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Then, to map the startWith input with a static value you must add the input in the params property and set the static value as in the below snippet:

{
  "paths": {
    "/skill2": {
      "post": {
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "usersFilter": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "x-ibm-ui-extension": {
                      "component": "dropdown",
                      "actions": [
                        {
                          "skill_id": "app_id__1.0.0__skill1",
                          "type": "data",
                          "mappings": {
                            "labels": "user.items.properties.name",
                            "values": "user.items.properties.id"
                          },
                          "params": {
                            "startWith": "J"
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Or, to map the startWith input with a dynamic value, you need to add this input in the params property and configure the name property with one of the skill inputs and the value property as __reference__:

{
  "paths": {
    "/skill2": {
      "post": {
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "usersFilter": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "x-ibm-ui-extension": {
                      "component": "dropdown",
                      "actions": [
                        {
                          "skill_id": "app_id__1.0.0__skill1",
                          "type": "data",
                          "mappings": {
                            "labels": "user.items.properties.name",
                            "values": "user.items.properties.id"
                          },
                          "params": {
                            "startWith": {
                              "name": "usersFilter",
                              "value": "__reference__"
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

File inputs

A file input enables users to upload files as skill inputs. Once a file is uploaded, it is converted to Base64 and passed to the API as a string.

Files inputs can be configured in two different forms: as a single file or as multiple files.

Single file

To create a single file input, combine the type: "string" and format: binary properties in your skill schema.

{
  "type": "string",
  "format": "binary"
}

This configuration presents a file upload widget to the user as skill input. It accepts a single file and sends a JSON payload to the API with the content of the uploaded file as a base64 encoded string.

Single file input example
Figure 14: The image shows how a single file input looks like.

Multiple files

You can create a multifile upload widget to allow users to upload any number of files to the API. To do it, configure the single file schema inside an array and object schema.

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "fileName": {
        "type": "string"
      },
      "content": {
        "type": "string",
        "format": "binary"
      }
    }
  }
}

This configuration presents a file upload widget to the user as skill input. It accepts multiple files and sends a JSON payload to the API with the content of the uploaded file as a base64 encoded string.

Multiple files input example
Figure 15: The image shows how a multiple files input looks like.