In this article, you will learn how to build and execute custom thunks. Before you start:
Acquire a high-level understanding of the core concepts of a thunk -- workflow, steps, AI agents, tools, content folders -- and the design and runtime environment of Thunk.AI
It is also useful to browse some of the sample thunks. After you sign in, you'll find a collection of sample thunks. These are simplified examples of AI automations across various industries—these aren’t just templates; they’re fully-functional samples. For example, in the Expense Receipt Processing sample, the AI automation logic extracts receipt details, checks them against company policy, recommends a decision, and drafts an email—automating the entire process. Watch this video to explore the Thunk and learn how to build one yourself!
You can copy any sample into your account, add or remove steps, alter step instructions, add your own content, and try it out on your data.
Step 1: Build your first, custom Thunk
A new thunk is first designed and then run on data. We will use this sample thunk "Processing purchase orders" as a running example in this tutorial and build something similar from scratch. In this section we will cover how to:
Design the thunk with AI-driven planning
Run the thunk
Customize and refine the thunk
4.1 Design the thunk with AI-Driven Planning
To start designing your thunk, you'll need to answer a few simple questions about your desired workflow. Click on the Create a New Thunk button on the homepage.
What is the goal?: Define a concise description for your workflow (eg: "Process purchase orders."). Aim for less than 7 words, usually a verb followed by a noun.
What is the workflow input? This is usually a short descriptive noun from the particular domain of the business workflow (eg: "Purchase Order"). The platform will prompt you with a suggestion which you can, of course, edit. Aim for semantic names here (eg: these names are good --- "Job Applicant", "Purchase Order", "Sales Lead", "Payment Transaction") rather than some low-level implementation term (eg: these names are not optimal -- "database row", "spreadsheet row", "data file", "email message", etc). Remember that the AI agent usually does better the more it is able to deduce the semantic meaning of what it is supposed to do. You can also provide examples of inputs. Especially when dealing with files and images, this can be extremely useful to help the AI planning process. You can also provide details about the inputs (eg: "Each purchase order will include product details, quantities, and payment information.").
What is the workflow process?: Outline your process as a list of steps, as you would explain it to a co-worker. The platform will provide an initial process suggestion, but almost always, you'd want to customize this to reflect your specific business process. For example: "(1) Extract and validate the order details, (2) ensure payment terms are acceptable, and (3) forward the confirmed order to the fulfillment team.". You also have the opportunity to provide any other information about the process.
Your AI will now take a minute or so to navigate you through (i) plan outline generation (ii) workflow state generation and (iii) plan details generation.
(i) Plan generation: Your AI uses information you provided to create a workflow with sequential steps.
(ii) Data Structure Identification: Your AI determines the important data to record during execution—e.g., invoices, payment amounts, approvals for invoice processing.
(iii) Plan Details: Finally, your AI planning agent refines the Plan Details to prepare the AI agents for execution.
At this crucial stage of planning, it is useful to look at the AI Instructions associated with each step and modify them as appropriate. AI Instructions include at least the following components: (a) Guidance for the AI Agent -- this includes instructions and examples, and (b) Definition of the Control Sandbox -- this includes constraints on input and output data, constraints on AI tools, and consistency check definitions. You do not need to get all of this perfect initially, but as you test your prototype, you will probably come back to change these components of your thunk.
Pro Tip: Detailed instructions and control sandbox constraints ensure consistent execution and reliable results. Learn more about how Thunk.AI ensures reliable agent behavior.
Hit the "Proceed" button to tell your AI agent to complete its planning work, and that's it! Your thunk is live and ready to execute!
4.2 Execute your thunk
Your thunk is now ready to accept workflow requests. As requests arrive, your AI will process them step by step, following your instructions. After each step, you can review outputs, adjust data, update instructions, and rerun the work if needed. Let’s dive into the details!
Add a workflow request
To begin, click on the Add button to create a new workflow request. This brings up a dialog that shows you a chat window with your AI agent. That gives you the flexibility to add multiple rows (eg: "open this spreadsheet https:.... and import each row as a workflow request"). All the same, the simplest way to start is to use the "Add using a form" option and that lets you add a single request.
Later, you can explore the various input options (like the email inbox or webhook endpoint that every thunk has). These are potentially more efficient and automated mechanisms to bring requests into a thunk.
When a request is added, a new workflow entry is created and the Thunk.AI runtime begins working on it following the defined workflow orchestration.
Pro Tip: New thunks are optimized for quick onboarding. By default, when new entries are added, they are processed immediately (instead of starting in a "draft" mode waiting for you to kick off the work) and move through each step without waiting for approval. You can adjust these settings under AI Governance > Human-in-the-Loop to enable more control.
Workflow Execution
The workflow orchestration logic in the platform kicks off each step in sequence and sets up the appropriate AI agent to run it.
Most likely, at this stage of early prototyping, you do not have any collaborators or human agents participating in this thunk. So every step will be assigned to you. However, be aware that if there were more users with access to the thunk, you can set up assignment logic that your AI agent will use to assign the step to an appropriate user. Learn how to add users and define assignment logic.
Step Execution
When a step is assigned to you, you will be able to observe your AI agent execute the step on your behalf. Your AI agent follows the instructions laid out for the step, relies on the inputs provided, utilizes tools available to it, does the work and records results in the appropriate result data properties. You do not need to be signed in or watching this happen. However, both in real time or after the fact, you can examine a log of the interaction between the control sandbox and the AI agent in doing the task and completing the work. If you human-in-the-loop intervention is needed, the platform or the AI agent itself will request your intervention with appropriate context.
Monitor & Review AI Work
The collapsible/expandable AI pane on the right shows you the working of your AI agent. You can track it in real-time or review it after the fact. Of course, the results of each step are stored in workflow state properties, that are persistent, easily visible to you and other users of the thunk, and these properties become inputs into subsequent workflow steps.
Step 5: Congratulations!
🎉
You've successfully created your first thunk. Now learn more about how to refine, iterate, and improve what you've just built.
There's so many more thunks you can build and workflows you can automate with AI agents. Happy thunking! Please reach out to us via https://community.thunk.ai or [email protected] if you have questions or need assistance in building your thunks.











