Introduction
Many enterprise uses git issues
as their project tracking tool. Create stories, post review comments and work towards closure. Survey
is a ServiceNow module that can be used to gather valueable user feedbacks.This integration will try to glue the best of both.Scenario can be described as below
TLDR on webhook:
If have worked with other SNOW intergration you already know what a webhook
means.For those who dont think webhook as an api
which can be used to get hold of events that is trigger from other systems.So you hook
(register) some api(that you create or the receiver service already provides) to a thirdparty service and listen to it.
E.g here whenever a github event
happens the entier event is avaialble and can be consumed using registred webhook (api that we are going to write).
Workflow
A holistic view of the end-to-end
workflow will comprise of the following steps:
- A ticket gets closed in GitHub issue
- A webhook event gets triggered from GitHub
- A preconfigured Scripted Rest API (SRAPI) will capture the details of user and ticket details in ServiceNow
- The SRAPI will internally call an automated process of creating Survey Assessment and generate survey link for specific user.
- Notification email will get triggered from ServiceNow with Survey link to user.
- User will complete Survey and feedback response will be recorded for further analysis.
PreRequisites
Before you start for a smoother integration have below checklist cleared.
- GitHub Account with Admin access ( so that we can add hooks)
- A Sample GitHub project with 1 issue
- ServiceNow Instance for consuming api
- A Json formatter to view payload ( there are lot actually available online) here is one
Integration Steps
Step1: SRAPI creation
First, we need to create SRAPI and generate an endpoint that can be added as a GitHub webhook
Step2: Installing webhook
Installing is supereasy. All we have to do is compose the url at SNOW side
so it will be snowinstace
/resource endpoint from restapi
we dont need all the event information, just issue details are enough
once hook installed make sure the green tick is shown
.
if dont see it might be because of various issues like url format is incorrect,authentication is enabled or instance mentioned doesnt exists.To confirm this hit deliver again at the bottom the screen.I got this exception so i removed authentication from the SNOW restapi as this a demo instance.
Step3: Capture event in snow
Let’s us simulate an even creation and we will then capture event at SRAPI. We will put some comments and close the issue.
Payload sample
We are interested in ticket owner and status details. Let us capture those in SRAPI
Step4: Automate Survey creation
We are going call a script include that will automate the survey creation process
SRAPI snippet
(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
//use this get the whole payload and peek into the properties.
//gs.info((request.body.dataString);
var jData = new global.JSON().decode(request.body.dataString);
var remoteAction = jData.action;
var remoteUser = jData.issue.user.login;
var assesment = new global.createAssestment();
gs.info("called from github call" + remoteAction + remoteUser + assesment.generate());
gs.info("Survey url" + assesment.generate());
return "hello";
})(request, response);
Script Include Snippet
Creation of suvery will require handfull of tables to be popoulated.But the below script is quite reusable.Just set the survey,category and user sysId and it should work without much change.
var createAssestment = Class.create();
createAssestment.prototype = {
initialize: function() {},
generate: function() {
//Survey definition sysID
var metric_type_id = "87186844d7211100158ba6859e610378";
//User sysId
var user_id = "6816f79cc0a8016401c5a33be04be441";
//Survey Questions metric categories
var survey_question_metric_category = "4b186844d7211100158ba6859e610378";
//Survey URL
var surveyURL = "https://dev67951.service-now.com/nav_to.do?uri=assessment_take2.do%3Fsysparm_assessable_type=";
//Create assesment group
var gr1 = new GlideRecord('asmt_assessment');
gr1.initialize();
gr1.metric_type = metric_type_id;
gr1.insert();
//Create assesment instance
var gr = new GlideRecord('asmt_assessment_instance');
gr.initialize();
gr.user = user_id;
var gdt = new GlideDateTime(gs.now());
gdt.addDays(14);
gr.due_date = gdt;
gr.metric_type = metric_type_id;
gr.assessment_group = gr1.getUniqueValue();
gr.insert();
//Get all questions
var arrayquestions = [];
var gr3 = new GlideRecord('asmt_metric');
gr3.addEncodedQuery('category.sys_idLIKE' + survey_question_metric_category);
gr3.query();
var count = gr3.getRowCount();
while (gr3.next()) {
var sysid = gr3.sys_id;
arrayquestions = arrayquestions + "," + sysid;
}
var arrayafter = arrayquestions.split(",");
for (var i = 1; i <= count; i++) {
var gr2 = new GlideRecord('asmt_assessment_instance_question');
gr2.initialize();
gr2.source_table = 'asmt_metric_type';
gr2.source_id = metric_type_id;
gr2.category = survey_question_metric_category;
gr2.instance = gr.getUniqueValue();
var answer = arrayafter[i];
gr2.metric = answer;
gr2.insert();
}
surveyURL = surveyURL + metric_type_id + "%26sysparm_assessable_sysid=" + gr.sys_id;
return surveyURL;
},
type: 'createAssestment'
};
Finally generate the Survey link as output. Note that it is not mandatory to return survey link.The link will anyway be send as part of notfication triggered from Survey. It just another way to show that we can even a custom notification programitcally using the link generated here.
Step5: Notification Email
Notification event will be fired by ServiceNow for the survey instance created. User will receive email with Survey link.
Step6: User submits survey
Finally, user clicks on survey link and completes the survey.
- Understanding Request, RITM, Task in ServiceNow
- Steps to create a case in ServiceNow (CSM)
- Performance Analytics in 10 mins
- Event Management in 10 minutes - part1
- Event Management in 10 minutes - part2
- Custom Lookup List
- Script includes in 5 minutes
- Interactive Filter in 5 minutes
- UI Policy in 6 Minutes
- Client Side Script Versus Server Side Script in 3 minutes
-
Snow
- Performance Analytics
- ServiceNow Scripts
- Script include
- Useful scripts
- Basic Glide Scripts
- Client Script
- Advance Glide Script
- Glide System Script
- Admin
- Import Set
- Work Flow
- ACL
- SLA
- Notification
- Core Application
- UI Policy
- UI Action
- Client Script
- CAB Workbech
- Data Policy
- Connect Support
- Catalog
- Discovery
- CSM
- Event Management
- HR
- Integrations
- SSO Integration
- LDAP Integration
- SCCM Integration
- AWS Intergration
- Slack Integration
- CTI Integration
- Jira Integration
- Ebonding ServiceNow
- SOAP Integration
- IBM Netcool Integration
- VIP Mobile App Integration
- Rest Integration
- Service Portal
- Questions
- ACL
- Performance analytics(PA) Interactive Filter
- Various Configurations in Performance analytics(PA)
- Service Portal
- Performance Analytics(PA) Widgets
- Performance Analytics(PA) Indicator
- Performance Analytics(PA) Buckets
- Performance Analytics(PA) Automated Breakdown
- Client Script
- Rest Integration
- Understanding the Request, RITM, Task
- Service Catalogs
- Events in ServiceNow
- Advance glide script in ServiceNow
- CAB Workbench
Comments