<style>p { margin: 0; }span.fr-emoticon.fr-emoticon-img { background-repeat: no-repeat !important; font-size: inherit; height: 1em; width: 1em; min-height: 20px; min-width: 20px; display: inline-block; margin: -0.1em 0.1em 0.1em; line-height: 1; vertical-align: middle; } span.fr-emoticon { font-weight: normal; font-family: "Apple Color Emoji", "Segoe UI Emoji", "NotoColorEmoji", "Segoe UI Symbol", "Android Emoji", "EmojiSymbols"; display: inline; line-height: 0; } blockquote { border-left: solid 2px #5e35b1; color: #5e35b1; margin-left:0; padding-left:5px;}blockquote blockquote{ border-color: #00bcd4; color: #00bcd4;}blockquote blockquote blockquote{ border-color: #43a047; color: #43a047;} table.grid{ border-collapse: collapse;} table.grid td, table.grid th { border: 1px solid #ddd;} .fr-fic.fr-dib{ display: block; margin: 5px auto;}.fr-fic.fr-dib.fr-fir{ text-align: right; margin: 5px 0 5px auto;}.fr-fic.fr-dib.fr-fil{ text-align: left; margin: 5px auto 5px 0;}.fr-fic.fr-dii{ float: none; margin: 5px auto;}.fr-fic.fr-dii.fr-fil{ float: left; margin: 5px auto;}.fr-fic.fr-dii.fr-fir{ float: right; margin: 5px auto;}img.fr-dib.fr-fir { margin-right: 0; text-align: right;}img.fr-dib.fr-fil { margin-left: 0; text-align: left;}img.fr-dib { margin: 5px auto; display: block; float: none;}img.fr-bordered { box-sizing: content-box; border: solid 5px #CCC;}img.fr-shadow { box-shadow: 10px 10px 5px 0px #cccccc;}img.fr-rounded { border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; -moz-background-clip: padding; -webkit-background-clip: padding-box; background-clip: padding-box;}</style><p><strong>In this guide we will cover:</strong></p><p><strong>- How to set up Webhooks used with the ServiceNow integration</strong></p><p><br></p><p>ServiceNow webhooks allow you to have tickets in Halo create automatically when incidents, change requests, service requests, change requests and problem tickets are raised in ServiceNow. They also allow work notes and additional comments added to the tickets to sync across to the ticket in Halo. Webhooks can also be used to have updates from suppliers update existing tickets in Halo, useful when logging issues to a supplier. </p><p><br></p><p>Before configuring webhooks for ServiceNow, you will need to connect your customer's ServiceNow instance to Halo. See our guide on how to do this here: <a data-fr-linked="true" href="https://usehalo.com/haloitsm/guides/1542/" id="isPasted" target="_blank" rel="noopener noreferrer"><strong>ServiceNow Integration</strong></a>.</p><p><br></p><p><strong><span style="font-size: 14pt;">How to set up Webhooks used with the ServiceNow integration</span></strong></p><p>With the appropriate Halo client/supplier already set up you will see a 'Webhooks' section under the customer/supplier you are configuring the ServiceNow connection for. </p><p><br></p><p><img src="https://halo.haloservicedesk.com/api/attachment/image?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjhiZWNkMGUyLWNjMTEtNGQyYS1hYjRmLTc4OGUyYTcxNmU0NyJ9.BeJsqaRCHbZP_IUkGDeuOz_PcH-xUXcqQBLSSboUECI" class="fr-fic fr-fil fr-dib" width="1184" height="488"></p><p><strong><span style="font-size: 10pt;">Fig 1. Webhook configuration</span></strong></p><p><br></p><p>You will need to create at least two business rules in the ServiceNow instance, one for creating new tickets, and another for updating existing tickets. </p><p><br></p><p><strong><em>Note: If you are connecting multiple ServiceNow instances to your Halo you will need to create these rules in each ServiceNow instance you are connecting. </em></strong></p><p><br></p><p><strong><span style="font-size: 12pt;">Webhook to Create New Tickets in Halo</span></strong></p><p>Follow the steps below to create a Business Rule that triggers a webhook to create new tickets in Halo:</p><p><br></p><ol><li>In the ServiceNow instance, go to System Definition > Business Rules.</li><li>Select New.</li><li>Give your new Business Rule a descriptive name, choose the incident table for ticket webhooks, or the journal entry table for actions webhooks, or the task table for task webhooks, and check the Advanced box. If you would like updates to sync for problems, change requests, and service requests, ensure you link the business rule to the following tables too:<ul><li data-pasted="true">Service requests: sc_req_item</li><li>Problem: problem</li><li>Change Request: change_request</li></ul></li><li>Next, choose After for when you want it to run. This is best practice as you want the data to be sent after it has been inserted or updated, so if a ticket fails, you can still update it in ServiceNow and then retrieve it immediately in Halo rather than falling back on the integrator. Doing it before the transaction is complete could lead to inaccurate data. You may also choose to add filter conditions so only specific customers incidents are pushed through to Halo.</li><li>Lastly, navigate to the Advanced tab, and you can find the script editor, the script for both actions and tickets can be found with their respective buttons shown in the screenshot above, or the text below</li><li>Before inserting the below, please make sure to replace <INSERT YOUR HALO SECRET HERE> with your client secret. The client secret is generated under the 'Webhook' section against the customer in Halo using the 'Generate' button (only visible when in edit mode). Also ensure you replace <HALO INSTANCE URL> with the URL of your Halo instance. <br><br></li><li> (function executeRule(current, previous) {<p> try {</p><p> var restMessage = new sn_ws.RESTMessageV2();</p><p> restMessage.setEndpoint("<strong><HALO INSTANCE URL></strong>/api/notify/servicenowticket");</p><p> restMessage.setHttpMethod("post");</p><p> </p><p> var obj = {</p><p> "halo_client_id": 27,</p><p> "halo_key": "<strong><INSERT YOUR HALO SECRET HERE></strong>",</p><p> };</p><p> for (var k in current){obj[k] = current.getValue(k);}</p><p> </p><p> var body = JSON.stringify(obj);</p><p> gs.info("Webhook body: " + body);</p><p> restMessage.setRequestBody(body);</p><p> </p><p> var response = restMessage.execute();</p><p> var httpStatus = response.getStatusCode();</p><p> } catch (ex) {</p><p> var message = ex.message;</p><p> gs.error("Error message: " + message);</p><p> }</p><p> gs.info("Webhook target HTTP status response: " + httpStatus);</p><p> })(current, previous);</p></li><li><p><span style="background-color: transparent;"> Now you can save this webhook, and you should begin receiving webhooks in Halo. </span></p></li></ol><p><br></p><p data-pasted="true"><strong><span style="font-size: 12pt;">Webhook to Update Existing Tickets in Halo </span></strong></p><p>Webhooks can be setup to have work notes and additional comments in ServiceNow sync to the linked ticket in Halo automatically. This includes updates from clients and suppliers. If setting up both client and supplier updates, ensure you setup the webhook in both client(s) and supplier instances. </p><p><br></p><p data-pasted="true">Follow the steps below to create a Business Rule that triggers a webhook to update existing tickets in Halo:</p><p><br></p><ol data-pasted="true"><li>In the ServiceNow instance, go to System Definition > Business Rules.</li><li>Select New.</li><li>Give your new Business Rule a descriptive name, choose the incident table for ticket webhooks, or the journal entry table for actions webhooks, or the task table for task webhooks, and check the Advanced box. If you would like updates to sync for problems, change requests, and service requests, ensure you link the business rule to the following tables too:<ul><li data-pasted="true">Service requests: sc_req_item</li><li>Problem: problem</li><li>Change Request: change_request</li></ul></li><li>Next, choose After for when you want it to run. This is best practice as you want the data to be sent after it has been inserted or updated, so if a ticket fails, you can still update it in Servicenow and then retrieve it immediately in Halo rather than falling back on the integrator. Doing it before the transaction is complete could lead to inaccurate data. You may also choose to add filter conditions so only specific customers incidents are pushed through to Halo.</li><li>Lastly, navigate to the Advanced tab, and you can find the script editor, the script for both actions and tickets can be found with their respective buttons shown in the screenshot above, or the text below</li><li>Before inserting the below, please make sure to replace <INSERT YOUR HALO SECRET HERE> with your client/supplier secret. The client/supplier secret is generated under the 'Webhook' section against the customer/supplier in Halo using the 'Generate' button (only visible when in edit mode). Also ensure you replace <HALO INSTANCE URL> with the URL of your Halo instance. <br><br></li><li> (function executeRule(current, previous) {<p> try {</p><p> var restMessage = new sn_ws.RESTMessageV2();</p><p> restMessage.setEndpoint("<strong><HALO INSTANCE URL></strong>/api/notify/servicenowaction");</p><p> restMessage.setHttpMethod("post");</p><p> </p><p> var obj = {</p><p> "halo_client_id": 27,</p><p> "halo_key": "<strong><INSERT YOUR HALO SECRET HERE></strong>",</p><p> };</p><p> for (var k in current){obj[k] = current.getValue(k);}</p><p> </p><p> var body = JSON.stringify(obj);</p><p> gs.info("Webhook body: " + body);</p><p> restMessage.setRequestBody(body);</p><p> </p><p> var response = restMessage.execute();</p><p> var httpStatus = response.getStatusCode();</p><p> } catch (ex) {</p><p> var message = ex.message;</p><p> gs.error("Error message: " + message);</p><p> }</p><p> gs.info("Webhook target HTTP status response: " + httpStatus);</p><p> })(current, previous);</p></li><li><p><span style="background-color: transparent;"> Now you can save this webhook, and you should begin receiving webhooks in Halo. </span></p></li></ol>