Skip to content

Connect Sellsy to AI Agents: Build Autonomous Integration Workflows

Learn how to connect Sellsy to AI agents using Truto's /tools endpoint. Build autonomous CRM and billing workflows with LangChain, Vercel AI SDK, or CrewAI.

Sidharth Verma Sidharth Verma · · 10 min read
Connect Sellsy to AI Agents: Build Autonomous Integration Workflows

You want to connect Sellsy to an AI agent so your system can autonomously research accounts, generate estimates, validate invoices, and execute revenue operations. Here is exactly how to do it using Truto's /tools endpoint and SDK, bypassing the need to build and maintain a custom Sellsy connector from scratch.

Sellsy is a comprehensive European CRM, invoicing, and accounting platform. Giving a Large Language Model (LLM) read and write access to a system that handles binding financial documents requires strict guardrails. If your team uses ChatGPT in their daily operations, check out our guide on connecting Sellsy to ChatGPT, or if you are building on Anthropic's models, read our guide on connecting Sellsy to Claude. For developers building custom autonomous workflows, you need a programmatic way to fetch these tools and bind them directly to your agent framework.

This guide breaks down exactly how to fetch AI-ready tools for Sellsy, bind them natively to an LLM using frameworks like LangChain, LangGraph, CrewAI, or the Vercel AI SDK, and execute complex revenue operations securely. For a broader look at the architecture behind this design pattern, refer to our research on architecting AI agents and the SaaS integration bottleneck.

The Engineering Reality of the Sellsy API

Giving an LLM access to an external API is easy in a prototype. You write a Node.js function, make a fetch request, wrap it in a tool decorator, and call it a day. When dealing with an enterprise system like Sellsy, this fragile approach collapses almost immediately.

Sellsy's architecture is heavily influenced by strict European accounting standards and e-invoicing regulations. If you hardcode standard REST assumptions into your agent, you will spend your sprints writing defensive integration code instead of improving your model's reasoning capabilities. Here are the three most critical Sellsy-specific API quirks you must account for.

1. The Strict Document State Machine

Most LLMs are trained to expect simple CRUD (Create, Read, Update, Delete) APIs. If an agent creates an invoice and then realizes it forgot to add a discount, it naturally attempts to send a PATCH or PUT request to update the invoice.

In Sellsy, documents like invoices, estimates, and credit notes exist within a rigid state machine. A document is created as a draft. It can then be computed to preview totals. Finally, it must be validated. Once an invoice is validated, its state is locked to comply with accounting immutability laws. Sellsy will outright reject any attempt to update a validated document. Your agent must understand this state transition flow, or it will hallucinate update operations that perpetually fail.

2. E-Invoicing Compliance and Strict Validation

Sellsy enforces European electronic invoicing (e-invoicing) reforms. This means the payloads you send to create invoices or estimates are subjected to intense validation.

For example, when an agent attempts to create a line item (a row), it cannot simply pass a price and a generic string for the tax. Sellsy requires a strictly compliant tax_id. Furthermore, recent updates force specific configuration flags, such as requiring settings.pdf_display to be true, and mandating specific text lengths for line-item descriptions. If your agent is allowed to guess these structures, it will consistently generate HTTP 400 Bad Request errors.

3. Complex Nested Search Payloads

When an LLM searches a CRM, it typically appends a simple query parameter like ?name=TechCorp. Sellsy's search endpoints, however, require complex POST requests containing deeply nested JSON filters objects.

Searching for a company might require a payload structured with filters.object_related, arrays for specific IDs, and strict timestamp formatting for date ranges. Standardizing these search payloads into JSON schemas that an LLM can consistently generate is a massive engineering undertaking if you manage the connector yourself.

Architecting a Unified Tool Layer for AI Agents

Before writing integration code, you must decide what layer your agent interacts with. Direct API tools - where you expose raw Sellsy endpoints directly to the LLM - push all of the quirks mentioned above into the model's context window.

