Skip to content

Connect Thena to AI Agents: Sync Tasks and Automate Customer Data

Learn how to connect Thena to AI agents using Truto's /tools endpoint. Bind unified tools to LangChain or Vercel AI SDK to automate support tasks, tickets, and customer data.

Nidhi KN Nidhi KN · · 9 min read

You want to connect Thena to an AI agent so your system can independently read customer contacts, generate account tasks, execute federated searches, and resolve support tickets based on historical context. Here is exactly how to do it using Truto's /tools endpoint and SDK, bypassing the need to code dozens of distinct REST endpoints manually.

Giving a Large Language Model (LLM) read and write access to a platform like Thena is an engineering headache. You either spend weeks building, hosting, and maintaining a custom connector that correctly handles Thena's polymorphic data models, or you use a managed infrastructure layer that normalizes the boilerplate for you. If your team uses ChatGPT, check out our guide on connecting Thena to ChatGPT, or if you are building on Anthropic's models, read our guide on connecting Thena to Claude. For developers building custom autonomous workflows, you need a programmatic way to fetch these tools and bind them to your agent framework.

This guide breaks down exactly how to fetch AI-ready tools for Thena, bind them natively to an LLM using a framework like LangChain, LangGraph, CrewAI, or Vercel AI SDK, and execute complex customer support operations workflows. For a deeper look at the architecture behind this approach, refer to our research on [architecting AI agents and the SaaS integration bottleneck](/architecting-ai-agents-langgraph-langchain-and-the-saas-integration-bottleneck/).

The Engineering Reality of Custom Thena Connectors

Building AI agents is relatively straightforward. Connecting them to external SaaS APIs safely is not. Giving an LLM access to external data often starts as a simple prototype where you write a Node.js function wrapping a fetch request in an @tool decorator. In production, this brittle approach collapses entirely, especially with an ecosystem as robust as Thena.

If you decide to integrate Thena manually, you own the entire API lifecycle. Thena's API introduces several specific integration challenges that routinely break standard LLM assumptions and induce hallucinations.

Polymorphic Entities and Threaded Relationships

Thena handles interactions dynamically across multiple domains. When an agent attempts to leave a comment, it cannot simply hit a /comments endpoint with a text string. The API requires a polymorphic declaration - the agent must know how to specify both the entityType and the entityId. If your agent framework is guessing these schemas based on vague system prompts, it will frequently attempt to attach comments to invalid or non-existent entities. Furthermore, threaded replies require specific sub-trees (thena_comments_list_threads), meaning your agent must navigate complex parent-child relationship structures just to read a conversation.

Deep Configuration Schemas Over Flat Fields

Unlike simpler CRMs where an issue status is a flat string ("status": "open"), Thena leverages complex nested configurations for nearly every core primitive. Tasks, activities, and accounts utilize deep configuration objects like typeConfiguration, statusConfiguration, and priorityConfiguration. If you manually expose Thena's raw endpoints to an LLM, the model must perfectly infer the exact shape of these configuration objects. A single hallucinated key inside statusConfiguration will cause a fatal HTTP 400 rejection.

Federated Search Complexities

AI agents rely heavily on context retrieval. Thena provides a powerful federated search endpoint, but it requires the caller to construct complex multi-query payloads specifying exactly which collections (tickets, comments, accounts, customer_contacts, etc.) to target, alongside specific fields to query. Teaching an LLM to accurately write a Thena-specific federated search payload is a massive context sink.

Instead of exposing these raw quirks, a unified tool layer abstracts the complexity. The agent receives clean, normalized JSON schemas where parameters are strictly enforced.

sequenceDiagram
    participant LLM as "LLM / Agent"
    participant App as "Your App (LangChain)"
    participant Truto as "Truto API"
    participant Thena as "Thena API"
    
    App->>Truto: GET /integrated-account/<id>/tools
    Truto-->>App: Returns unified JSON tool schemas
    App->>LLM: .bindTools() (Registers capabilities)
    LLM->>App: Agent decides to search Thena
    App->>Truto: POST /proxy/thena_search_federated_search
    Truto->>Thena: Executes complex search payload
    Thena-->>Truto: Returns raw search results
    Truto-->>App: Normalizes pagination & response
    App-->>LLM: Feeds context back to agent

Accessing Thena Tools Programmatically

Truto maps every Thena API endpoint into a Resource with distinct Methods (List, Get, Create, Update, Delete, Custom). These Proxy APIs handle all authentication injection and query parameter processing, returning data in a predictable format.

