Assistant Custom Extension

This section will describe how we were able to query one watsonx assistant from another using the watsonx assistant API. In addition, this guide will also include information about how to update session variables on the subordinate bot from the calling bot. Ways to integrate with a subordinate watsonx assisant bot:

  1. Assistant Custom Extension

Assistant Custom Extension

Generate API Key

  1. Navigate to the subordinate bot instance
  2. In the sidebar, navigate to “Assistant Settings”
  3. Under “Assistant IDs and API details”, select “Generate API key” and save it for later

Identify OpenAPI spec values

Two values will be needed to connect to a subordinate Assistant: * service instance url * environmentID

  1. Within the Assistant Builder’s sidebar, navigate to the “Assistant Settings”
  2. Under “Assistant IDs and API details”, select “View details”
  3. Save/copy the values for:
    • service instance URL
    • Draft/Live Environment ID (whichever is applicable)

Create the Custom Extension

  1. Navigate and download the OpenAPI spec for another assistant bot here
  2. Modify the server url at line 10 with the service instance url from step 3 here
  3. Navigate to the integrations section within the Assistant Builder sidebar
  4. Select “Build custom extension” and name the extension
  5. Upload the OpenApi spec from step 1 and press “Finish”
  6. Select “Add+” within the newly configured extension
  7. Select “Next” and update values:
    • Authentication type: Basic auth
    • Username: apikey
    • Password: Password from here

Action Integration

Two api calls are needed to successfully integrate this extension:

  1. Create a session id for the subordinate bot
  2. Make a dialog request to the subordinate bot

Create a session id

  1. Within the appropriate action, create a step and under “And then” select “Use an extension”
  2. Select the appropriate subordinate bot extension made here
  3. Select the Operation as “Create Session”
  4. Set the Parameters to:
Tip

Make sure the “environment_id” variable type is ‘text’

Make a dialog request

  1. Create a new step after the action with the “create a session” extension
  2. Under the “And then” Section, select “Use an extension”
  3. Select the appropriate subordinate bot extension made here
  4. Select the Operation as “Make dialog request”
  5. Set the Parameters to:
    • input.text: input.text
    • input.message_type: text
    • useContext.skills.actions skill.skill_variables : {"DEFINED_VARIABLE" : "VARIABLE_VALUE"}
    • session_id: [session_id from previous step w/ “Create Session” call]
    • environment_id: Environment ID from step 3 of Identify OpenAPI spec values
A note about session variables

Session variables play a crucial role in storing and managing information within and across watsonx Assistant actions. These variables can be defined either by the user or automatically by the assistant, with each session maintaining a distinct instance of each variable.

When there is a need to pass additional information beyond the input query to a subordinate bot, session variables are the appropriate mechanism. To facilitate this, the session variable must first be defined on the subordinate side before its value can be updated via a dialog request. Once defined, the variable can be updated by including its name and the desired value in a JSON object under the useContext.skills.actions.skill.skill_variables field.

This approach ensures smooth communication and data transfer between actions, enabling more dynamic and complex chatbot workflows.