Tutorial: Creating the Empower agent on Agent builder
The following step-by-step guides you through setting the watsonx Orchestrate Agent builder, creating an agent, adding tools, and other agent to collaborate with your agent on accomplishing tasks.
Before you start to follow this tutorial, you must set up your IBM watsonx Orchestrate ADK environment, where you build agents and tools. It also provides a convenient interface for managing credentials, sending requests, and handling responses from the service’s APIs. See the Installing the watsonx Orchestrate ADK and Installing the watsonx Orchestrate Developer Edition.
This tutorial is based on a scenario called Empower: An agent for employee success. The goal is to create an agent with a key role in assisting employees by answering their questions, providing guidance on supporting tickets, service issues, and referencing FAQs stored in Sharepoint. The following sections walk you through the complete agent building process, from defining the name and description until the deployment process and the agent’s usage on watsonx Orchestrate chat.
After setting up the ADK and starting your local orchestrate server, you need to import the ServiceNow and Customer care examples, both agent and tools, once they are used to create the Empower agent. The following sections make available the files that are needed to build the ServiceNow and Customer care examples, and how to install them.
The following section guides you to create the Customer care and ServiceNow agents.
Create a folder to structure your agents and tools. For instance, name this folder as agents.
In the new folder, create a YAML file with a text editor of your preference. Name the file as customer_care_agent.
Insert the following code into the customer_care_agent.yaml file.
Copy
spec_version: v1style: reactname: customer_care_agentllm: watsonx/meta-llama/llama-3-2-90b-vision-instructdescription: >You are an agent who specializes in customer care for a large healthcare institution. You should be compassionateto the user.You are able to answer questions around benefits provided by different plans, the status of a claim,and are able to help direct people to the nearest provider for a particular ailment.instructions: >Use the search_healthcare_providers tool to search for providers. If more than 1 is returned format as a githubformatted markdown table. Otherwise simply return the output in a kind conversational tone. Do not expand speciality acronyms.Use the get_healthcare_benefits tool to fetch the benefits coverage for a particular ailment, or for generic plancomparisons. Respond to get_healthcare_benefits requests in a github style formatted markdown table. Be specific aboutthe expected coverage type if a particular condition is mentioned.Use the get_my_claims tool to fetch your open medical claims. Make sure to respond in a direct tone anddo not negotiate prices. Format the output of get_my_claims as a github style markdown table.collaborators:- service_now_agenttools:- search_healthcare_providers- get_healthcare_benefits- get_my_claims
Save your file.
Create another YAML file, but name it as service_now_agent.
Insert the following code into the service_now_agent.yaml file.
Copy
spec_version: v1style: reactname: service_now_agentllm: watsonx/meta-llama/llama-3-2-90b-vision-instructdescription: >You are an agent who specializes in customer care for a large healthcare institution. You should be compassionateto the user.You are able to help help a user create tickets in service now for processing by a human later. Examples of when to dodo this include for adding members to plans or helping users with documentation.instructions: >If a user is having difficulty either generating benefits documents or adding additional members to their plan,create a new incident for our support team using service_now_create_incident tool. Be compassionate about the userfacing difficulty.The output of get_service_now_incidents should be formatted as a github style formatted markdown table.collaborators: []tools:- create_service_now_incident- get_my_service_now_incidents- get_service_now_incident_by_number
Save your file.
Up until here, you created the agents that are needed for Customer care and ServiceNow examples.
The following section guides you to create the tools for Customer care example.
Create a new folder to insert the tools of your examples. For instance, name this folder as tools.
In the new folder, create another one to insert the customer care tools. Name this folder as customer_care.
In the customer_care folder, create a Python file with a text editor of your preference. Name the file as get_healthcare_benefits.
Insert the following code into the get_healthcare_benefits.py file.
[Python]
Copy
from enum import Enumfrom ibm_watsonx_orchestrate.agent_builder.tools import tool, ToolPermissionimport requestsclass Plan(str, Enum): HDHP = 'HDHP' HDHP_Plus = 'HDHP Plus' PPO = 'PPO'@tooldef get_healthcare_benefits(plan: Plan, in_network: bool = None): """ Retrieve a comprehensive list of health benefits data, organized by coverage type and plan variant. This data outlines details such as annual deductibles, out-of-pocket maximums, and various co-pays or percentages for medical services under different network plans (HDHP, HDHP Plus, and PPO). :param plan: Which plan the user is currently on, can be one of "HDHP", "HDHP Plus", or "PPO". If not provided all plans will be returned. :param in_network: Whether the user wants coverage for in network or out of network. If not provided both will be returned. :returns: A list of dictionaries, where each dictionary contains: - 'Coverage': A description of the coverage type (e.g., 'Preventive Services') - 'HDHP (In-Network)': The cost/percentage coverage for an in-network HDHP plan - 'HDHP (Out-of-Network)': The cost/percentage coverage for an out-of-network HDHP plan - 'HDHP Plus (In-Network)': The cost/percentage coverage for an in-network HDHP Plus plan - 'HDHP Plus (Out-of-Network)': The cost/percentage coverage for an out-of-network HDHP Plus plan - 'PPO (In-Network)': The cost/percentage coverage for an in-network PPO plan - 'PPO (Out-of-Network)': The cost/percentage coverage for an out-of-network PPO plan """ resp = requests.get( 'https://get-benefits-data.1sqnxi8zv3dh.us-east.codeengine.appdomain.cloud/', params={ 'plan': plan, 'in_network': in_network } ) resp.raise_for_status() return resp.json()['benefits']
Save your file.
In the same folder, create another Python file and name it as get_my_claims.
Insert the following code into the get_my_claims.py file.
[Python]
Copy
from ibm_watsonx_orchestrate.agent_builder.tools import tool@tooldef get_my_claims(): """ Retrieve detailed information about submitted claims including claim status, submission and processing dates, amounts claimed and approved, provider information, and services included in the claims. :returns: A list of dictionaries, each containing details about a specific claim: - 'claimId': Unique identifier for the claim - 'submittedDate': Date when the claim was submitted - 'claimStatus': Current status of the claim (e.g., 'Processed', 'Pending', 'Rejected') - 'processedDate': Date when the claim was processed (null if not processed yet) - 'amountClaimed': Total amount claimed - 'amountApproved': Amount approved for reimbursement (null if pending, 0 if rejected) - 'rejectionReason': Reason for rejection if applicable (only present if claimStatus is 'Rejected') - 'provider': Provider details, either as a simple string or a dictionary with detailed provider information - 'services': List of services included in the claim, each with: - 'serviceId': Identifier for the service - 'description': Description of the service provided - 'dateOfService': Date the service was provided - 'amount': Amount charged for the service """ claims_data = [ { "claimId": "CLM1234567", "claimStatus": "Processed", "amountClaimed": 150.00, "amountApproved": 120.00, "provider": { "name": "Healthcare Clinic ABC", "providerId": "PRV001234", "providerType": "Clinic" }, "services": [ {"serviceId": "SVC001", "description": "General Consultation", "dateOfService": "2025-02-28", "amount": 100.00}, {"serviceId": "SVC002", "description": "Blood Test", "dateOfService": "2025-02-28", "amount": 50.00} ] }, { "claimId": "CLM7654321", "claimStatus": "Pending", "amountClaimed": 300.00, "amountApproved": None, "provider": "City Health Hospital", "services": [ {"serviceId": "SVC003", "description": "X-ray Imaging", "dateOfService": "2025-02-14", "amount": 300.00} ] }, { "claimId": "CLM9876543", "claimStatus": "Rejected", "amountClaimed": 200.00, "amountApproved": 0.00, "rejectionReason": "Service not covered by policy", "provider": "Downtown Diagnostics", "services": [ {"serviceId": "SVC003", "description": "MRI Scan", "dateOfService": "2025-02-05", "amount": 200.00} ] } ] return claims_data
Save your file.
In the same folder, create another Python file and name it as search_healthcare_providers.
Insert the following code into the search_healthcare_providers.py file.
[Python]
Copy
from typing import Listimport requestsfrom pydantic import BaseModel, Fieldfrom enum import Enumfrom ibm_watsonx_orchestrate.agent_builder.tools import tool, ToolPermissionclass ContactInformation(BaseModel): phone: str email: strclass HealthcareSpeciality(str, Enum): GENERAL_MEDICINE = 'General Medicine' CARDIOLOGY = 'Cardiology' PEDIATRICS = 'Pediatrics' ORTHOPEDICS = 'Orthopedics' ENT = 'Ear, Nose and Throat' MULTI_SPECIALTY = 'Multi-specialty'class HealthcareProvider(BaseModel): provider_id: str = Field(None, description="The unique identifier of the provider") name: str = Field(None, description="The providers name") provider_type: str = Field(None, description="Type of provider, (e.g. Hospital, Clinic, Individual Practitioner)") specialty: HealthcareSpeciality = Field(None, description="Medical speciality, if applicable") address: str = Field(None, description="The address of the provider") contact: ContactInformation = Field(None, description="The contact information of the provider")@tooldef search_healthcare_providers( location: str, specialty: HealthcareSpeciality = HealthcareSpeciality.GENERAL_MEDICINE) -> List[HealthcareProvider]: """ Retrieve a list of the nearest healthcare providers based on location and optional specialty. Infer the speciality of the location from the request. :param location: Geographic location to search providers in (city, state, zip code, etc.) :param specialty: (Optional) Medical specialty to filter providers by (Must be one of: "ENT", "General Medicine", "Cardiology", "Pediatrics", "Orthopedics", "Multi-specialty") :returns: A list of healthcare providers near a particular location for a given speciality """ resp = requests.get( 'https://find-provider.1sqnxi8zv3dh.us-east.codeengine.appdomain.cloud', params={ 'location': location, 'speciality': specialty } ) resp.raise_for_status() return resp.json()['providers']
Up until here, you created the tools for the customer care example.
This section shows how to define the name and description of your agent. This step gives your agent a clear purpose and helps guide how it interacts with users.
From the watsonx Orchestrate chat page, click Manage agents.
Click Create agent.
Choose Create from Scratch.
In the Name field, insert Empower and in the Description, insert a text as you prefer to describe the agent. Suggestion: “This agent’s role is to assist employees by answering their questions, providing guidance on supporting tickets, service issues, and referencing FAQs stored in Sharepoint”.