Module 12 - Create Tool - ServiceNow Close Incident
In this module we will create a stateful workflow to close an existing ServiceNow Incident. Next, we will incorporate the workflow into our Agent Loop at as tool to enable the agent to close and provide some resolution comments for our ServiceNow Incident .
Create the Stateful Workflow
-
Search for and navigate to the Logic Apps service
-
Open the Logic App created earlier
-
Create a new workflow
-
Click the
Workflows -> Workflows
from the menu on the left -
Click
+ Add -> Add
-
-
Create a new stateful workflow with:
- Workflow name:
tool-ServiceNow-CloseIncident
- Select the radio button for the
Stateful
worflow type - Click
Create
- Workflow name:
-
Open the worflow visual editor by clicking on the
tool-ServiceNow-UpdateIncident
link (if the workflow designer isn't opened automatically)
Configure Workfow
-
Configure the workflow trigger to accept an HTTP Request
-
Click on
Add Trigger
-
Select the
Request
action located in the Built-in tools group -
Select the
When a HTTP request is received
-
-
Configure the
When a HTTP request is recieved
action:- Request Body JSON Schema
{
"type": "object",
"properties": {
"TicketNumber": {
"type": "string"
},
"Notes": {
"type": "string"
}
}
}
- Request Body JSON Schema
-
Look up the internal identifier for the Incident in Service Now
-
Add a new action. Click
+ Add an action
-
Select the
ServeNow - List Records
action
-
-
Configure the List Records Activity as follows
-
Rename activity to
List Records - Get Ticket Details
-
Record Type:
Incident
-
Advanced Parameters (click
Show all
) -
Query:
number=@{triggerBody()?['TicketNumber']}
(note: notice that the connection for the ServiceNow connection was automatically selected for the activity)
-
-
Add the Update Record action to update the work notes on the incident in ServiceNow
-
Click on the
+
->Add a Action
-
Search for
SearchNow
Connector and select theUpdate Record
Activity
-
-
Configure the Update Record action
-
Rename activity to
Update Incident Work Notes
-
Record Type:
Incident
-
System ID: (using the expression (fx) editor)
first(body('List_Records_-_Get_Ticket_Details')?['result'])['sys_id']
-
State: (Advanced Parameter)
7
-
Resolution Code:: (Advanced Parameter)
Solution Provided
-
Resolution Notes:: (Advanced Parameter)
@{triggerBody()?['Notes']}
-
-
Add the Response activity to return a status message to the calling process
- Click on the
+
->Add a Action
- Search for and select the
Response
activity
- Click on the
-
Configure the Response activity
- Body:
{
"status": "Ticket {@{triggerBody()?['TicketNumber']}} has been updated successfully"
}
- Body:
-
Save your workflow