Human tasks on workflows triggered from a user agent

Use case

Build an interactive workflow that is triggered from a user agent (for example, a browser).

An example flow:

  1. User initiates an action on a browser to trigger a workflow
  2. HTTP request handler executes workflow using a pre-initialized workflow client
  3. Certain activities performed until an activity is reached to require user input
    • Notice here the goal is not to send an email or notification via some other channel to collect that user input
  4. HTTP handler responds with a page. How does the handler know to do this? Is there a way for the workflow to communicate back to the “client” to indicate that the human action needs to be performed?
  5. User is shown a page on the browser to complete a form and submits
  6. Backend updates workflow and signals completion? If the issue at 4 can be addressed, signalling the workflow becomes trivial, possibly.

I am pretty new to Temporal, so I might be missing something obvious. Can you please help? I am using the Go-SDK.

Is Query perhaps the way to do this?

  1. The HTTP handler basically polls for the state of the workflow
  2. Workflow sets the query result when a task requiring an interrupt is encountered. The query result contains the signal to be sent when the task is completed.
  3. HTTP handler presents the page with the appropriate signal embedded within a callback/post URL.

The other option would be to use Update, but the goal here isn’t to change the state of the workflow, so I am not sure it is appropriate. The answer here appears to indicate it is the way to go though - Receive a workflow signal from a client

  1. Calls UpdateWithStart
  2. Executes activities then completes Update wich unblocks UpdateWithStart call.
  3. Based on the result of the Update the corresponding page is generated.
  4. No changes
  5. Calls Update.