Integrating GPT Actions with ServiceNow for Enhanced Workflows

jesjuar
Tera Guru

Integrating GPT Actions with ServiceNow allows users to interact with their instance through a Custom GPT, enabling record creation, updates, and automation using natural language. This approach simplifies workflows, reduces manual effort, and enhances efficiency.

 

https://platform.openai.com/docs/actions/introduction 

 

What Are GPT Actions?

GPT Actions enable a Custom GPT to connect with external systems like ServiceNow via REST API calls. This allows users to retrieve information, create records, and trigger workflows in ServiceNow directly from ChatGPT.

 

Getting Started

This guide provides a step-by-step process for setting up a Custom GPT with ServiceNow. You will need:

  1. A ServiceNow instance (e.g. PDI)
  2. An OpenAI account (with access to create Custom GPTs)

 

Step 1: Configure OAuth in ServiceNow

To allow a Custom GPT to interact with ServiceNow, you can configure OAuth 2.0 authentication in your instance.

  • Navigate to Application Registry

    • Go to System OAuth > Application Registry in ServiceNow

    • Click New and select Create an OAuth API endpoint for external clients

  • Register a New Application

    • Enter a Name (e.g., ActionGPT Integration)

    • Save the record. Client ID and Client Secret will be auto-generated - note them down.

    • Leave the Redirect URL empty for now, we will populate it later from the GPT Action.

    • No scopes need to be defined for testing the integration.

Screenshot 2025-03-14 at 13.53.31.png

 

Step 2: Create a GPT Action

Once ServiceNow is ready, configure a new Action in your Custom GPT to interact with the instance.

  • Create a New Action

    • In the edit view of your custom GPT, scroll down to the “create new action” option and click on it

    • Select OAuth as the authentication

    • Use the Client ID and Client Secret from the ServiceNow registry

    • Use https://[YOUR_PDI].service-now.com/oauth_auth.do as the authorization URL

    • Use https://[YOUR_PDI].service-now.com/oauth_token.do as the token URL

    • Leave the scope empty and the token exchange method as Default

 

Screenshot 2025-03-03 at 17.01.06.png

 

  • Define the API Schema

    • Once you save the authentication details, your GPT Action requires an Open API schema to describe the parameters of the API call, which is a standard for describing APIs.
    • This schema defines the API paths and their request and response structure so the custom GPT knows how to call the API and the format of the response.
    • You can use the official OpenAI custom GPT to help you generate the schema
    • Example of Open API schema:

 

openapi: 3.1.0
info:
  title: ServiceNow Incident API
  description: API to create an incident in ServiceNow using the Table API
  version: 1.0.0
servers:
  - url: https://[YOUR_PDI].service-now.com/api/now
    description: ServiceNow instance
paths:
  /table/incident:
    post:
      operationId: createIncident
      summary: Create a new incident
      description: Inserts a new incident record in ServiceNow and returns the incident number and short description.
      parameters:
        - name: sysparm_fields
          in: query
          description: Comma-separated list of fields to return in the response.
          required: false
          schema:
            type: string
          example: number,short_description
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                short_description:
                  type: string
                  description: Brief summary of the issue.
                description:
                  type: string
                  description: Detailed description of the issue.
                contact_type:
                  type: string
                  description: The type of contact that reported the issue.
                caller_id:
                  type: string
                  description: The email or sys_id identifier of the caller.
                u_affected_user:
                  type: string
                  description: The email or sys_id identifier of the affected user.
              required:
                - short_description
                - description
                - contact_type
                - caller_id
                - u_affected_user
      responses:
        '201':
          description: Incident successfully created
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: object
                    properties:
                      number:
                        type: string
                        description: The incident number.
                      short_description:
                        type: string
                        description: The short description of the issue.
        '400':
          description: Bad request - Invalid input
        '404':
          description: Not found - Invalid endpoint
      security:
        - basicAuth: []
​

 

 

Step 3: Update OAuth Configuration in ServiceNow

  • After saving your GPT Action, return to the custom GPT configuration screen. You will find the callback URL displayed there

  • Copy the callback URL and paste it into the Redirect URL field in your ServiceNow app registry to complete the configuration

 

Step 4: Testing the Integration

  • Click Test in the Custom GPT settings. A pop-up will request permission for the connection. Approve it to proceed.
  • Use Postman or another API tool to validate requests.

 

Optimizing Custom GPT Actions

To ensure effective integration, configure the Custom GPT to invoke actions at the appropriate time.

Example: Incident Creation Custom GPT

 

...
The chatbot attempts to assist the user in resolving their issue with clear guidance.
If the user’s problem remains unresolved or they explicitly request an incident, proceed with incident creation.

Incident Creation Request:
The chatbot must collect the user’s email (mandatory for caller ID and affected user fields)
The chatbot structures the incident request in first-person format (e.g., "My laptop is broken...") 
The chatbot constructs the ServiceNow API request with the following required fields:
contact_type = "self-service"
caller_id = [User Email]
short_description = [User's Issue Summary]
description = [Full User Description]
The chatbot submits the request to ServiceNow.

Confirmation & Follow-up:
The chatbot confirms that the incident has been created and provides the incident number
...

 

1 REPLY 1

KKM
Tera Guru

Hi Jesjuar,

Very neatly articulated about GPT actions to integrate with ServiceNow.

 

With Regards,
Krishna Kumar M - Talk with AIT3ch
LinkedIn: https://www.linkedin.com/in/mkrishnak4/
YouTube: https://www.youtube.com/@KrishAIT3CH
Topmate: https://topmate.io/mkrishnak4 [ Connect for 1-1 Session]