Question about querying token for pending activity

I have an activity implementation, say,

Approve() error {
  return ErrResultPending

I register it in temporal with name “APPROVE”. Now I execute two parallel activities:


Later I will call CompleteActivity(token) twice to finish those activities. So I have to store the token for each activity in activity context like this:

Approve(activityName string) error {
  Save(activityName, GetInfo.TaskToken)
  return ErrResultPending

Is there a way to get the token from Temporal through an API by using a custom tag as key or something instead of saving it ahead of time? Thx

The solution is to specify your own ID through ActivityOptions.ActivityID for each activity and then use CompleteActivityByID API to complete them.