Start a workflow remotely

Hello!
I am new to Temporal, so need some guidance on this -

I have written a workflow in Go with several activities that communicate with other services. Now I want to start this workflow remotely from a different service (also written in Go). Could you advise on how would I invoke this workflow remotely?

From what I have read, it looks like I have to use the WorkflowService, but not sure how? Is that the right approach? If so, is there an example I can look at?

Thanks

I want to start this workflow remotely from a different service

You can use just the client apis of Temporal SDK, for example here

Thanks for your reply @tihomir.
I am familiar with this. But I want to start the workflow from a different service. Is WorkflowService the way to go?
https://pkg.go.dev/go.temporal.io/api@v1.21.0/workflowservice/v1

You don’t have to use the apis directly, the SDK abstracts those for you so for example

c.ExecuteWorkflow

calls the StartWorkflowExecution api.

On your different service side if you use temporal sdk you would just need to specify your temporal service target (endpoint) and namespace (if its not “default”), for example:

c, err := client.Dial(client.Options{
	HostPort: "host:7233",
	Namespace: "my-namespace",
})

I see. I tried the code below and I get an error that TestWorkflow is undefined. Am I missing something?

c, err := client.Dial(client.Options{
		HostPort: "localhost:7233",
		Namespace: "default",
	})

	// Executing the workflow
	we, err := c.ExecuteWorkflow(context.Background(), options, TestWorkflow, "Test")

Note that the worker is already running in the other service and this workflow is registered with it.

Use string name of the workflow if it is not defined in this process.

	we, err := c.ExecuteWorkflow(context.Background(), options, "TestWorkflow", "Test")
2 Likes

Thank you @tihomir and @maxim for your help . That worked!