User interactions and approvals
Some steps need a person. A change needs an approval, a request is missing a detail, or an operator has to confirm that a maintenance window really has started. Orchestrator handles this with the User interaction element. When a run reaches it, the run stops and waits for someone to fill in a small form. Their answers go into the run’s variables, and the workflow carries on with them.
In this recipe you build Approve a VM description. It asks for approval before it runs Describe a VM from recipe 3.1, logs the reason if the request is rejected, and gives up cleanly if nobody answers in time. The workflow only reads from vCenter, so you can try the whole approval loop without risk.
Getting ready
- The workflow
Describe a VMfrom recipe 3.1, and the folder VCF Orchestrator Guide/Chapter 3. - A second login to answer with, if you want to see the approval from the approver’s side. It doesn’t need an Orchestrator role: Broadcom’s role table says users without one can still respond to user interaction requests.
- The idea of an exception path from recipe 3.4, and of the long-running elements from recipe 3.7.
How to do it
Set up the workflow
- Create a workflow called
Approve a VM descriptionin VCF Orchestrator Guide/Chapter 3. - On the Inputs/Outputs tab, add:
- An input
vmof typeVC:VirtualMachine. - An input
approvalHoursof typenumber. On the Input Form tab later, you can give it a default of24. - An output
summaryof typestring.
- An input
- On the Variables tab, add four variables:
| Name | Type | Holds |
|---|---|---|
approvalDeadline |
Date |
The time the request stops waiting |
approved |
boolean |
The approver’s answer |
approverComment |
string |
The approver’s reason |
approvalError |
string |
The error if nobody answers in time |
- On the Schema tab, add a scriptable task called
Set the deadline, withapprovalHoursin andapprovalDeadlineout:
// approvalHours can be a fraction: 0.05 is three minutesvar waitMs = Math.round(approvalHours * 60 * 60 * 1000);approvalDeadline = new Date(new Date().getTime() + waitMs);System.log("Waiting for approval until " + approvalDeadline);Add the user interaction
- From the Generic group of the palette, drag a User interaction onto the arrow after
Set the deadline. Name itAsk for approval. - Select it and open Options. Bind
timeout.datetoapprovalDeadline. Leavesecurity.group,security.assignees, andsecurity.assignee.groupsunbound for now. There’s more shows what they do. - Add the two answers the approver gives. Under Form Inputs, click + and pick
approved, then + again and pickapproverComment. These are the fields the approver sees, and their answers are written back to these variables. Adding them here also lays out a default answer form. - The workflow now has an extra tab, named after the element: Ask for approval. Open it (or click Edit input form on the element). Select each field and, on Appearance, set the Label:
Approve this requestforapprovedandReasonforapproverComment. On the Constraints tab ofReason, set Required to Yes. The editor is the same one you used on the Input Form tab in recipe 3.6.

Fill in the form inputs with + in the editor, not only in an imported or hand-edited workflow file: a user interaction without a laid-out form shows the approver an empty dialog.
Act on the answer
- Drag a Decision onto the arrow after
Ask for approval. Name itApproved?, choose the variableapproved, and the condition is true. - On the decision’s true path, drag the workflow
Describe a VMfrom the library. Bind its inputvmtovmand its outputsummarytosummary. - On the false path, add a scriptable task called
Log the rejection, withvmandapproverCommentin andsummaryout, and link it to an end element:
summary = "Request for " + vm.name + " rejected: " + approverComment;System.warn(summary);Handle the timeout
- Select
Ask for approvalagain. Under its exception handling, chooseapprovalErroras the variable that receives the error. - Drag a scriptable task onto
Ask for approvalitself, not onto an arrow. Orchestrator draws a red dashed exception arrow to it. Name itLog the timeout, withapprovalDeadlineandapprovalErrorin andsummaryout, and link it to an end element:
summary = "No answer before " + approvalDeadline + ". Nothing was done.";System.warn(summary + " (" + approvalError + ")");- Click Save.

Answer it
- Run the workflow with any VM and
approvalHours=1. The run logs its deadline, then stops in the Waiting state. - As the approver, open Activity > Waiting for Input. The run appears there as a card, and on the Dashboard under Waiting for Input. Click Answer on the card to open the form from step 8.
- Select Approve this request, type a reason, and click Answer. The run carries on, runs
Describe a VM, and completes with the VM’s summary in itssummaryoutput.

