08 - Create the 'ServiceNow Create Incident' tool
In this module we will create a stateful workflow to create a ServiceNow incident. Our Agent Loop will leverage this workflow as a tool when processing user requests.
Create Stateful Workflow
-
Create a new workflow:
-
Navigate to the Workflows -> Workflows section of your Logic app
-
Click
+ Add -> Add
-
-
Create a new stateful workflow with:
- Workflow name:
tool-ServiceNow-CreateIncident - Select the radio button for the
Statefulworkflow type - Click
Create

- Workflow name:
-
Open the workflow visual editor by clicking on the
tool-ServiceNow-CreateIncidentlink
Configure Workflow
-
Configure the workflow trigger to accept an HTTP Request
-
Click on
Add Trigger -
Select the
Requestaction located in the Built-in tools group -
Select the
When a HTTP request is received
-
-
Configure the
When a HTTP request is receivedaction:- Request Body JSON Schema
{
"type": "object",
"properties": {
"AssignmentGroup": {
"type": "string"
},
"Description": {
"type": "string"
},
"FailureDateTime": {
"type": "string"
},
"ResolutionSteps": {
"type": "string"
},
"Severity": {
"type": "string"
}
}
}
- Request Body JSON Schema
-
Look up the internal identifier for the Assignment Group in ServiceNow. The Assignment Group is the group of the team that will be responsible for resolving the particular incident. By assigning, this value during ticket creation, we can ensure that it is assigned appropriately.
-
Add a new action. Click
+ Add an action -
Select the
ServiceNow - List Recordsaction
-
-
Configure the
ServiceNow - List Recordsaction.-
Configure the Connection:
- Connection Name:
connServiceNowDev - Authentication Type:
Basic Authentication - Instance Name: [obtained from Module 4]
- example:
devXXXXXX - can also be found in the URL of your developer instance https://[instance name].service-now.com
- example:
- Connection Name:
-
Username: [obtained from Module 4 - ]
- example: admin
-
Password: [obtained from Module 4 - ]
- Click
Create new

- Click
-
-
Configure the List Records Action as follows
- Record Type:
Group - Advanced Parameters (click
Show all) - Query:
name=@{triggerBody()?['AssignmentGroup']}

Note: ServiceNow has two types of Groups that are available in this dropdown. Unfortunately, the ordering in the dropdown is non-deterministic. To ensure that you have the right Group selected, click on the Code view tab and ensure that 'sys_usr_group' is selected. If you see one that references CMDB, you have the wrong instance and should select the other value from the dropdown.

- Record Type:
-
Add a new action
-
Select the
ServiceNow - Create Recordaction
-
Configure the Create Record action as follows:
- Record Type:
Incident - Advanced Parameters:
- you can show selected advanced parameters by clicking on the dropdown and select each parameter individually
- Short Description:
The following error occurred and needs to be investigated: @{triggerBody()?['Description']} - Assignment Group:
@{first(body('List_Records')?['result'])['sys_id']} - Description:
The following workflow failed and needs to be investigated:
Error Message: @{triggerBody()?['Description']}
Additional Information: @{triggerBody()?['FailureDateTime']}
Resolution Steps (from Operation Manual):
@{triggerBody()?['ResolutionSteps']} - Severity:
@{triggerBody()?['Severity']}

- Record Type:
-
Add the
Request (Built-in) -> Responseaction
-
Configure the Response action as follows:
- Status Code: 200
- Body:
{
"TicketNumber": "@{body('Create_Record')?['result']?['number']}"
} - Response Body JSON Schema
{
"type": "object",
"properties": {
"TicketNumber": {
"type": "string"
}
}
}

-
Click
Saveto save the changes made to the workflow
You should see a notification once the workflow is saved.