Instead, a unified tool layer abstracts the underlying API complexity. Truto achieves this by exposing Proxy APIs. Every Sellsy integration is mapped as a comprehensive JSON object that represents how the API behaves. Sellsy endpoints are mapped into Resources and Methods. Truto handles all pagination, query parameter processing, and authentication, outputting a strict JSON schema for the LLM to follow.

A critical note on API rate limits: Sellsy enforces rate limits to protect its infrastructure. Truto does not automatically retry, throttle, or apply backoff logic on rate limit errors. This is an intentional architectural decision. When Sellsy returns an HTTP 429 Too Many Requests error, Truto passes that error directly back to the caller. However, Truto normalizes the upstream rate limit information into standardized headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset) per the IETF specification. Your agent framework is responsible for reading these headers and executing the retry and backoff loop.

Sellsy Hero Tools for AI Agents

By leveraging Truto's /integrated-account/<id>/tools endpoint, you can dynamically fetch AI-ready tools for Sellsy. Here are the highest-leverage tools you should equip your agent with to automate revenue and CRM operations.

1. Search Sellsy Companies (list_all_sellsy_search_companies)

This tool allows the agent to query the Sellsy CRM using structured filters. It handles the nested JSON required to find companies by creation dates, location, archived state, or employee count.

Usage note: Use this tool at the beginning of an agent workflow to resolve a natural language company name into a strict Sellsy company_id.

"Find the company record for 'Acme Corp' in Sellsy, ensuring you only return active, non-archived clients based in France."

2. Create an Opportunity (create_a_sellsy_opportunity)

Enables the agent to open a new deal in the CRM. It accepts structured data for the opportunity name, the target pipeline, the specific step/stage, and the related company ID.

Usage note: The LLM must pass the exact pipeline and step identifiers. Ensure your agent first queries available pipelines if it does not have the context.

"Create a new sales opportunity for the Acme Corp account we just found. Name it 'Q3 Enterprise Expansion' and place it in the first step of the Default Sales Pipeline."

3. Create an Estimate (create_a_sellsy_estimate)

Allows the agent to generate a draft estimate (quote). It handles the creation of the document header and the specific line items (rows).

Usage note: Because of strict validation, the agent must use correct tax_id values and compliant currency structures when defining the estimate amounts.

"Generate a new draft estimate for the 'Q3 Enterprise Expansion' opportunity. Add a single line item for 'Enterprise Software License' with a quantity of 50 and a unit price of 100 EUR."

4. Create an Invoice (create_a_sellsy_invoice)

This tool enables the agent to draft a new invoice. Under the electronic invoicing reform, this tool enforces strict schema rules for line items, related entities, and document settings.

Usage note: This only creates a draft invoice. It cannot be paid or considered finalized until it undergoes the validation step.

"Draft a new invoice for Acme Corp based on the accepted estimate. Ensure the line items match the 50 Enterprise Software Licenses, and apply the standard 20% VAT tax code."

5. Validate an Invoice (create_a_sellsy_invoice_validate)

Transitions a draft invoice to a due status.

Usage note: This is a one-way operation. After validation, the invoice is immutable and can no longer be edited. Ensure the agent has a "human-in-the-loop" approval step or strict programmatic checks before invoking this tool.

"The client has approved the draft. Validate invoice ID 908122 so that it becomes officially due and locked in the accounting ledger."

6. Send an Email (create_a_sellsy_email_send)

Allows the agent to dispatch emails directly from the connected Sellsy email account, useful for sending out the newly validated invoices or estimates.

Usage note: The connected email account must be active. The agent must provide the subject, content, and the "to" recipient list.

"Send an email to the billing contact at Acme Corp. Use the subject 'Your Invoice for Q3 Licenses' and include a polite message noting that the invoice is attached to their account."

