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.
- Go
- Python
- TypeScript
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 .
info
For a full tutorial, see the Temporal docs
main.py
import asyncio
import json
from temporalio.client import Client
async def main():
client = await Client.connect("localhost:7233")
result = await client.execute_workflow(
"simple-workflow",
id="your-workflow-id",
task_queue="zigflow",
)
print(json.dumps(result, indent=2))
if __name__ == "__main__":
asyncio.run(main())
Now run this script:
uv run main.py
info
For a full tutorial, see the Temporal docs
index.ts
import { Connection, Client } from '@temporalio/client';
import { nanoid } from 'nanoid';
async function bootstrap() {
const connection = await Connection.connect();
const client = new Client({
connection,
});
const handle = await client.workflow.start('simple-workflow', {
taskQueue: 'zigflow',
workflowId: nanoid(),
});
console.log(JSON.stringify(await handle.result(), null, ' '));
}
bootstrap().catch((err) => {
console.error(err);
process.exit(1);
});
Now run this script:
ts-node .
You you should see a workflow with the result:
{
"data": {
"message": "Hello from Ziggy"
}
}
🎉🎉🎉 Congratulations. You've just run your first Zigflow workflow 🎉🎉🎉