|
| 1 | +# ServiceNow ↔ OpenAI ChatGPT Integration |
| 2 | +**Connect ServiceNow with ChatGPT using REST Message and Business Rule** |
| 3 | + |
| 4 | +--- |
| 5 | + |
| 6 | +## Overview |
| 7 | +This project demonstrates how to integrate **ServiceNow** directly with **OpenAI’s ChatGPT** platform using only native features - |
| 8 | +no Scripted REST APIs, no IntegrationHub, and no plugins required. |
| 9 | + |
| 10 | +The integration leverages: |
| 11 | +- A **REST Message** (calling OpenAI’s API endpoint) |
| 12 | +- A **Business Rule** (triggering automatically on record updates) |
| 13 | + |
| 14 | +Once configured, ServiceNow can send ticket details (like short descriptions or work notes) to ChatGPT |
| 15 | +and store AI-generated responses back in the record — such as incident summaries, resolution hints, or category suggestions. |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## Key Highlights |
| 20 | + |
| 21 | +100% Native - Uses **RESTMessageV2** and **Business Rule** only |
| 22 | +Generates AI-based summaries, causes, or recommendations |
| 23 | +Works with **GPT-3.5-Turbo**, **GPT-4-Turbo**, or **GPT-4o-Mini** models |
| 24 | +Real-time execution after record creation or update |
| 25 | +No external plugin dependencies |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +## Use Case Example |
| 30 | +Whenever a new **Incident** is created or updated, ServiceNow automatically: |
| 31 | +1. Sends the incident’s short description and work notes to **ChatGPT**. |
| 32 | +2. Receives an AI-generated summary or root cause statement. |
| 33 | +3. Saves the response in a custom field (`u_ai_summary`). |
| 34 | + |
| 35 | +This automation reduces manual summarization and speeds up triage. |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## Prerequisites |
| 40 | + |
| 41 | +| Requirement | Description | |
| 42 | +|--------------|-------------| |
| 43 | +| **OpenAI API Key** | Obtain from [https://platform.openai.com](https://platform.openai.com) | |
| 44 | +| **Model** | Any `gpt-4o-mini`, `gpt-4-turbo`, or `gpt-3.5-turbo` | |
| 45 | +| **ServiceNow Role** | admin / developer | |
| 46 | +| **Custom Field** | Add a field `u_ai_summary` (String or HTML) on `incident` table | |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## Step 1 — Create REST Message |
| 51 | + |
| 52 | +**Name:** `OpenAI ChatGPT` |
| 53 | +**Endpoint:** `https://api.openai.com/v1/chat/completions` |
| 54 | +**HTTP Method:** `POST` |
| 55 | + |
| 56 | +### Headers |
| 57 | +| Name | Value | |
| 58 | +|------|--------| |
| 59 | +| Content-Type | application/json | |
| 60 | +| Authorization | Bearer `YOUR_OPENAI_API_KEY` | |
| 61 | + |
| 62 | +### Request Body |
| 63 | +```json |
| 64 | +{ |
| 65 | + "model": "gpt-4o-mini", |
| 66 | + "messages": [ |
| 67 | + { "role": "system", "content": "You are a helpful ITSM assistant." }, |
| 68 | + { "role": "user", "content": "${prompt}" } |
| 69 | + ] |
| 70 | +} |
0 commit comments