If you have wanted to automate some workflows and improve your productivity, our webhooks are a powerful resource to get you started for your use case.
Webhooks are a way that an application can send real-time data to another application. They have a message (or payload in the form of JSON) and are sent to a unique URL.
Therefore, with webhooks, the UXI Dashboard can send information to a third-party service when an action or event happens.
Setting up Webhooks
On the dashboard page, on the top right, click on the settings button and navigate to the Integrations page (shown below):
At the top of the page, there is a webhook section where users can add their webhook configurations.
At the moment we support three types of webhooks; Generic, Slack & ServiceNow.
Slack is an IRC communication application that is used at Aruba. A potential use case for Slack is posting to a particular slack channel about a particular event through webhooks.
ServiceNow is an IT ticketing system used in the Aruba ecosystem. A potential use case for ServiceNow includes posting an Alert to create support tickets.
Adding Webhooks
Webhook 1: Generic
On the dashboard, click on the Add webhook button
Change the target to Generic
Paste the webhook URL in the URL input field
Select an Authentication method - None or Basic
Bearer Token authentication - If the destination allows for it to be specified in the URL as a query parameter you can specify it in the URL. It wouldn’t work if the destination only allows for it to be part of the header.
Click on Add
Your webhook should be visible in your webhooks list as below.
Below is an example of the body of the request to the webhook URL
{
'details': ' Sensor: *Sensor1* Network: *YourSSIDName* Service: *Gmail*',
'notification_reference': 5649,
'description': 'External service is unavailable',
'severity': 'error',
'status': 'ALARM',
'start_timestamp': 1590395448
}
Webhook 2: Slack
In order to add a slack webhook, you need to create a slack application.
Follow the instructions for Slack incoming webhooks here
Copy the webhook URL generated by slack.
It should look something like this
https://hooks.slack.com/services/xxxxxxxxxx/xxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx
3. On the dashboard, Click on the add webhook button
Change the target to Slack
Paste the URL in the URL input field
Select None for Authentication
Click on Add
All alerts will now be published to the appropriate Slack channel. In our case the channel is #webhook-test and the result is as below
Webhook 3: ServiceNow
This is a little more in-depth as it requires configuration on ServiceNow.
Below are the steps to create your webhook with ServiceNow.
Navigate to Scripted REST API
2. Create your API
Click on the new button to start creating your API
Give your API a name and an ID
Click on the submit button to save this API
3. Select your API and create a new unauthenticated resource
After creating your API, you are redirected to a list of APIs.
Search for your API and select your API
Create a new resource by clicking on the new button at the bottom of the page.
4. Use the script below as a template
This example shows how to create a POST request. We will be using it to post an alert. The alert details are contained in
request.body.data.text
5. Final script for REST API:
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
gs.info(request.body.data);
var action = request.body.data.action;
var inc = new GlideRecord('incident');
if (action == 'open_incident') {
inc.initialize();
inc.short_description = 'Incident created from WebHook';
inc.comments = request.body.data.text;
inc.insert();
gs.info('Incident created');
return {
"uri": request.uri,
"url": request.url,
"sys_id": inc.sys_id,
};
} else if (action == 'close_incident') {
inc.get(request.body.data.sys_id);
inc.state = 7;
inc.update();
gs.info('Incident closed');
}
})(request, response);
6. An example Incident from ServiceNow
Once this is done, on the dashboard, you just have to add the webhook to the dashboard.
On the dashboard, Click on the add webhook button
Change the target to ServiceNow
Paste the Webhook URL in the URL input field. In our case https://ven02658.service-now.com/api/arune/cape. This is a combination of the base (https://ven02658.service-now) and resource path (/api/arune/cape).
Select the Authentication method for your webhook
If None is selected proceed to the next step
If Basic is selected, type in Username and Password and proceed to the next step
Click on Add
All alerts will now be published to the defined URL. Please note that incidents on ServiceNow will auto close when all issues on an alert (incident) have been closed or no longer ongoing.
Note: Some of the webhooks when you try to configure using a generic option, require data to be received in a specific JSON format. for example MS Teams Webhook hence feature requests can be entered in AIZ for such requests.
Editing Webhooks
In the Webhooks section, click on the webhook you would like to edit. This opens up the edit modal and you can modify the webhook.
Click Save to save your changes
Deleting Webhooks
In the Webhooks section, click on the webhook you would like to delete.
This opens up the edit modal and you can click on the red trash can to remove a webhook. Please note that this will not delete configuration on your service side.