- Run it again and answer with Approve this request cleared. The run follows the false path and logs the rejection with your reason.
- Run it a third time with
approvalHours=0.05and don’t answer. After about three minutes, the run follows the exception path toLog the timeoutand ends Completed. In the lab the timeout fired ten seconds after the deadline, andapprovalErrorheld Timeout on signal.
How it works
A user interaction is a long-running element, like the waiting timer and waiting event in recipe 3.7. When a run reaches it, Orchestrator saves the run to its database, frees the run’s thread, and creates a user interaction object: a record that says which run is waiting, which fields it needs, who may answer, and until when. The run sits in the Waiting state, using no thread, for as long as it takes. A restart of the server doesn’t lose it.
When someone answers, Orchestrator checks that they’re allowed to, writes their values into the variables listed as the element’s form inputs, and picks the run up again at the next element. From there it’s an ordinary run. The decision in step 9 reads approved like any other variable.
Its special inputs control the waiting:
timeout.dateis the deadline. When it passes with no answer, the element throws an exception. With an exception path, as in step 13, the workflow handles it. Without one, the run fails. Leave it unbound and the run waits for ever.security.group,security.assignees, andsecurity.assignee.groupssay who may answer. With none of them bound, the request isn’t restricted to particular people.
Answering is just another call to the Orchestrator REST API. The client calls it when you click Answer, and so can any other system, which is how a ticketing tool or a chat bot can approve a run.
There's more
Choose who answers. Bind one of the security inputs to restrict the approvers. security.group (LdapGroup) takes one group, and only its members can answer. security.assignees (Array/LdapUser) takes a list of users, and security.assignee.groups (Array/LdapGroup) a list of groups. Which users and groups you can pick depends on the authentication provider from Chapter 1. With vSphere authentication, they come from vCenter Single Sign-On. With a VCF Automation organization, they come from that organization.
security.assignees to one user and confirm that another non-administrator can’t answer, that an Orchestrator administrator can, and how a user or group value is picked in the form.Answer from a script or another system. The REST API has one call to read a waiting interaction and one to answer it, both under the run that’s waiting. To find the waiting runs, list GET /vco/api/interactions. To read the form of one, call GET on the run’s interaction, and to answer, POST the values to the same address:
# WF_ID is the workflow's ID, RUN_ID the waiting run's ID, TOKEN a bearer token (Chapter 7)curl -k -X POST \ "https://vco01.vmw.lab/vco/api/workflows/$WF_ID/executions/$RUN_ID/interaction" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"parameters": [ {"name": "approved", "type": "boolean", "value": {"boolean": {"value": true}}}, {"name": "approverComment", "type": "string", "value": {"string": {"value": "Approved from the API"}}} ]}'The call returns 204 No Content when the answer is accepted, and the run carries on at once: tested on 9.1.1, both with an approval and with a rejection. A DELETE on the same address cancels the interaction. Chapter 7 shows how to get a token and find workflow and run IDs.
Approvals in VCF Automation. VCF Automation has its own approval policies for catalog requests. They’re separate from user interactions and answered in VCF Automation, not in the Orchestrator Client. Use an approval policy when the question is “may this person order this item?”, and a user interaction when a step in the middle of a workflow needs a decision. Chapter 8 covers the VCF Automation side.
Send a reminder. Nobody watches Waiting for Input all day. Before the user interaction, send the approver an email or chat message with the VM name, the deadline, and a link to the client. The mail plug-in is covered in Chapter 5.
Keep deadlines realistic. A request that waits for a week ties up nothing on the server, but it does keep a half-finished change in flight. Pick a deadline that matches how the approvers work, and make the timeout path tell someone that the request expired.
Ask for more than yes or no. The answer form can hold any input type, with defaults, drop-downs filled by actions, and validations, exactly as in recipe 3.6. An approver can pick a datastore, correct a hostname, or choose a change window, and the workflow uses the answer like any other variable.
See also
- 3.4 Handling errors and exceptions, for exception paths.
- 3.6 Building input forms, for the form editor used in step 8.
- 3.7 Waiting tasks and custom events, for the other long-running elements.
- Broadcom TechDocs (VCF 9): Set the User Interaction security.group Variable, Set the timeout.date Variable to an Absolute Date, Create the Input Parameters Dialog Box for the User Interaction, Define User Interaction Exception Behavior, and VCF Operations orchestrator User Roles.
- Broadcom developer documentation (VCF Operations Orchestrator API, latest): Workflow Run Service, Answer User Interaction, and List User Interactions.
- CloudBlogger, the author’s blog: User Input Requests in Service Broker Inbox: More than Approvals.
