Define a task, a function in your project that does one job and returns a result, then run it with a payload: by hand, on a schedule or from a webhook.
Before you start
You need a project. See Create a project.
Write a task
- Add the task. Its file name is its ID:
tasks/word-count.ts
export default { name: "word-count", description: "Count the words in a text.", schedulable: true, async run({ input }) { return { words: String(input.text).trim().split(/\s+/).length }; },}; - Run it on your machine.
--configis the payload:Shellnpx veryfront task word-count --config '{"text": "Veryfront runs agents, tasks and workflows"}' - Read the result: it prints
"words": 6. - Start the project with
npm run dev(Work locally) and open Building blocks > Tasks in Studio. You should now seeword-countlisted.
Try it in a sandbox
Create a project
Add the task
Check it