This is just a curated selection of the highest-leverage Sellsy capabilities. Sellsy is a massive platform encompassing everything from inventory to subscription management. To view the complete inventory of available operations and their exact JSON schemas, visit the Sellsy integration page.

Workflows in Action

When you provide an AI agent with a unified toolset, it can chain these operations together to replace manual data entry and complex administrative sequences. Here are two real-world workflows demonstrating how an agent navigates Sellsy.

Scenario 1: Autonomous Deal Desk (Sales Rep Persona)

Sales representatives frequently waste hours transferring intent data into CRM opportunities and drafting quotes. An AI agent can handle this entire sequence autonomously.

"A new inbound lead just signed up for our enterprise tier from 'GlobalTech Industries'. Find them in Sellsy, create an opportunity for a 12-month contract, and draft an estimate for 100 user seats."

Step-by-Step Execution:

  1. The agent calls list_all_sellsy_search_companies passing {"q": "GlobalTech Industries"} into the filter payload to retrieve the company_id.
  2. The agent calls create_a_sellsy_opportunity using the retrieved company_id, setting the pipeline to the default sales track.
  3. The agent calls create_a_sellsy_estimate, passing the opportunity_id as the related object, and structures the line items for 100 user seats using compliant tax codes.

Outcome: The sales rep logs into Sellsy and finds a perfectly formatted opportunity and a draft estimate ready for review, saving 20 minutes of manual clicking.

Scenario 2: End-to-End Billing Automation (RevOps Persona)

Revenue Operations teams must ensure that when a deal is marked closed-won, the invoice is generated, validated, and sent out without delay.

"The GlobalTech deal is closed. Convert their estimate into an invoice, lock it in the system as due, and email the invoice notification to billing@globaltech.com."

Step-by-Step Execution:

  1. The agent calls create_a_sellsy_invoice, referencing the data from the previously created estimate.
  2. The agent pauses for human-in-the-loop approval, or proceeds directly to call create_a_sellsy_invoice_validate with the new invoice ID, transitioning it from draft to due.
  3. The agent calls create_a_sellsy_email_send, drafting a contextual message and sending it to the client's billing address.

Outcome: The invoice is legally locked in the accounting ledger and dispatched to the customer, accelerating time-to-revenue with zero manual intervention.

Building Multi-Step Workflows

To build these workflows in production, you need an architecture that seamlessly connects your LLM to Sellsy. Truto's /tools endpoint makes this framework-agnostic. Whether you are using LangChain, Vercel AI SDK, or CrewAI, the integration pattern remains identical.

Below is a conceptual architecture diagram of how the agent interacts with Sellsy through Truto:

sequenceDiagram
    participant App as User Application
    participant Agent as AI Agent Framework
    participant Truto as Truto API
    participant Sellsy as Sellsy API

    App->>Agent: "Draft an invoice for Acme Corp"
    Agent->>Truto: GET /integrated-account/<id>/tools
    Truto-->>Agent: Returns JSON schema of Sellsy tools
    Agent->>Agent: LLM decides to use create_a_sellsy_invoice
    Agent->>Truto: POST tool execution with arguments
    Truto->>Sellsy: Translates to Sellsy-compliant REST
    Sellsy-->>Truto: Returns created draft invoice
    Truto-->>Agent: Returns normalized JSON response
    Agent-->>App: "Invoice drafted successfully."

Handling Tool Binding and Rate Limits in Code

When writing the execution loop, you must bind the tools to your model. Furthermore, because Truto adheres to a strict pass-through philosophy for rate limits, your execution loop must be prepared to catch HTTP 429 errors and read the IETF standard headers to calculate backoff times.

Here is a conceptual TypeScript example demonstrating how you might fetch tools, bind them using LangChain, and implement a resilient execution loop:

import { ChatOpenAI } from "@langchain/openai";
import { TrutoToolManager } from "truto-langchainjs-toolset";
 
