
This assumes you are familiar with Flow Designer. If not, check out my article FreeKB - ServiceNow - Getting Started with Flows.
Queue Work and Wait for Callback can be used to determine if a task completed successfully. For example, let's say you have a task that runs some home-grown automation. In this example, Queue Work is used to "queue up" the home-grown automation, then the home-grown automation is run, and Wait for Callback is used to determine if the home-grown automation completed successfully.

Queue Work is pretty simple. We just need to enter a name for the Worker and Task.

Queue Work will generate a callback URL, which will be something like this.
https://acme.service-now.com/api/x_thffl_callback/callback/3b2f0b151b819ad0464adb56dc4bcb6a
In this scenario, when invoking the home-grown automation, the callback URL will need to be provided to the home-grown automation. For example, perhaps the home-grown automation accepts JSON input. In this example, the callback URL is provided to the home-grown automation as JSON.

For the sake of this tutorial, let's say the home-grown automation is Ansible and the Ansible automation removes all of the files and directories at and below the /tmp directory. The home-grown Ansible automation may look like this, where first the /tmp directory is cleaned up and then a POST request is made to the ServiceNow callback URL with JSON body { "result": "success" }
---
- hosts: all
tasks:
- ansible.builtin.file:
path: /tmp
state: absent
- ansible.builtin.uri:
url: "{{ callback_url }}"
method: POST
body_format: json
body: "{ \"result\": \"success\" }"
...
Last but not least, Wait for Callback is used to, as the name suggests, wait for a callback from the home-grown automation. Or more specifically, to wait for a POST request to the ServiceNow callback URL. In this example, the callback waits for 5 minutes.

After invoking this flow, Status in Wait for Callback will be Response if the home-grown Ansible automation was able to POST to the ServiceNow callback URL and Response should contain the JSON body, which is { "result": "success" } in this example.

Did you find this article helpful?
If so, consider buying me a coffee over at