Create a task
This guide shows you how to create tasks in Lattice using custom task definitions that you’ve published to the Lattice Schema Registry (LSR). Custom task definitions allow you to extend Lattice’s tasking capabilities with your own specialized workflows.
When working with custom tasks:
- First, you retrieve your JSON Schema definitions from the Schema Registry
- Then you validate your task data against these schema definitions
- Finally, you use the validated data to create tasks in Lattice using the
CreateTaskAPI
Before you begin
- You need to have custom schemas defined and published to the Lattice Schema Registry.
- To create tasks, set up your Lattice environment.
- Familiarize yourself with tasks in Lattice.
Get the JSON schemas
When you push your Protobuf definitions to the Schema Registry, they’re automatically converted to JSON Schema files. These files help validate your task data before sending it to Lattice.
Log in to the Schema Registry dashboard using your credentials.
Example JSON Schema structure for a custom task:
Create a task
To create a task using a custom task definition, do the following:
Prepare your task data
Define the data for your custom task that matches your schema structure.
This data will be encapsulated in the specification
field of the CreateTaskRequest message.
Validate task data using the schema
Before sending data to Lattice, validate it against the JSON Schema to ensure it matches your custom task definition. This prevents issues when submitting invalid task data to the API.
Create the task using validated data
Use the CreateTask API to submit your task to Lattice. This API expects the following key fields:
description: A human-readable description of the task (up to 4096 characters)specification: Your validated task data wrapped in a Google Protocol BufferAnymessageauthor: Information about who or what created the taskinitialEntities: Optional list of entities that should be associated with the task
The response contains a Task object with details including the assigned task ID and initial status,
which starts as STATUS_CREATED in the task lifecycle.
What’s next?
- Learn how to listen for tasks as an agent.
- Learn how to update task status as your agents make progress.
- Explore the Task Manager API reference documentation for more details.