async function runSellsyAgent(prompt: string, integratedAccountId: string) {
  // 1. Initialize the LLM
  const model = new ChatOpenAI({ modelName: "gpt-4o-mini", temperature: 0 });
 
  // 2. Fetch Sellsy tools from Truto
  const toolManager = new TrutoToolManager({
    apiKey: process.env.TRUTO_API_KEY,
    integratedAccountId: integratedAccountId,
  });
  
  const tools = await toolManager.getTools();
 
  // 3. Bind tools to the model
  const modelWithTools = model.bindTools(tools);
 
  let attempt = 0;
  const maxRetries = 3;
 
  while (attempt < maxRetries) {
    try {
      // 4. Invoke the model
      const response = await modelWithTools.invoke(prompt);
      
      // 5. If the LLM decided to call a tool, execute it
      if (response.tool_calls && response.tool_calls.length > 0) {
        for (const toolCall of response.tool_calls) {
          const selectedTool = tools.find(t => t.name === toolCall.name);
          if (selectedTool) {
            // Execute the tool call against Truto's Proxy API
            const toolResult = await selectedTool.invoke(toolCall.args);
            console.log(`Tool Result:`, toolResult);
          }
        }
      }
      break; // Success, exit loop
 
    } catch (error: any) {
      // 6. Handle Sellsy Rate Limits passed through by Truto
      if (error.status === 429) {
        // Truto normalizes Sellsy's headers to IETF specifications
        const resetTime = error.headers['ratelimit-reset'];
        const delay = resetTime ? (parseInt(resetTime) * 1000) - Date.now() : 5000;
        
        console.warn(`Rate limit hit. Retrying in ${delay}ms...`);
        await new Promise(resolve => setTimeout(resolve, Math.max(delay, 1000)));
        attempt++;
      } else {
        throw error; // Throw non-retriable errors (e.g., 400 Bad Request)
      }
    }
  }
}

This execution loop demonstrates the power of the unified tool layer. The model never has to write authentication headers, format URL endpoints, or handle cursor pagination. It simply reads the JSON schema, outputs the required arguments, and lets the infrastructure handle the translation layer. Meanwhile, you retain total control over the resilience of your system by handling the ratelimit-reset headers exactly as your application requires.

Unlocking Autonomous CRM Operations

Building AI agents that reliably orchestrate revenue operations is not an exercise in basic REST fetching. The moment your agent needs to validate a European e-invoice or navigate a strict document state machine, standard prompt engineering is no longer sufficient.

By leveraging Truto's /tools endpoint, you collapse the complexity of the Sellsy API into a deterministic, AI-ready schema. You remove the hallucination surface area, offload the authentication lifecycle, and give your agent a stable set of operations to interact with. This allows your engineering team to focus entirely on improving the agent's reasoning capabilities, rather than spending their sprints maintaining broken integration code.

FAQ

How do AI agents authenticate with the Sellsy API?
Using a unified tool layer like Truto, authentication is handled at the infrastructure level. Your agent uses a single Truto API key, and Truto manages the underlying Sellsy OAuth 2.0 token lifecycle automatically.
Can AI agents automatically validate and send Sellsy invoices?
Yes. By providing the agent with the appropriate Sellsy tool definitions, such as create_a_sellsy_invoice_validate and create_a_sellsy_email_send, the LLM can chain these actions to autonomously finalize and dispatch invoices.
How do I handle Sellsy API rate limits with AI agents?
Truto passes upstream rate limit errors (HTTP 429) directly to the caller, normalizing the headers to the IETF specification (ratelimit-limit, ratelimit-remaining, ratelimit-reset). Your agent framework is responsible for reading these headers and executing the retry and backoff logic.
Does this approach work with frameworks other than LangChain?
Yes. Truto's /tools endpoint returns standard JSON schemas that can be ingested by any modern agent framework, including LangGraph, CrewAI, AutoGen, and the Vercel AI SDK.

More from our Blog