Skip to main content

Your First Workflow

Below is a simple YAML workflow that sets a message to your workflow's state and outputs it

workflow.yaml
document:
dsl: 1.0.0
namespace: zigflow
name: simple-workflow
version: 1.0.0
do:
- set:
export:
as: data
set:
message: Hello from Ziggy

Running your workflow

You can now run this workflow with Zigflow

zigflow -f ./workflow.yaml

Triggering your workflow

Now you have a running workflow, you need to build an application that will trigger it. Temporal

tip

Consider doing the Temporal 101 course to give you a better understanding of how Temporal works and the key concepts.

info

For a full tutorial, see the Temporal docs

main.go
package main

import (
"context"
"fmt"

"go.temporal.io/sdk/client"
)

func main() {
client, err := client.Dial(client.Options{})
if err != nil {
panic(err)
}
defer client.Close()

workflowOptions := client.StartWorkflowOptions{
TaskQueue: "zigflow",
}

ctx := context.Background()
workflowRun, err := client.ExecuteWorkflow(ctx, workflowOptions, "simple-workflow")
if err != nil {
panic(err)
}

var result any
workflowRun.Get(ctx, &result)

r, err := json.MarshalIndent(result, "", " ")
if err != nil {
panic(err)
}

fmt.Println(string(r))
}

Now run this script:

go run .

You you should see a workflow with the result:

{
"data": {
"message": "Hello from Ziggy"
}
}

🎉🎉🎉 Congratulations. You've just run your first Zigflow workflow 🎉🎉🎉