Skip to content

Commit 433233c

Browse files
committed
Create Blog “no-code-integration-of-hpe-greenlake-cloud-with-servicenow”
1 parent 77eec1b commit 433233c

9 files changed

+207
-0
lines changed
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
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+
---
8+
<style>
9+
ul li{
10+
font-size:27px;
11+
}
12+
</style>
13+
14+
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.
15+
16+
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.
17+
18+
![HPE Greenlake cloud event framework](/img/slide-pour-blog-webhooks.jpg "HPE Greenlake cloud event framework")
19+
20+
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.
21+
22+
## Problems, incidents and change orders
23+
24+
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.
25+
26+
## What’s the right API then?
27+
28+
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.
29+
30+
Here is the Python script returned by ChatGPT:
31+
32+
```python
33+
import requests
34+
import json
35+
# Replace these variables with your own information
36+
instance_url = "https://your-instance.service-now.com"
37+
username = "your-username"
38+
password = "your-password"
39+
service_id = "service-id" # The Service ID related to the incident
40+
41+
# Define the API endpoint for creating an incident
42+
url = f"{instance_url}/api/now/table/incident"
43+
44+
# Create the headers for the request (set the content-type to application/json)
45+
headers = {
46+
"Content-Type": "application/json",
47+
"Accept": "application/json"
48+
}
49+
50+
# Define the data to be sent in the request body
51+
data = {
52+
"short_description": "Issue with email service",
53+
"description": "The email service is down and needs urgent attention.",
54+
"category": "Inquiry",
55+
"impact": "3", # 1=High, 2=Medium, 3=Low (you can adjust accordingly)
56+
"urgency": "2", # 1=High, 2=Medium, 3=Low (you can adjust accordingly)
57+
"service": service_id # The ID of the service being impacted
58+
}
59+
60+
# Make the POST request to create the incident
61+
response = requests.post(url, auth=(username, password), headers=headers, data=json.dumps(data))
62+
63+
# Check the response
64+
if response.status_code == 201:
65+
print(f"Incident created successfully! Incident Number: {response.json()['result']['number']}")
66+
else:
67+
print(f"Failed to create incident. Status Code: {response.status_code}")
68+
print(f"Response: {response.text}")
69+
```
70+
71+
> > Note: ServiceNow provides the full documentation for their API once you sign up as a ServiceNow developer and it is free.
72+
73+
Nevertheless, this script was very helpful because I now understand:
74+
75+
* 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**
76+
* The (minimal) payload I need to pass in the API call
77+
* The necessary headers
78+
* The response code expected if it worked: 201
79+
80+
## From event to incident
81+
82+
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…) 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 will use another event that might 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/).
83+
84+
This can be considered an incident and could be added in ServiceNow incident table.
85+
86+
The payload sent to the webhook handler when this event is triggered by the Subscriptions Management service, has the following format:
87+
88+
```json
89+
{
90+
"specversion": "1.0",
91+
"id": "fb25f344-5e20-4f13-9937-c3ecc0327dc3",
92+
"source": "https://global.api.greenlake.hpe.com/subscriptions",
93+
"type": "com.hpe.greenlake.subscriptions.v1.expiring-subscriptions",
94+
"datacontenttype": "application/json",
95+
"time": "2024-10-30T21:09:16.127443806Z",
96+
"data": {
97+
"key": "OFKIAASTEST168IZ",
98+
"expirydate": "10/25/2024",
99+
"sku": "S0B80AAE",
100+
"licensetier": "ENHANCED PROLIANT",
101+
"quantity": 500,
102+
"username": "John Doe Inc.",
103+
"subscriptionendinsecs": 1729848600,
104+
"subscriptiontype": "Compute Subscription",
105+
"producttype": "DEVICE",
106+
"platformcustomerid": "22e7e552184511ef88e9cacb36fa7032",
107+
"devices": []
108+
}
109+
}
110+
```
111+
112+
Now that I know what my webhook handler will receive as input and how I can open an incident in ServiceNow, I’ll get started.
113+
114+
## From code to no-code
115+
116+
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:
117+
118+
![Original scenario in make ](/img/second-route-taken.jpg "Original scenario in make ")
119+
120+
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/).
121+
122+
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.
123+
124+
The HTTP Make a request module that allows you to make any type of REST API call. It comes in very handy for integration use cases.
125+
126+
> > Note: Make.com also provides a native ServiceNow integration, but you need an Enterprise plan to use it, which I don’t have.
127+
128+
My scenario looks like this:
129+
130+
![New scenario in make](/img/webhook-blog-servicenow-picture-2.jpg "New scenario in make")
131+
132+
My new scenario includes:
133+
134+
* The **Custom webhook** module as a trigger of your webhook scenario with *advanced option* enabled
135+
* 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
136+
* 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
137+
* 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
138+
139+
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/).
140+
141+
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:
142+
143+
* **The URL endpoint of my ServiceNow instance**: *https://{your-instance}/api/now/table/incident*
144+
* **Method**: *POST*
145+
* Two custom headers for **Accept** and **Content-Type** both set to *application/json*
146+
* **Body type**: *Raw*
147+
148+
149+
150+
![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")
151+
152+
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.
153+
154+
I then need to set up the JSON payload (***Request content*** as shown below) with ServiceNow information such as:
155+
156+
* The ***short description*** (for example, the subscription type is expiring soon)
157+
* The ***description*** (for example, License <license type> expires on <date>)
158+
* The ***category***, and the ***subcategory***
159+
* The level of ***urgency*** (high, medium, low), the level of ***priority*** (high, medium, low) and the level of the ***impact*** (high, medium, low)
160+
* The ***caller_id***
161+
* The ***service***
162+
163+
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:
164+
165+
![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")
166+
167+
It’s important not to forget to specify username and password obtained when creating a ServiceNow personal developer instance.
168+
169+
## Putting it all together
170+
171+
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:
172+
173+
![Subscribing to expiring subscriptions](/img/webhook-blog-servicenow-picture-5.jpg "Subscribing to expiring subscriptions")
174+
175+
If everything goes well, I should see the following subscribed event configuration:
176+
177+
![Webhook armed](/img/webhook-blog-servicenow-picture-6.jpg "Webhook armed")
178+
179+
First, let’s take a look at the open incidents page of the ServiceNow console:
180+
181+
![ServiceNow console before event received](/img/webhook-blog-servicenow-picture-7.jpg "ServiceNow console before event received")
182+
183+
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:
184+
185+
![ServiceNow console after event received](/img/webhook-blog-servicenow-picture-8.jpg "ServiceNow console after event received")
186+
187+
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:
188+
189+
![Detail of incident created](/img/webhook-blog-servicenow-picture-9.jpg "Detail of incident created")
190+
191+
This HPE GreenLake cloud event is now an incident in ServiceNow. It will continue its lifecycle until its closure in ServiceNow.
192+
193+
## Call to action
194+
195+
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.
196+
197+
Additional benefits I can see from this technique are:
198+
199+
* No need to verify that a polling code is still running
200+
* No risk of API token expiration
201+
* No loss of events
202+
* It’s a well-established industry standard mechanism
203+
* There is a huge choice of implementation methods including low code/no code ones
204+
205+
> > Note: While a low-code/no-code approach was taken in this tutorial, the same logic applies to any other programming language selected.
206+
207+
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
140 KB
Loading
239 KB
Loading
175 KB
Loading
218 KB
Loading
833 KB
Loading
785 KB
Loading
582 KB
Loading

0 commit comments

Comments
 (0)