IBM Developer

Tutorial

Build a software procurement agent with watsonx Orchestrate

Integrate ServiceNow with watsonx Orchestrate to automate software procurement using AI agents and agentic workflows

By Nidhi Jain, Dhara Bagadia

AI-powered agents can transform how enterprises handle software procurement. In this tutorial, you integrate ServiceNow with watsonx Orchestrate to build an intelligent procurement agent that accepts natural language queries and retrieves software inventory data from ServiceNow, your system of record.

The solution bridges unstructured user requests and structured enterprise data using prompt engineering and custom Python tools inside an agentic workflow. You will learn how to:

  • Set up a ServiceNow Personal Developer Instance (PDI) with a software catalog
  • Create a watsonx Orchestrate agent and custom Python tools
  • Build an agentic workflow to automate Non-Standard Software Requests (NSRs)

Prerequisites

  • Python 3.8+
  • The rapidfuzz Python library
  • A trial instance of watsonx Orchestrate SaaS on IBM Cloud
  • A running local environment of the watsonx Agent Development Kit (ADK). If you do not have an active ADK instance, review the getting started with ADK tutorial. This tutorial has been tested and validated with ADK version 2.0.

Solution architecture

The solution is built around a main parent agent called the Software Procurement Advisor, which orchestrates the following tools:

  • get_software_details (custom Python tool)
  • recommend_software_by_functionality (custom Python tool)
  • Non-Standard Software Request (NSR) Workflow (agentic workflow tool)

    • CreateNSRServiceNowRequest (custom Python tool)

Architecture diagram showing the Software Procurement Advisor agent and its connected tools

Step 1. Set up ServiceNow Personal Developer Instance (PDI)

  1. Get a ServiceNow Personal Developer Instance (PDI) following these instructions in the ServiceNow PDI setup documentation.

  2. Create a catalog following these instructions in the ServiceNow Service Catalog builder documentation. Essentially, from the All menu, search for "Maintain catalogs" and click the New button.

    ServiceNow All menu with "Maintain catalogs" search result highlighted

    Then, in the Title field, give the catalog a name, such as "Software catalog ndz", and then click Submit.

    ServiceNow new catalog form with Title field and Submit button

  3. Add items in the catalog. (For more details, see the Service Catalog API documentation and the CatItem API reference documentation, which uses JavaScript in its examples, whereas this tutorial uses Python.) In this tutorial example, you need to add the following 3 custom Translated Text columns to the sc_cat_item table in addition to the default columns, name, price, description:

    • Installation link (u_installation_link)
    • Meta Data (u_meta_data)
    • Software Disposition (u_software_disposition)

      Then, download the software_data.json file, which defines the catalog items for this tutorial.

      Next, load the JSON and set your ServiceNow instance credentials:

      import json, requests
      from requests.auth import HTTPBasicAuth
      
      with open("software_data.json") as f:
        software_list = json.load(f)
      
      # Find sys_ids in the URL of each record
      instance = "https://<your-instance>.service-now.com"
      catalog_sys_id = "<your-catalog-sysid>"
      category_sys_id = "<your-category-sysid>"
      username, password = "<username>", "<password>"
      
      url = f"{instance}/api/now/table/sc_cat_item"
      headers = {"Content-Type": "application/json", "Accept":     "application/json"}
      

      Finally, bulk upload the items from the JSON file:

      for software in software_list:
          payload = {
            "name": software["name"],
            "short_description": software["short_description"],
            "description": software["description"],
            "sc_catalogs": catalog_sys_id,
            "category": category_sys_id,
            "active": "true",
            "price": software["price"],
            "u_installation_link": software["u_installation_link"],
            "u_meta_data": software["u_meta_data"],
            "u_software_disposition": software["u_software_disposition"]
         }
        response = requests.post(url, auth=HTTPBasicAuth(username,   password), headers=headers, json=payload)
          print(f"✅ Created: {software['name']}" if response.status_code == 201 else f"❌ Failed: {software['name']} — {response.status_code}")
      

      The items appear in the "Software catalog ndz" catalog.

      Screenshot of the ServiceNow software catalog after bulk upload

  4. Create another catalog item in the "Software catalog ndz" catalog named "NSR Request", which handles the requests that users raise. (For more details on how to create catalog items, see the ServiceNow Service Catalog item definition documentation.) Then, open the NSR Request item and scroll down and click the Variables tab in the related lists section.

    ServiceNow NSR Request item Variables tab in the related lists section

    Add the following variables individually, adding the following details for each variable. Click Submit after each variable.

    • Type: Select Box, Question: What is the urgency?
    • Type: Date, Question: Approx date till you want to have the software?
    • Type: Select Box, Question: Which type of subscription you want?
    • Type: Select Box, Question: Hardware Required?
    • Type: Numeric Scale, Question: How many users would be using the instance?
    • Type: Single Line Text, Question: What features do you absolutely need?
    • Type: Single Line Text, Question: What is the software website URL?
    • Type: Single Line Text, Question: What is the software name?

      ServiceNow Variables tab showing the list of NSR request variable questions

  5. Create a new request flow named "NSR software procurement" in the Flow Designer. (For more details, see the Building flows documentation.) Set the trigger as "Service Catalog" and the catalog item as "NSR Request." Under Actions, add the Create Catalog Task on Request Item action, and set Request Item [Requested Item] to Trigger → Service Catalog → Requested Item Record.

    Screenshot of the NSR software procurement flow in ServiceNow Flow Designer

    Click Save > Activate

  6. Link the "NSR software procurement" flow to the "NSR Request" item using the Process Engine. Open the NSR Request item and scroll down and click the Process Engine tab in the related lists section. Add the "NSR software procurement" flow in the Flow section. (For more details, see the Build workflows documentation.)

    Screenshot of the NSR Request item Process Engine tab in ServiceNow

