Cadence allows normal (non-local) be completed externally. This can be useful when an external system needs to be responsible for completing an operation. You can take advantage of this in your activity implementation by retrieving the TaskToken from Task. This is an opaque byte array that identifies the running task.
You'll need to persist this somewhere (like a database) that the external system has access to and then your activity will call DoNotCompleteOnReturn and then it will return.
Cadence will see the DoNotCompleteOnReturn call and no result will be returned to the calling workflow (yet). Instead, Cadence will wait for the the external system to complete the activity by calling ActivityCompleteByTokenAsync or fail the activity via ActivityErrorByTokenAsync. The activity returns to the calling workflow when one of these methods is called.
Note that the activity timeouts still apply for externally completed activities. This means that the external system may need to submit heartbeats to Cadence via ActivityHeartbeatByTokenAsync when a heartbeat timeout is specified.
Activities can also be completed externally by ID.