This article is a supplement to the ServiceNow documentation. For full documentation please refer ServiceNow official website
Checkout our NEW Video Channel you can like and subscribe too!


Many enterprise uses git issues as their project tracking tool. Create stories, post review comments and work towards closure. Surveyis 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).


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.



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.

survey-git-13.png survey-git-15.png

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.
    var jData = new global.JSON().decode(request.body.dataString);
    var remoteAction = jData.action;
    var remoteUser = jData.issue.user.login;
    var assesment = new global.createAssestment();"called from github call" + remoteAction + remoteUser + assesment.generate());"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 = "";

        //Create assesment group
        var gr1 = new GlideRecord('asmt_assessment');
        gr1.metric_type = metric_type_id;

        //Create assesment instance
        var gr = new GlideRecord('asmt_assessment_instance');
        gr.user = user_id;
        var gdt = new GlideDateTime(;
        gr.due_date = gdt;
        gr.metric_type = metric_type_id;
        gr.assessment_group = gr1.getUniqueValue();

        //Get all questions
        var arrayquestions = [];
        var gr3 = new GlideRecord('asmt_metric');
        gr3.addEncodedQuery('category.sys_idLIKE' + survey_question_metric_category);
        var count = gr3.getRowCount();
        while ( {
            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.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;

        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.