Browse Guides

Triggering Automation Policies in RMM via Halo
Reading mode
Copy Link
Link Copied!
Print
Feedback
This guide has multiple versions available:
<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 Trigger Automation Policies in NinjaOne</strong></p><p><strong>- How to Trigger Automation Policies in N-Central&nbsp;</strong></p><p><br></p><p><br></p><p><a href="https://usehalo.com/halopsa/guides/1630/" target="_blank" rel="noopener noreferrer">Custom Integration Runbooks</a> in Halo can be leveraged to allow you to trigger Automation Policies in RMM tools from Halo. In this guide we outline how to set this up for NinjaOne and N-central. Trials created as of the 16th of April 2024 will have some pre-configuration available to assist with the setup of this functionality</p><p><br></p><p><strong><span style="font-size: 14pt;">How to Trigger Automation Policies in NinjaOne<br></span></strong></p><p>The first step towards achieving script calling in NinjaOne is to authenticate with your NinjaOne environment.</p><p><br></p><p><span style="font-size: 12pt;"><strong>Authentication</strong></span></p><p><span style="font-size: 11pt;">NinjaOne is an available option for a &#39;System&#39; integration. This means that you can connect to your NinjaOne instance via Configuration&gt;Integrations&gt;NinjaOne, and that same authentication process can be used in Integration Runbooks. Simply connect to your instance of NinjaOne then, choose the &#39;NinjaOne&#39; option under &#39;System&#39; within your Custom Integration:</span></p><p><br></p><p><span style="font-size: 11pt;"><img src="https://halo.haloservicedesk.com/api/attachment/image?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjJmYzg5NzYzLTZkODgtNDkwZi04ODVmLTc3MmU1YmM3YWU0MCJ9.81MET9m9DRezDNDyBj2ArUQchZoUPnqWTb5A42Ru-2U" class="fr-fic fr-fil fr-dib" width="216" style="width: 216px; height: 148.037px;" height="148.037"></span></p><p><strong><span style="font-size: 10pt;">Fig 1. System Integration Options</span></strong></p><p><br></p><p><span id="isPasted" style="font-size: 12pt;"><strong>Halo Configuration</strong></span></p><p><span id="isPasted">There are 3 main consideration points when looking at Triggering Automations in NinjaOne from Halo:</span></p><ul><li>What Device should I trigger my Script on?</li><li>What Script should I trigger?</li><li>Does my Script require extra parameters?</li></ul><p><strong>Device Selection</strong></p><p>For this part, we can use a custom field in Halo to select our device. Create a custom field of type &#39;Single Select&#39; and lookup Type &#39;Dynamic SQL&#39;. The query can be tailored to suit your own setup, but it is important to ensure your &#39;ID&#39; column in the query is &#39;DNinjaRMMId&#39; - the NinjaOne ID of the synced device in Halo. An example query may look like:</p><p><br></p><p>&quot;</p><p><em>select</em></p><p><em>DNinjaRMMId [ID]</em></p><p><em>, dinvno [Display]</em></p><p><em><br></em></p><p><em>from faultDevice</em></p><p><em>join device on fdSiteID=dsite and fdDevNum=DDevNum</em></p><p><em><br></em></p><p><em>where fdfaultid=$faultid</em></p><p>&quot;&nbsp;</p><p><br></p><p><strong>Script Selection</strong></p><p>Your script repository can be managed via a Custom Table. For those who have started trials as of the 16th of April 2024, you will find an existing Custom Table in HaloPSA named &#39;NinjaOne Script Repository&#39;. If you do not already have this table, you can create a new Table with 2 columns: Script UID and Script Name.</p><p><br></p><p>Populate this table with records containing the scripts you would like to be available from Halo.</p><p><br></p><p>Script selection, from this &#39;Repository&#39; table can also use a custom field, selecting the ID of the table row, and the respective Script name as the &#39;display&#39;. An example query for this may look like:</p><p><br></p><p>&quot;</p><p id="isPasted"><em>select</em></p><p><em>CTNinjaOneScriptLibraryid [ID]</em></p><p><em>, CFNinjaOneScriptName [Display]</em></p><p><em>from CTNinjaOneScriptLibrary</em></p><p>&quot;</p><p><br></p><p>For those who have started trials after 16th April 2024 this field will already be added to your instance, it will be called &quot;CFNinjaOneScriptRepository&quot;.&nbsp;</p><p><br></p><p><strong>Extra Parameters</strong></p><p>This is a simple case of creating a Custom Field of type &#39;text&#39;, the contents of this field can then be passed to NinjaOne as extra Parameters.</p><p><br></p><p>For those who have started trials as of the 16th of April 2024, you will find an existing custom field for this in your instance called &quot;CFNinjaOneAutomationParameters&quot;.&nbsp;</p><p><br></p><p><span id="isPasted" style="font-size: 12pt;"><strong>The Runbook</strong></span></p><p><span style="font-size: 11pt;">Trials started as of 16th of April 2024 will already have this Runbook configured, so there should be no need to recreate this. However, you may wish to customise the runbook to control when scripts run and what data is sent to ninja. The runbook required can be found under Configuration &gt; Integrations &gt; Custom Integrations &gt; Integration Runbooks &gt; &quot;</span>NinjaOne Script Invocation&quot;.&nbsp;</p><p><br></p><p><span id="isPasted">The Runbooks for triggering the Script in NinjaOne has 2 components: Obtaining the relevant data (Device, Script, Parameters) and triggering the Script in NinjaOne.</span></p><p><br></p><p><strong>Obtaining the Data</strong></p><p>The scope for determining what scenario triggers a script in NinjaOne is as broad as it needs to be for your use case: From Alerts raised via NinjaOne to Incidents logged directly by end users. The important consideration is that your fields are added to an Action that will be used to script calling, or that the data points are populated on the Ticket at the point of triggering the script.</p><p><br></p><p>The first step of the Runbook should trigger an Action in Halo that will return those core details: UID, Device &amp; Parameters. &nbsp;As the script UID is not of type &#39;int&#39;, we will need to extract this information from the Custom table via a report. Create an report in Halo that extracts the relevant datapoints. Trials started after 16th April will have this report created already &quot;NinjaOne Script Details&quot;. If you need to create this report, an example of this report query is:</p><p><br></p><p>&quot;</p><p id="isPasted"><em>select</em></p><p><em>(select CFNinjaOneScriptUID from CTNinjaOneScriptLibrary where CTNinjaOneScriptLibraryid=CFNinjaOneScriptRepository) [UID]</em></p><p><em>, CFNinjaOneDevice [Device]</em></p><p><em>, CFNinjaOneAutomationParameters [Parameters]</em></p><p><em><br></em></p><p><em>from faults where faultid=$faultid</em></p><p>&quot;</p><p><br></p><p>Where, in the above:</p><ul><li>CFNinjaOneScriptUID - the name of the Custom field that is in the Custom Table and represents the Script UID</li><li>CTNinjaOneScriptLibrary - The name of the Custom Table</li><li>CTNinjaOneScriptLibraryid - The ID of the custom table row</li><li>CFNinjaOneScriptRepository - The name of the Custom field that returns the dropdown of all available scripts</li><li>CFNinjaOneDevice - The name of the Custom Field used to return the device to run the script on</li><li>CFNinjaOneAutomationParameters - The name of the Custom Field used to return script parameters.</li></ul><p>This report should then be triggered from an Action in Halo, and the default note for this action should be $_ReportJSON (without the _). Trails started after 16th April will have this action created already (ID=76). Note, the ID of this Action and use this in your first Runbook Method, which should look like:</p><p><br></p><p><img src="https://halo.haloservicedesk.com/api/attachment/image?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImM1NDdlODdkLWMzZTYtNDJlNy1hMzQ4LTUyYjEyMWIxZjhhOSJ9.J2K_fZrRUOgbWhBGE_JG9Q5DexgcjygMaSGm4Tc_50c" class="fr-fic fr-fil fr-dib" width="1324" style="width: 1326px; height: 781.365px;" height="781"></p><p><strong><span style="font-size: 10pt;">Fig 2. Runbook Method</span></strong></p><p><br></p><p>Looking at the above example, my &#39;outcome_id&#39; is 76 - denoting the ID of the action I am triggering. Looking at the bottom of the above screenshot, you will see 3 output variables created. These variables are looking at the returned values from the report and will be used in the next method.</p><p><br></p><p>The following method will be the POST to NinjaOne to trigger the script on the selected device, this method will look like:</p><p><br></p><p><img src="https://halo.haloservicedesk.com/api/attachment/image?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjliMzZkNzg2LTEwOTMtNGZkMS04ZDI4LTU3MmJiZmYyMGY5MiJ9.pa9g6eR3Y1gi7Bu33hI4-JMAB7Ps7ehxSejDQYggrX4" class="fr-fic fr-fil fr-dib" width="991" style="width: 991px; height: 258.444px;" height="258.444"></p><p><strong><span style="font-size: 10pt;">Fig 3. Runbook method to POST to Ninja</span></strong></p><p><br></p><p>Where the device ID is added to the request URL and the Script UID and Parameters are added to the Request Body.</p><p><br></p><p><strong><span style="font-size: 14pt;">How to Trigger Automation Policies in N-Central&nbsp;<br></span></strong></p><p>With the introduction of some changes to N-Central&#39;s API, namely the addition of REST API endpoints that can be used for initiating Automation Policies, HaloPSA can now trigger Automation Policies in N-Central. This functionality is centred around <a href="https://halopsa.com/guides/article/?kbid=1630" rel="noopener noreferrer" target="_blank">Custom Integration Runbooks</a>. If you started a trial after the 24th of March 2024 then you will find some configuration already available in your instance that will help with setting this up.</p><p><br></p><p>There are some points to consider when thinking about implementing this functionality:</p><ul><li>What Automation Policy (AP) to trigger.</li><li>What device to trigger the AP on.</li></ul><p>Before the above can be achieved, you&#39;ll need to authenticate with your instance of N-Central.&nbsp;</p><p><br></p><p><span style="font-size: 12pt;"><strong>Authentication</strong></span></p><p>N-Central is an available option for a &#39;System&#39; integration. This means that you can connect to your N-Central instance via Configuration&gt;Integrations&gt;N-Central, and that same authentication process can be used in Integration Runbooks. Simply connect to your instance of N-Central then, choose the &#39;N-Central&#39; option under &#39;System&#39; within your Custom Integration.</p><p><br></p><p><span style="font-size: 11pt;">Authentication can then be achieved via making a POST request to your instance of N-Central&#39;s &#39;authenticate&#39; endpoint (characterised via your N-Central URL followed by /api/auth/authenticate). Your request does not need a body, but must include an &#39;Authorization&#39; header with value: &quot;Bearer {JSON TOKEN}&quot;, where {JSON TOKEN} is the token you can obtain from N-Central when you create an API user in their platform. The response for this request will include an Access Token, which you can obtain from your response by creating an Output Variable with value: &#39;</span>response^tokens^access^token!<span style="font-size: 11pt;">&#39;</span></p><p><span style="font-size: 11pt;"><img src="https://halo.haloservicedesk.com/api/attachment/image?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Ijk2ODcyMzZkLTQ1NDEtNDA3My1hMmY0LTZkYzkzYmJhM2EzMiJ9.AzDyhSRjO-rDKgBJoM-uuwrrUiZCPMiuC_cbHPXJu80" class="fr-fic fr-fil fr-dib" width="1341" style="width: 1341px; height: 308.122px;" height="308.122"></span></p><p><span style="font-size: 10pt;"><strong>Fig 4. POST request to Ninja&#39;s authentication endpoint</strong></span><strong><span style="font-size: 10pt;"><br></span></strong></p><p><br></p><p>This should be the first method to your Runbook.</p><p><br></p><p><strong>Selecting an Automation Policy</strong></p><p>Automation Policies are triggered via making a POST request to {YOUR N-CENTRAL URL}/api/scheduled-tasks/direct, and will have a request body that looks something like the following:</p><p><br></p><p id="isPasted"><em>{</em></p><p><em>&nbsp; &quot;name&quot;: &quot;Task (ID: &lt;&lt;ItemID!&gt;&gt;) Triggered for Ticket &lt;&lt;Ticket ID!&gt;&gt; at &lt;&lt;action^datetime!&gt;&gt;&quot;,</em></p><p><em>&nbsp; &quot;itemId&quot;: &lt;&lt;ItemID&gt;&gt;,</em></p><p><em>&nbsp; &quot;taskType&quot;: &quot;AutomationPolicy&quot;,</em></p><p><em>&nbsp; &quot;customerId&quot;: &lt;&lt;CustomerID&gt;&gt;,</em></p><p><em>&nbsp; &quot;deviceId&quot;: &lt;&lt;DeviceID&gt;&gt;,</em></p><p><em>&nbsp; &quot;credential&quot;: {</em></p><p><em>&nbsp; &nbsp; &quot;type&quot;: &quot;LocalSystem&quot;,</em></p><p><em>&nbsp; &nbsp; &quot;username&quot;: null,</em></p><p><em>&nbsp; &nbsp; &quot;password&quot;: null</em></p><p><em>&nbsp; },</em></p><p><em>&nbsp; &quot;parameters&quot;: [</em></p><p><em>&nbsp; &nbsp; {</em></p><p><em>&nbsp; &nbsp; &nbsp; &quot;parameter1&quot;: &quot;value1&quot;,</em></p><p><em>&nbsp; &nbsp; &nbsp; &quot;parameter2&quot;: &quot;value2&quot;</em></p><p><em>&nbsp; &nbsp; }</em></p><p><em>&nbsp; ]</em></p><p><em>}</em></p><p><br></p><p>Where the value of &#39;itemId&#39; determines the AP to trigger, hence we need a repository of AP&#39;s that can be triggered. For trials started after 16th April 2024, a Custom Table has been created for this purpose called &quot;N-Central Script Library&quot;.</p><p><img src="https://halo.haloservicedesk.com/api/attachment/image?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjZkY2JjMDM4LWU4MzctNDg0MS1iZGNiLWQxMmEyMzFhNzg0YSJ9.Q1HCFZiXr3DNNviPjCBm4gr2vjwkMD3zjTRVj1Rvo-k" class="fr-fic fr-fil fr-dib" width="1066" style="width: 1066px; height: 331.237px;" height="331.237"></p><p><strong><span style="font-size: 10pt;">Fig 5. Custom Table containing APs tat can be triggered</span></strong></p><p><br></p><p><em><strong>Note: This table characterises the minimum number of required datapoints (a name and repository ID), but you can add any other columns you would need for your use case. Repository ID&#39;s can be obtained from N-Central (via Configuration&gt;Scheduled Tasks&gt;Script/Software Repository)</strong></em></p><p><br></p><p>Now you have your repository composed, you can create a custom field that queries this table. New trials include a custom field for this already called &quot;CFNCentralScriptRepository&quot;. If you do not have this field, create a new single select custom field with lookup type &#39;Dynamic List (SQL)&#39; and SQL:</p><p><br></p><p id="isPasted"><em>select</em></p><p><em>CFRepositoryID [ID]</em></p><p><em>, CFAutomationPolicyName [Display]</em></p><p><em><br></em></p><p><em>from CTNCentralScriptLibrary</em></p><p><br></p><p><span style="font-size: 12pt;"><strong>Device/Customer Selection</strong></span></p><p><span style="font-size: 11pt;">The selection of Device can also be determined by the selection based on a Single Select CF. The N-Central ID of the device in Halo is characterised by &#39;DGFIDeviceID&#39;, so your SQL would look something like:</span></p><p><br></p><p id="isPasted"><em>select</em></p><p><em>DGFIDeviceID [id],</em></p><p><em>dinvno [display]</em></p><p><em>from device</em></p><p><em>where dsite in (select ssitenum from site where sarea=(select areaint from faults where faultid=$faultid))</em></p><p><br></p><p><span style="font-size: 11pt;">The value required for &#39;customerId&#39; should also be available in Halo (assuming you have already integrated N-Central with Halo), which can be obtained via the &#39;gfisiteid&#39; value for the Ticket&#39;s site.</span></p><p><br></p><p><span style="font-size: 12pt;"><strong>Additional Parameters</strong></span></p><p><span style="font-size: 11pt;">Different AP&#39;s require different parameters to be successfully executed. As each AP has a unique set of parameters, you may want to consider having different Runbook Methods for each AP, amending your request body to reflect the required parameters for each AP. If the value of these specific parameters are dynamic, you can follow similar steps to the above to create Custom Fields allowing for the selection of each parameter.</span></p><p><br></p><p><strong><em>Note: The name of the Task that is triggered must be unique, so ensure that your task name includes some unique identifiers (the above example references the Item ID, Ticket ID and time that the Task was initiated.</em></strong></p><p><br></p><p><span style="font-size: 12pt;"><strong>Building the Runbook</strong></span></p><p>Trials started as of 16th of April 2024 will already have this Runbook configured, so there should be no need to recreate this. However, you may wish to customise the runbook to control when scripts run and what data is sent to N-Central.&nbsp;</p><p><br></p><p><span style="font-size: 11pt;">Details on how to build Custom Integration Runbooks can be found via <a href="https://halopsa.com/guides/article/?kbid=1630" rel="noopener noreferrer" target="_blank">this guide</a> - for this specific example, you can have your Runbook initiated when closing a Ticket and having a checkbox selected:</span></p><p><span style="font-size: 11pt;"><img src="https://halo.haloservicedesk.com/api/attachment/image?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImFkZTlmMjQxLWViYTctNDBlYi05NWNmLTRkNmRhMDA4YWFiYiJ9.qso_a_EKjsJhUFyr5o7DjmdJP9dOPRzkiPchsXhvf58" class="fr-fic fr-fil fr-dib" width="443" style="width: 443px; height: 227.403px;" height="227.403"></span></p><p><span style="font-size: 10pt;"><strong>Fig 6. Runbook trigger when ticket is closed and checkbox checked</strong></span><strong><span style="font-size: 10pt;"><br></span></strong></p><p><br></p><p>Dynamic Field Visibility can be added to only show the relevant fields when they are required - namely, only show your AP/Device dropdowns when &#39;Resolve via N-Central Automation Policy&#39; is checked.&nbsp;</p><p><br></p><p><em><strong>Note: You can further add Dynamic Field Visibility for your required parameter values based on the AP selected.</strong></em></p>
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.