By calling the GET https://api.truto.one/integrated-account/<id>/tools endpoint, your infrastructure retrieves a complete, dynamically generated list of tools that describe the Thena API via strict JSON Schema. You pass these schemas directly into your LLM framework of choice.

Thena Agent Tools: The Heroes

Rather than hand-coding wrappers for Thena's 100+ endpoints, you can selectively activate the highest-leverage tools for your agent. Here are the core hero tools you need for robust support operations.

Create a Thena Ticket (create_a_thena_ticket)

This tool allows the agent to autonomously open new support tickets. The agent must provide a title, a requestor email, and the appropriate team ID. The API returns a comprehensive ticket object, including a nested comment entity that represents the opening message.

"A VIP customer, Sarah at Acme Corp, just emailed saying her payment gateway is failing. Open a P1 ticket in Thena on the Engineering Support team and add a comment with her initial diagnostic details."

Update a Thena Ticket (update_a_thena_ticket_by_id)

Once an agent takes action to resolve a problem - or determines an escalation is needed - it uses this tool to change the ticket's state. It handles updating priority, status, and reassignment.

"I have verified the database migration is complete for ticket #TKT-8492. Change the ticket status to 'Resolved', drop the priority to low, and leave an internal note that the migration was successful."

This is arguably the most critical tool for an autonomous agent. It allows the model to run a single query across multiple Thena collections (tickets, users, accounts, help center) simultaneously. The agent uses this to gather context before taking action.

"Before I reply to this new bug report about 'login timeouts', run a federated search across all tickets and comments to see if any other users reported a login timeout in the last 48 hours."

Create an Account Task (create_a_thena_account_task)

Agents aren't just for answering questions - they orchestrate human work. This tool allows the AI to assign operational tasks to specific human assignees within a given account context.

"The annual renewal for Stark Industries is coming up in 30 days. Create an account task in Thena for the assigned Account Manager to schedule a QBR, and set the priority to High."

Create an Account Note (create_a_thena_account_note)

When an agent performs analysis on unstructured data (like summarizing a 40-message email chain), it needs a place to store that analysis. This tool logs intelligence directly onto the Thena account record.

"I just reviewed the transcription of the Q3 check-in call with Wayne Enterprises. Summarize the three major feature requests they mentioned and log it as a new account note on their Thena profile."

Create CSAT Rule (thena_csat_create_rule)

For agents managing customer satisfaction operations, this tool allows for the dynamic configuration of feedback triggers based on account health, ticket resolution states, and custom filters.

"We just launched a new beta feature. Create a new CSAT rule in Thena for the Beta Support team that triggers a feedback form immediately when a ticket tagged 'beta' is moved to Closed status."

To view the complete list of available operations, schemas, and required parameters, visit the Thena integration page.

Workflows in Action

Exposing tools to an LLM is only half the battle. The real value lies in the autonomous workflows the agent executes. Here is exactly how an agent leverages the Truto tool layer to execute complex support operations.

Use Case 1: Automated Ticket Triage and Task Generation

When a vague customer request comes in, a human support rep usually has to dig through history to figure out what the customer is talking about. An AI agent can perform this triage instantly.

"A user named John Doe (john@example.com) submitted a ticket saying 'The integration is broken again just like last month.' Figure out what integration he means, assign a task to engineering, and reply to him."

  1. Context Retrieval: The agent calls thena_search_federated_search querying term: "john@example.com" across the tickets and comments collections to find historical context.
  2. Analysis: The agent reads the JSON response and identifies that "last month", John had an issue with the Salesforce integration.
  3. Ticket Creation: The agent calls create_a_thena_ticket with the title "Salesforce Integration Failure (Recurring)".
  4. Task Assignment: The agent calls create_a_thena_account_task assigning a high-priority task to the on-call engineer to review the specific Salesforce sync logs.

The Result: The human engineering team receives a fully contextualized, prioritized task without a Level 1 support rep having to spend 20 minutes digging through historical tickets.

Use Case 2: Proactive Account Intelligence Logging

Agents can monitor external data sources (like product usage telemetry) and proactively inject intelligence into Thena.

"Acme Corp's product usage just dropped by 40% this week. Log a warning note on their account and alert the account owner."

  1. Account Lookup: The agent calls thena_search_federated_search to find the account ID for "Acme Corp".
  2. Record Retrieval: The agent calls get_single_thena_account_by_id to retrieve the accountOwnerId.
  3. Note Creation: The agent calls create_a_thena_account_note attaching a detailed markdown summary of the usage drop to the account record.
  4. Task Creation: The agent calls create_a_thena_account_task assigned to the Account Owner, titled "Urgent: Investigate 40% usage drop at Acme Corp".

