Home / SAP Joule Guide / Building Agents

How to Build Your First Custom Joule Agent (Step by Step)

A practical path from API layer to deployed agent in Joule Studio, with the order and habits that avoid the usual failures.

Building Agents10 min readUpdated Dec 2026
TL;DR
  • Build in this order: API layer (actions) → agent → instructions → test → deploy. Agents are only as good as the tools you give them.
  • You can build in Joule Studio low-code or pro-code. You don’t have to write code for a first agent.
  • Pick a narrow, high-volume task for agent #1. “Explain why this sales order is blocked” beats “manage order-to-cash”.

Joule Studio is SAP’s environment for building custom AI agents, skills, apps and workflows in SAP Build. This guide walks through the build path we use with clients for a first agent on S/4HANA. Screens and menu names change between releases, so follow the flow, not exact button labels.

Prerequisites

  • A BTP subaccount with SAP Build and Joule Studio enabled, and the right role collections assigned to you.
  • Joule Base or AI Units in place, since Joule Studio runtime services require one of them (see AI Units explained).
  • One working BTP destination to your S/4HANA system. Reuse a single, well-configured destination across scenarios rather than creating one per agent (see authentication and destinations).
  • A clear use case with a measurable outcome.

Pick the right first use case

Good first agents have high volume, clear data in S/4HANA, and a human who makes the final call. Examples:

Order credit-block reviewRead the order, customer exposure and payment history, then recommend release or hold.
PO delivery delay checkFind late POs, check supplier confirmations and draft follow-ups.
Invoice exception triageExplain why an invoice is blocked and propose the next step.

Step 1: Build the API layer first (actions)

Before you create the agent, build and test the tools it will use. In SAP Build, an action wraps an API (usually an S/4HANA OData service) so agents and workflows can call it.

  1. Choose the APIFind the standard S/4HANA API on SAP Business Accelerator Hub (for example Sales Order or Business Partner), or use your own RAP service.
  2. Create an action projectImport the API specification and select only the operations and fields the agent needs.
  3. Bind your destinationPoint the action at your existing S/4HANA destination.
  4. Test each actionRun it with real keys and confirm the response before any AI is involved.
  5. Release itPublish the action so the agent project can use it.
Why actions first? Most agent failures are really API failures: wrong fields, auth errors, or responses that are too big. Fix those while they’re easy to see. Full walkthrough: connect S/4HANA OData APIs as Joule actions.

Step 2: Create the agent

In SAP Build, create a new Joule agent project in Joule Studio. Give it a clear name and a short description of what it does. Joule uses that description to decide when to route a user’s request to your agent.

Then add its tools: the actions you just released, any existing Joule skills, documents for grounding, and (if needed) external tools through Model Context Protocol (MCP) servers. Agents can also call other custom agents.

Step 3: Write the instructions

The instructions are the agent’s job description. Be specific:

Role: Order-to-cash credit analyst for company code 1010.
Goal: When asked about a blocked sales order, explain why it is
blocked and recommend RELEASE or HOLD with a short reason.
Steps:
1. Get the sales order header and credit status.
2. Get the customer's open items and overdue amount.
3. Compare exposure to credit limit.
Rules:
- Never release an order yourself. Only recommend.
- If data is missing, say what is missing. Do not guess.
- Answer in under 120 words, with the key numbers.

Clear steps and hard rules cut wasted tool calls (which also saves AI Units) and lower the risk of made-up answers.

Step 4: Test

  • Use the test chat in Joule Studio with real document numbers.
  • Try the edge cases: missing data, wrong IDs, users without authorization.
  • Check which tools the agent called and in what order. Tighten instructions where it wanders.
  • Keep a small set of test prompts and expected answers to rerun after every change. See testing and governing agents.

Step 5: Deploy

Release the project and deploy it to your environment. Once deployed, users reach the agent through Joule. Every agent is registered in SAP’s AI Agent Hub inside Joule Studio, which gives you a portfolio view and scheduled evaluations to catch drift.

Start with a small pilot group, measure usage and accuracy for two to four weeks, then widen access.

Frequently asked questions

Do I need to code to build a Joule agent?

No. Joule Studio supports low-code agent building, and pro-code options exist when you need them.

What should I build first, the agent or the API?

Build and test the API layer (actions) first. Most agent problems are actually data or API problems.

Can a Joule agent call non-SAP systems?

Yes. Custom agents can connect to SAP and non-SAP systems, including through MCP servers.

How do users access a custom agent?

After you deploy it, users reach the agent through Joule in their SAP applications.

Keep reading

Want this built in your landscape?

We design and ship Joule agents on S/4HANA, from API layer to production.

Book a Discovery Call
© 2026 erpai.blogSAP, S/4HANA and Joule are trademarks of SAP SE. Screens show illustrative sample data.