Use case: Remediating disk issues with a chatbot
This use case details the steps to configure and integrate a chatbot solution with Nexthink API features to fix, in this case, a disk-related issues.
This document provides NQL examples for common chatbot tasks essential for issue resolution, including:
- Providing employees with basic troubleshooting related to their device issues. 
- Leveraging Nexthink data about employee devices to retrieve basic device information. 
- Launching a remediation to fix a disk issue. 
Step 1 - Design the user-chatbot interaction for disk-issue resolution using API technologies
Design standardized steps for the employees-chatbot interaction and define the API technologies to use in each step.
Refer to the Integrating chatbots using Nexthink REST APIs documentation to understand the chatbot flow.
The following table illustrates the designed interaction steps for this use case.
- Authenticating communication 
Configure API credentials and Collect a token via the API.
- Identifying the device 
Use NQL API to allow the chatbot to identify the devices based on the username. Alternatively, use the Data Exporter. 
- Diagnosing the user device 
Use NQL API (or Data Exporter) to retrieve device performance data and outputs of the Get Startup Impact and Get Battery Status remote actions.
- Remediating the issue 
Use Remote Action API to trigger the Disk Cleanup remote action on a user's device.
- Following up on the fix 
Use NQL API to get the remediation status and details and inform the user about the remediation results.
Step 2 - Configure Nexthink content to support the chatbot integration via API
Configure API features in the Nexthink web interface. Nexthink recommends following the sequence in which the features are listed, as some are interdependent. Nonetheless, you have the flexibility to navigate between different solutions according to your preference.
Configure data-collection remote actions
Install the following remote actions from Nexthink Library:
- Get Startup Impact 
- Get Battery Status 
Schedule the executions to occur daily. Refer to Managing remote actions for more information
When you complete this step, save the NQL ID of both remote actions to use in the next steps.
NQL ID's:
- get_startup_impact_windows
- get_battery_status
Configure remediation remote actions
Install the Disk Cleanup remote action from Nexthink Library. If already Installed, copy it and configure it as follows:
- Select API for the remote action trigger. 
- Set default input parameter values that are in line with your chatbot needs. See the Input parameters for Disk Cleanup remote action table below. 
Input parameters for Disk Cleanup remote action
DiskCleanupCampaignId
If you want to display a campaign, use the library campaign disk_cleanup_invoke.
If you don’t want a campaign confirmation pop-up to appear, enter value 00000000-0000-0000-0000-000000000000
CleanupCompletedCampaignId
If you want to display a campaign, use the library campaign disk_cleanup_completed.
If you don’t want a campaign notification pop-up to appear, enter value 00000000-0000-0000-0000-000000000000
RemoveFilesNotModifiedInDays
Default value from Library (7)
MaximumDelayInSeconds
Default value from Library (30)
CleanupLevel
Choose the cleanup level, Light or Deep.
This field works only if you decide not to use a campaign and involve the employee in choosing the cleanup level. Otherwise, an employee’s choice takes precedence.
When you complete this step, save the remote action's NQL ID for use in the next steps.
NQL ID: disk_cleanup
Create NQL API queries
According to the designed scenario, you need to create three NQL API queries:
- Get user devices based on the - usernameof the user (Stage 1: Identifying device).
- Get device data to perform diagnostics for the current topic (Stage 2: Diagnosing device). 
- Get the remote action status and results (Stage 4: Following up on the fix). 
See details of each NQL API query.
When you complete this step, save the NQL ID's of all NQL API queries to use them in the next steps.
NQL ID's:
- #get_device_basic_infos 
- #diagnose_device_bad_health 
- #get_remote_action_result 
Configure API credentials
Create API credentials in the Nexthink web interface to establish secure communication between Nexthink and the chatbot. Select Remote Actions API and NQL API in the Permissions section. Refer to API credentials for more information.
When you complete this step, save the Client ID and Client Secret obtained during the credential creation in the Nexthink web interface.
Step 3 - Implement API calls within the chatbot's service layer
Once you configured all necessary API features within Nexthink, move on to implementing the Nexthink REST API calls within the chatbot's service layer.
The following stages reflect the user-chatbot interaction design.
Chatbot first stage: Authenticating communication
Prior to executing the following API calls, you first need to retrieve a valid authentication token. Refer to the Nexthink Nexthink Developer documentation on how to obtain a valid OAuth token using your generated API credentials.
Chatbot second stage: Identifying the device 
Employee (user) I have an issue with my device
To identify the device, use the #get_device_basic_infos NQL API query that you created previously (See: Get user devices based on the username of the user).
Your chatbot platform should be able to maintain session context across API calls. For example, the device identifier retrieved in this step needs to be stored and reused in later stages: diagnose, remediate, confirm fix.
Chatbot third stage: Diagnosing the device
(Chatbot) I have found the following devices for you, which one are you having issues with?
(1) Laptop XN1231242-2142 (Lenovo)
(2) Laptop XCX124231-1231 (Apple)
Employee (user) 1
To get device information, use the #diagnose_device_bad_health NQL API query that you created previously (See: Get device data to perform diagnostics for the current topic).
Chatbot fourth stage: Remediating the issue
(Chatbot) Thanks, I see that your device has only about 2 GB of free disk space left.
I can clean up unneeded files to prevent slowdowns.
Do you want me to proceed?
Employee (user) Yes
Use Remote Action API to execute Disk Cleanup remote action that you configured in the previous step and remedy the problem (See: Configuring remediation remote actions).
The Remote Action API response includes the execution status (success/failure) and any defined outputs. Your chatbot can use this information to confirm that the fix was applied successfully or to continue troubleshooting if needed.
Chatbot fifth stage: Following up on the fix
(Chatbot) I have launched the fix. It should only take a short while.
Use the #get_remote_action_result NQL API query that you created previously to get the remote action status and results.
(See: Get the remote action status and results).
Nexthink recommends making a call to get the remote action results no earlier than 1 minute after triggering the remote action with the API.
Ending the conversation
(Chatbot) I am all done - I freed up 1.3 GB. Is there anything else I can do to help you?
RELATED TOPIC
Last updated
Was this helpful?