The Result: The account manager is proactively alerted to churn risk with all the context attached directly to the CRM record in Thena.

Building Multi-Step Workflows

To make this work in a production environment, you need an orchestration loop. While you could build this entirely from scratch, utilizing an existing framework like LangChain makes binding the tools simple.

Here is how you initialize the Truto toolset, bind it to a model, and execute a multi-step workflow.

A factual note on rate limits: Truto handles the heavy lifting of normalization and pagination, but it does not absorb rate limits. If you slam the Thena API and they return an HTTP 429, Truto passes that 429 directly back to your caller, normalizing the upstream headers into standard IETF formats (ratelimit-limit, ratelimit-remaining, ratelimit-reset). Your agent's orchestration loop is responsible for checking these headers and implementing backoff logic.

import { ChatOpenAI } from "@langchain/openai";
import { AgentExecutor, createToolCallingAgent } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";
import { TrutoToolManager } from "truto-langchainjs-toolset";
 
async function runThenaAgent() {
  // 1. Initialize the Truto tool manager with your specific Integrated Account ID
  const toolManager = new TrutoToolManager({
    integratedAccountId: "your_thena_account_id_here",
    trutoApiKey: process.env.TRUTO_API_KEY,
  });
 
  // 2. Fetch the Thena proxy tools (this calls the /tools endpoint under the hood)
  console.log("Fetching Thena tool schemas...");
  const tools = await toolManager.getTools();
  
  // 3. Initialize your LLM and bind the tools natively
  const llm = new ChatOpenAI({
    modelName: "gpt-4o",
    temperature: 0,
  });
 
  // 4. Construct the agent prompt
  const prompt = ChatPromptTemplate.fromMessages([
    ["system", "You are a senior technical support engineer. You manage Thena accounts autonomously. You have access to tools that can search records, create tickets, and assign tasks."],
    ["human", "{input}"],
    ["placeholder", "{agent_scratchpad}"],
  ]);
 
  // 5. Create the executor loop
  const agent = createToolCallingAgent({
    llm,
    tools,
    prompt,
  });
 
  const agentExecutor = new AgentExecutor({
    agent,
    tools,
    // In production, implement custom error handling here to catch HTTP 429s
    // and pause execution based on the 'ratelimit-reset' header.
    handleParsingErrors: true,
  });
 
  // 6. Execute a complex instruction
  const result = await agentExecutor.invoke({
    input: "Search for any recent tickets from 'finance@globex.com'. If you find an open one, create an account task for the billing team to investigate their invoice discrepancy, then add a note to the ticket saying the billing team is looking into it."
  });
 
  console.log("Agent Execution Result:", result.output);
}
 
runThenaAgent().catch(console.error);

In a robust production environment, you will wrap your tool invocation layer with an interceptor that listens for HTTP 429 Too Many Requests. When Truto passes this through, you read the ratelimit-reset header, pause the agent's execution thread (or put the job back into a delayed queue if using a framework like Inngest), and resume once the window clears. This prevents your agent from entering a failed hallucination loop where it endlessly retries a rejected tool call.

The Path Forward

Connecting AI agents to enterprise tools like Thena requires moving past the "demo phase" of brittle, hand-coded fetch wrappers. By adopting a unified tool layer, you restrict the LLM to deterministic JSON schemas, drastically reducing hallucination and enforcing clean data validation.

Whether you are building autonomous support triage, proactive account health monitoring, or intelligent routing, standardizing your tool layer is the only reliable way to scale agent capabilities.

FAQ

How do I connect an AI agent to Thena?
You can connect an AI agent to Thena by fetching standardized JSON schemas for Thena's endpoints using Truto's /tools API, then binding those schemas to your LLM using a framework like LangChain or the Vercel AI SDK.
Does Truto automatically handle API rate limits for Thena?
No, Truto does not retry, throttle, or apply backoff on rate limit errors. When Thena returns an HTTP 429, Truto passes that error to your caller with standardized headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset), leaving the retry logic to your agent application.
Can I use these Thena tools with any LLM framework?
Yes. The Truto /tools endpoint returns standard JSON Schema definitions, which are completely framework-agnostic. They work natively with LangChain, LangGraph, CrewAI, Vercel AI SDK, and custom agent loops.

More from our Blog