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:
Assistant Custom Extension
Generate API Key
- Navigate to the subordinate bot instance
- In the sidebar, navigate to “Assistant Settings”
- 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
- Within the Assistant Builder’s sidebar, navigate to the “Assistant Settings”
- Under “Assistant IDs and API details”, select “View details”
- Save/copy the values for:
service instance URL
Draft/Live Environment ID
(whichever is applicable)
Create the Custom Extension
- Navigate and download the OpenAPI spec for another assistant bot here
- Modify the server url at line 10 with the
service instance url
from step 3 here - Navigate to the integrations section within the Assistant Builder sidebar
- Select “Build custom extension” and name the extension
- Upload the OpenApi spec from step 1 and press “Finish”
- Select “Add+” within the newly configured extension
- 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:
Create a session id
- Within the appropriate action, create a step and under “And then” select “Use an extension”
- Select the appropriate subordinate bot extension made here
- Select the Operation as “Create Session”
- Set the Parameters to:
- environment_id: Environment ID from step 3 of Identify OpenAPI spec values
Make sure the “environment_id” variable type is ‘text’
Make a dialog request
- Create a new step after the action with the “create a session” extension
- Under the “And then” Section, select “Use an extension”
- Select the appropriate subordinate bot extension made here
- Select the Operation as “Make dialog request”
- 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
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.