Step 2. Connect to ServiceNow in watsonx Orchestrate

  1. Clone the repository:

     git clone https://github.com/IBM/software_procurement_advisor.git
    
  2. Create one import.sh script and paste the following code to set up a connection to ServiceNow in watsonx Orchestrate. This script creates the connection named ServiceNow_Auth, configures both draft and live environments, and sets the ServiceNow credentials.

    Update this script and replace <servicenow_username> and <servicenow_password> with your ServiceNow PDI credentials.

       # Create connection
       orchestrate connections add -a ServiceNow_Auth
    
       # Configure Draft Environment
       orchestrate connections configure -a ServiceNow_Auth --env draft --kind basic --type team
    
       # Set Draft Credentials
       orchestrate connections set-credentials -a ServiceNow_Auth --env draft -u <servicenow_username> -p <servicenow_password>
    
       # Configure Live Environment
       orchestrate connections configure -a ServiceNow_Auth --env live --kind basic --type team
    
       # Set Live Credentials
       orchestrate connections set-credentia -a ServiceNow_Auth --env live -u <servicenow_username> -p <servicenow_password>
    
       # Verify Connections
       orchestrate connections list
    

    ```

  3. After you activate the watsonx Orchestrate environment locally, run the import.sh script.

    To run the import.sh script, issue these commands:

     cd /path/to/software_procurement_advisor
     bash ../import.sh
    

Step 3. Create the Software Procurement Advisor agent

  1. Launch watsonx Orchestrate. From the left navigation, click Build. Then, click Create agent. For more details, see the Creating and customizing agents guide.

    Screenshot of the watsonx Orchestrate Agent Builder home screen

  2. Select Create from scratch.

  3. Give the agent a name and provide a description of it.

  4. Click the Create button.

    Screenshot of the Create Agent dialog with Name and Description fields

  5. Open the agent, scroll down to the Behavior section, and copy and paste the Software Procurement Advisor behavior prompt in this section.

Step 4. Import the tools into watsonx Orchestrate

The Software Procurement Advisor agent uses these tools:

  • get_software_details tool, which validates that the software exists in the ServiceNow catalog and retrieves comprehensive details with intelligent name matching. View get_software_details.py on GitHub.

  • recommend_software_by_functionality tool, which discovers and recommends approved software based on a user's functional requirements and use cases. View get_software_recommendations.py on GitHub.

  • CreateNSRServiceNowRequest tool, which automates the creation of Non-Standard Software Requests (NSR) in ServiceNow for unapproved software. (This tool will be integrated inside the agentic workflow for raising Non-Standard Software Requests.) View service_now_request_creation_new.py on GitHub

Update the import.sh script that you created earlier and paste the following code. This script imports all the tools and the agent into watsonx Orchestrate. Update the file paths if your directory structure differs before running this script.

# Import Software Details Tool
orchestrate tools import -k python -f tools/get_software_details/get_software_details.py -p tools/get_software_details --app-id ServiceNow_Auth

# Import Software Recommendation Tool
orchestrate tools import -k python -f tools/recommend_software_by_functionality/get_software_recommendations.py -p tools/recommend_software_by_functionality --app-id ServiceNow_Auth

# Import NSR ServiceNow Request Tool
orchestrate tools import -k python -f tools/CreateNSRServiceNowRequest/service_now_request_creation_new.py -p tools/CreateNSRServiceNowRequest --app-id ServiceNow_Auth

To run the import.sh script, issue these commands:

cd /path/to/software_procurement_advisor
bash ../import.sh

Step 5. Create the agentic workflow in watsonx Orchestrate

Agentic workflows are deterministic processes that execute a predefined sequence of steps, ensuring consistent, predictable, and repeatable outcomes. This structured approach guarantees that each stage of the workflow is carried out reliably and in the intended order.

This workflow demonstrates how Non-Standard Software Requests (NSRs) are managed. When a requested software application is not part of the approved software catalog, the workflow automatically initiates a request in ServiceNow for the necessary review and approval process. The workflow leverages a custom Python tool CreateNSRServiceNowRequest Tool that connects with ServiceNow to create and manage these requests.

To import the workflow, download the NSR_workflow_1418uw.json file from the software_procurement_advisor GitHub repository and run the following command:

orchestrate tools import -k flow -f <file-path>

The following screen capture shows what the complete flow looks like.

Diagram of the complete NSR Agentic Workflow in watsonx Orchestrate

Step 6. Test the Software Procurement Advisor agent

Open the chat interface for the agent, and try the following prompts to test the agent:

  • I need to order Docker
  • I want to order a software -> Microsoft Teams
  • Software for team collaboration
  • I need to order non standard software -> Creativity

The following animated GIF shows the flow and output of the agent and the NSR agentic workflow.

Demo showing the Software Procurement Advisor agent handling both a standard software query and an NSR submission

Summary

In this tutorial, you learned how to build an AI-powered Software Procurement agent by integrating watsonx Orchestrate with ServiceNow. The solution enables intelligent query resolution through natural language processing, allowing users to discover and retrieve software information from enterprise systems seamlessly.

You learned how to use prompt engineering, custom tool development, and agentic workflows to streamline software procurement operations.

Acknowledgment

The author thanks Michelle Corbin for her editorial guidance and support, which significantly enhanced the clarity and quality of this tutorial.