Skip to content

Commit 0f717f0

Browse files
authored
Merge pull request #2970 from hpe-dev-incubator/cms/blog/no-code-integration-of-hpe-greenlake-cloud-with-servicenow
Create Blog “no-code-integration-of-hpe-greenlake-cloud-with-servicenow”
2 parents 436fc21 + f1f0bee commit 0f717f0

9 files changed

+210
-0
lines changed
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
---
2+
title: No-code integration of HPE GreenLake cloud with ServiceNow
3+
date: 2025-03-18T07:49:59.220Z
4+
author: Didier Lalli
5+
authorimage: /img/didier-lalli-192x192.png
6+
disable: false
7+
tags:
8+
- hpe-greenlake-cloud
9+
- webhooks
10+
---
11+
<style>
12+
li {
13+
font-size: 27px;
14+
line-height: 33px;
15+
max-width: none;
16+
}
17+
</style>
18+
19+
In my [previous tutorial](https://developer.hpe.com/blog/getting-started-with-the-hpe-greenlake-cloud-eventing-framework/) on webhooks for HPE GreenLake cloud, I used a no-code/low-code platform called [Make.com](https://www.make.com/) to implement a webhook handler. The webhook handler’s URL endpoint was then registered with HPE GreenLake cloud to subscribe to audit log events from the platform. In my simplistic use case, I stored these events in a Google Sheet as they arrived.
20+
21+
For this handler, I was responsible for taking care of the handshake initiated by HPE GreenLake cloud when the new webhook was registered. This is a security feature that uses a secret key shared by HPE GreenLake cloud and the webhook handler. The following diagram illustrates the mechanics involved in this process.
22+
23+
![HPE Greenlake cloud event framework](/img/slide-pour-blog-webhooks.jpg "HPE Greenlake cloud event framework")
24+
25+
As this implementation was working well, I thought I would reuse this low-code handler technique to demonstrate another use case of an integration with an IT service management (ITSM) platform. I decided to use ServiceNow because it’s a very popular ITSM platform and because it provides a very nice way for developers to fire up a [personal developer instance](https://devportaluat.service-now.com/dev.do#!/learn/learning-plans/washingtondc/new_to_servicenow/app_store_learnv2_buildmyfirstapp_washingtondc_personal_developer_instances) (PDI) and get their work done.
26+
27+
## Problems, incidents and change orders
28+
29+
Most of these ITSM platforms are managed through the lifecycle of different types of tickets (New, In Progress, Resolved). One of the most common ticket types is called *Incident*, which is the type of ticket that users might open when they face an issue and want to raise it to their IT team for resolution. In most cases, end users use a web portal to do this. However, there is also an API to programmatically do it, and this is exactly what I’m going to use in this blog.
30+
31+
## What’s the right API then?
32+
33+
To be fair, I must admit that I initially reached out to ChatGPT to get started, asking it *“how do I create an incident in ServiceNow?”*. To my surprise it returned a short Python script that, once edited to use my ServiceNow personal developer instance, my username and password, worked immediately. This confirmed my choice of selecting ServiceNow.
34+
35+
Here is the Python script returned by ChatGPT:
36+
37+
```python
38+
import requests
39+
import json
40+
# Replace these variables with your own information
41+
instance_url = "https://your-instance.service-now.com"
42+
username = "your-username"
43+
password = "your-password"
44+
service_id = "service-id" # The Service ID related to the incident
45+
46+
# Define the API endpoint for creating an incident
47+
url = f"{instance_url}/api/now/table/incident"
48+
49+
# Create the headers for the request (set the content-type to application/json)
50+
headers = {
51+
"Content-Type": "application/json",
52+
"Accept": "application/json"
53+
}
54+
55+
# Define the data to be sent in the request body
56+
data = {
57+
"short_description": "Issue with email service",
58+
"description": "The email service is down and needs urgent attention.",
59+
"category": "Inquiry",
60+
"impact": "3", # 1=High, 2=Medium, 3=Low (you can adjust accordingly)
61+
"urgency": "2", # 1=High, 2=Medium, 3=Low (you can adjust accordingly)
62+
"service": service_id # The ID of the service being impacted
63+
}
64+
65+
# Make the POST request to create the incident
66+
response = requests.post(url, auth=(username, password), headers=headers, data=json.dumps(data))
67+
68+
# Check the response
69+
if response.status_code == 201:
70+
print(f"Incident created successfully! Incident Number: {response.json()['result']['number']}")
71+
else:
72+
print(f"Failed to create incident. Status Code: {response.status_code}")
73+
print(f"Response: {response.text}")
74+
```
75+
76+
> > **Note**: ServiceNow provides the full documentation for their API once you sign up as a ServiceNow developer and it is free.
77+
78+
The script it provided was very helpful because it helped me understand:
79+
80+
* The API I need to use is the table API and the table name to be used is called incident, thus the API call: POST /api/now/table/incident
81+
* The (minimal) payload I need to pass in the API call
82+
* The necessary headers
83+
* The response code expected if it worked should be 201
84+
85+
## From event to incident
86+
87+
Now that I understand how to create an incident, it would be good to think about what represents an incident within HPE GreenLake cloud. In my [previous tutorial](https://developer.hpe.com/blog/getting-started-with-the-hpe-greenlake-cloud-eventing-framework/), I subscribed to audit log events (workspace loaded by user X, user Y logged out, user Z changed these settings, etc.) but you most likely would not want to open an incident for each of these. First, they are not really incidents, and second, you don’t want to flood your incident table with inappropriate data, as real incidents might get lost. For this use case, I decided to use another event that could be triggered by the **Subscriptions Management** service in HPE GreenLake cloud when a subscription is expiring in 1, 30, 60, and 90 days. The event is called **Expiring Subscriptions**. The full description of this event can be found on the [HPE GreenLake Developer Portal](https://developer.greenlake.hpe.com/docs/greenlake/services/subscription-management/public/catalog/subscriptions-unified-events-glcp-v1/paths/Expiring%20Subscriptions/post/).
88+
89+
This can be considered an incident and could be added in ServiceNow incident table.
90+
91+
The payload sent to the webhook handler when this event is triggered by the Subscriptions Management service has the following format:
92+
93+
```json
94+
{
95+
"specversion": "1.0",
96+
"id": "fb25f344-5e20-4f13-9937-c3ecc0327dc3",
97+
"source": "https://global.api.greenlake.hpe.com/subscriptions",
98+
"type": "com.hpe.greenlake.subscriptions.v1.expiring-subscriptions",
99+
"datacontenttype": "application/json",
100+
"time": "2024-10-30T21:09:16.127443806Z",
101+
"data": {
102+
"key": "OFKIAASTEST168IZ",
103+
"expirydate": "10/25/2024",
104+
"sku": "S0B80AAE",
105+
"licensetier": "ENHANCED PROLIANT",
106+
"quantity": 500,
107+
"username": "John Doe Inc.",
108+
"subscriptionendinsecs": 1729848600,
109+
"subscriptiontype": "Compute Subscription",
110+
"producttype": "DEVICE",
111+
"platformcustomerid": "22e7e552184511ef88e9cacb36fa7032",
112+
"devices": []
113+
}
114+
}
115+
```
116+
117+
Now that I know what my webhook handler will receive as input and how I can open an incident in ServiceNow, I can get started.
118+
119+
## From code to no-code
120+
121+
Let me show you how to translate these learnings in Make.com. In my previous [article](https://developer.hpe.com/blog/getting-started-with-the-hpe-greenlake-cloud-eventing-framework/), I created a scenario in Make.com that looked like this:
122+
123+
![Original scenario in make ](/img/second-route-taken.jpg "Original scenario in make ")
124+
125+
The topmost branch was used to handle the initial security handshake. I will keep that intact. If you need details about this branch, check out my [previous tutorial](https://developer.hpe.com/blog/getting-started-with-the-hpe-greenlake-cloud-eventing-framework/).
126+
127+
What I will do now is duplicate this scenario, delete the Google Sheets module, and replace it with another one called **HTTP Make a request**. Then I will link the new module to the Webhook response.
128+
129+
The HTTP Make a request module allows you to make any type of REST API call. It comes in very handy for integration use cases.
130+
131+
> > **Note**: Make.com also provides a native ServiceNow integration, but you need an Enterprise plan to use it, which I don’t have.
132+
133+
My scenario looks like this:
134+
135+
![New scenario in make](/img/webhook-blog-servicenow-picture-2.jpg "New scenario in make")
136+
137+
My new scenario includes:
138+
139+
* The **Custom webhook** module as a trigger of your webhook scenario with *advanced option* enabled
140+
* The **Set variable** module and the **Webhook response** module to validate the verification challenge and ensure the webhook communication between HPE GreenLake cloud and the webhook handler is authenticated
141+
* A **Router** module in the scenario to branch your flow into several routes and process the data within each route differently, based on the type of event received
142+
* The **HTTP Make a request** module connected to the bottom branch of the Router module along with the **Webhook response** module connected to the HTTP Make a request module to create the incident in ServiceNow and return a 200 status to HPE GreenLake cloud
143+
144+
For more information, you can refer to the chapter *“Getting started with Make”* in my first [blog post](https://developer.hpe.com/blog/getting-started-with-the-hpe-greenlake-cloud-eventing-framework/).
145+
146+
Next, I’ll dive into the properties of the **HTTP Make a request** module that needs to be configured based on the details collected from the Python script:
147+
148+
* The URL endpoint of my ServiceNow instance: *https://{your-instance}/api/now/table/incident*
149+
* Method: *POST*
150+
* Two custom headers for Accept and Content-Type both set to *application/json*
151+
* Body type: *Raw*
152+
153+
![Setting up HTTP Make a request properties - part 1](/img/webhook-blog-servicenow-picture-3.jpg "Setting up HTTP Make a request properties - part 1")
154+
155+
To setup the JSON payload as shown below, I need to first configure the first step of my webhook scenario to use the JSON payload of the **Expiring Subscriptions** event described earlier.
156+
157+
I then need to set up the JSON payload (**Request content** as shown below) with ServiceNow information such as:
158+
159+
* The *short description* (for example, the subscription type is expiring soon)
160+
* The *description* (for example, License <license type> expires on <date>)
161+
* The *category*, and the *subcategory*
162+
* The level of *urgency* (1=high, 2=medium, 3=low) and the level of the *impact* (1=high, 2=medium, 3=low) which will be used to compute *priority* in ServiceNow
163+
* The *caller_id*
164+
* The *service*
165+
166+
Once this is in place, I can build the Request content and drag/drop items from the JSON input payload (shown in red) into the Request content of the HTTP call as shown below:
167+
168+
![Setting up HTTP Make a request properties - part 2](/img/webhook-blog-servicenow-picture-4.jpeg "Setting up HTTP Make a request properties - part 2")
169+
170+
It’s important not to forget to specify username and password obtained when creating a ServiceNow personal developer instance.
171+
172+
## Putting it all together
173+
174+
Voila! Now the Webhook scenario is in place. I need to subscribe to the event with HPE GreenLake cloud. As noted in my first [blog](https://developer.hpe.com/blog/getting-started-with-the-hpe-greenlake-cloud-eventing-framework/) post, I can apply the same logic, except that this time I will subscribe to **Expiring Subscriptions** event as shown below:
175+
176+
![Subscribing to expiring subscriptions](/img/webhook-blog-servicenow-picture-5.jpg "Subscribing to expiring subscriptions")
177+
178+
If everything goes well, I should see the following subscribed event configuration:
179+
180+
![Webhook armed](/img/webhook-blog-servicenow-picture-6.jpg "Webhook armed")
181+
182+
First, let’s take a look at the open incidents page of the ServiceNow console:
183+
184+
![ServiceNow console before event received](/img/webhook-blog-servicenow-picture-7.jpg "ServiceNow console before event received")
185+
186+
Once a subscription reaches an expiration threshold, HPE GreenLake cloud will send an event to my webhook handler, which will, in turn, open a new incident to track it in ServiceNow, as shown below:
187+
188+
![ServiceNow console after event received](/img/webhook-blog-servicenow-picture-8.jpg "ServiceNow console after event received")
189+
190+
The new incident, visible at the top of the list above, was automatically opened by the webhook handler. I can open it to check out the details that were set up by the webhook handler:
191+
192+
![Detail of incident created](/img/webhook-blog-servicenow-picture-9.jpg "Detail of incident created")
193+
194+
This HPE GreenLake cloud event is now an incident in ServiceNow. It will continue its lifecycle until its closure in ServiceNow.
195+
196+
## Call to action
197+
198+
Webhooks together with the HPE GreenLake cloud events framework provide a great way to integrate with HPE GreenLake cloud using modern technology. They provide great flexibility on where you can run the subscriber code and allow you to choose the language in which to write the webhook code. They also allow you to build a tight integration with an existing platform such as ServiceNow or HPE OpsRamp.
199+
200+
Additional benefits I can see from this technique are:
201+
202+
* No need to verify that a polling code is still running
203+
* No risk of API token expiration
204+
* No loss of events
205+
* It’s a well-established industry standard mechanism
206+
* There is a huge choice of implementation methods including low code/no code ones
207+
208+
> > **Note**: While a low-code/no-code approach was taken in this tutorial, the same logic applies to any other programming language selected.
209+
210+
You can request access to this feature by signing up to the Automations/Webhook Access Beta Program [here](https://app.smartsheet.com/b/form/0e61e8c2bd6d48c7829845ab824c11d6).
148 KB
Loading
49.4 KB
Loading
84.3 KB
Loading
71.1 KB
Loading
218 KB
Loading
833 KB
Loading
785 KB
Loading
582 KB
Loading

0 commit comments

Comments
 (0)