---
title: "Connect BQE CORE to AI Agents: Sync Sales Leads and Workforce Ops"
slug: connect-bqe-core-to-ai-agents-sync-sales-leads-and-workforce-ops
date: 2026-10-31
author: Nidhi KN
categories: ["AI & Agents"]
excerpt: "Learn how to connect BQE CORE to AI agents using Truto's /tools endpoint. Discover how to sync leads, manage resource schedules, and build agentic workflows."
tldr: "Connect BQE CORE to AI agents using Truto's SDK to automate workforce ops and sales leads. We cover API quirks, rate limit handling, and code for multi-step agent workflows."
canonical: https://truto.one/blog/connect-bqe-core-to-ai-agents-sync-sales-leads-and-workforce-ops/
---

# Connect BQE CORE to AI Agents: Sync Sales Leads and Workforce Ops


You want to connect BQE CORE to an AI agent so your system can autonomously sync sales leads, manage resource schedules, generate time entries, and process invoices. Here is exactly how to do it using Truto's `/tools` endpoint and SDK, bypassing the need to build and maintain a custom BQE CORE API integration from scratch.

Giving a Large Language Model (LLM) read and write access to your professional services automation (PSA) instance is an engineering challenge. You either spend sprints dealing with OAuth tokens, optimistic concurrency, and complex pagination, or you use an infrastructure layer that handles the boilerplate for you. If your team uses ChatGPT, check out our guide on [connecting BQE CORE to ChatGPT](https://truto.one/connect-bqe-core-to-chatgpt-manage-projects-time-and-expenses/), or if you are building on Anthropic's models, read our guide on [connecting BQE CORE to Claude](https://truto.one/connect-bqe-core-to-claude-automate-billing-and-resource-schedules/). For developers building custom autonomous workflows, you need a [programmatic way to fetch these tools](https://truto.one/best-unified-api-for-llm-function-calling-ai-agent-tools-2026/) and bind them to your agent framework.

This guide breaks down exactly how to fetch AI-ready tools for BQE CORE, bind them natively to an LLM using frameworks like [LangChain, LangGraph, CrewAI](https://truto.one/architecting-ai-agents-langgraph-langchain-and-the-saas-integration-bottleneck/), or the Vercel AI SDK, and execute complex workforce operations. We will look at the specific API quirks of BQE CORE, the recommended tools to expose, and the code required to build a resilient, multi-step agent loop. For a broader look at this design pattern, read our research on [Architecting AI Agents: LangGraph, LangChain, and the SaaS Integration Bottleneck](https://truto.one/architecting-ai-agents-langgraph-langchain-and-the-saas-integration-bottleneck/).

## The Engineering Reality of the BQE CORE API

Giving an AI agent access to external PSA data sounds simple in a Jupyter notebook prototype. You write a fetch request, wrap it in a `@tool` decorator, and move on. In production against complex financial and operational systems like BQE CORE, this approach rapidly deteriorates. 

BQE CORE's API introduces several specific integration challenges that break standard REST assumptions. If you hardcode these interactions directly into your agent, you will spend your time writing defensive integration code instead of improving your model's reasoning capabilities.

### Optimistic Concurrency and JSON Patch

Unlike simpler APIs that accept standard `PUT` requests with flat JSON payloads, BQE CORE enforces optimistic concurrency control for updates. When an agent wants to modify a project or an invoice, it cannot simply push the changed fields. 

To perform a partial update, the API requires the current record's `version` string and a strict JSON Patch document array. 

```json
{
  "version": "12345abcde",
  "Document": [
    {"op": "replace", "path": "/name", "value": "Updated Project Name"}
  ]
}
```

Standard LLMs are notoriously bad at generating compliant JSON Patch arrays. They will frequently invent invalid operations or misunderstand the JSON pointer syntax for the `path` attribute. By putting a unified tool layer between the LLM and the API, the agent interacts with a standard, flat JSON schema (`bqe_core_projects_partial_update`), and the proxy layer handles the structural translation. The model never has to write a literal `"op": "replace"`.

### Complex Query Filtering and Expansion Constraints

BQE CORE exposes a powerful but highly specific query language via the `where` and `orderBy` parameters. Furthermore, pagination operates on a strict `page=<number>,<size>` string format. 

Crucially, BQE CORE caps standard list results at 1,000 records per page. However, if your agent requests nested entity expansions (using the `expand` query parameter to fetch related objects), that limit drops to 100 records per page. If your agent is allowed to construct raw HTTP URLs, it will inevitably mix an `expand` query with a `size=500` pagination request, triggering an immediate HTTP 400 Bad Request. Abstracting the list methods behind strict tool definitions prevents the agent from violating these undocumented matrix constraints.

### The Reality of API Rate Limits

Many integration platforms obscure rate limits with unpredictable, opaque queues. Truto takes a deterministic approach: Truto does not retry, throttle, or apply arbitrary backoff on rate limit errors. 

When the BQE CORE upstream API returns an HTTP 429 Too Many Requests, Truto passes that error directly to the caller. However, Truto normalizes the upstream rate limit information into standardized IETF headers: `ratelimit-limit`, `ratelimit-remaining`, and `ratelimit-reset`. This means the caller (your agent framework) is fully responsible for retry logic and backoff, but it has the exact, standardized telemetry needed to do so accurately across any SaaS provider.

## Available BQE CORE AI Agent Tools

Rather than exposing raw endpoints, Truto provides proxy tools with strictly typed schemas. These tools handle the pagination, authentication, and query parameter processing automatically. 

Here are the highest-leverage BQE CORE tools for automating sales leads and workforce operations.

### list_all_bqe_core_projects

Use this tool to allow the agent to query active projects, fetch project IDs, and read contract types. The agent can filter the list using specific `where` parameters to find projects belonging to a certain client or manager.

> "Find all active BQE CORE projects managed by user ID 405 where the contract type is hourly, and return their project codes."

### create_a_bqe_core_time_entry

Time entry automation is the lifeblood of PSA systems. This tool allows the agent to log time against specific projects and activities. It strictly requires the `activityId`, `date`, `description`, `projectId`, and `resourceId`.

> "Log 4 hours of time for resource ID 88 on project ID 102 for yesterday. Use activity ID 15 and add the description 'Database schema design and normalization'."

### bqe_core_invoices_attach

This is a highly specific operational tool. In BQE CORE, you do not simply update an invoice to add line items. You use this dedicated attach method to link existing unbilled time and expense entries to a specific invoice ID.

> "Take the unbilled time entries from last week for the 'Acme Corp Redesign' project and attach them to invoice ID 9942."

### list_all_bqe_core_leads

Sales operations agents need to query the CRM pipeline. This tool retrieves a list of leads, which can be filtered by status or creation date. It provides the foundational data for syncing BQE CORE leads into external marketing automation systems.

> "Retrieve the list of all new leads added to BQE CORE in the last 7 days so we can score them and push them to our marketing sequence."

### bqe_core_projects_partial_update

This tool handles the complex optimistic concurrency logic mentioned earlier. It allows the agent to safely update specific fields on a project (like the status or the assigned manager) without risking data loss from concurrent edits.

> "Update the project name for project ID 334 to 'Phase 2 - Enterprise Rollout' and change the status to Active."

### list_all_bqe_core_resource_schedules

Workforce optimization requires knowing who is doing what and when. This tool fetches the resource schedules, allowing an AI agent to determine employee availability before assigning new tasks or creating allocations.

> "Check the resource schedules for next week and find me an engineer who has less than 20 hours allocated."

To view the complete inventory of available BQE CORE methods, supported query parameters, and detailed JSON schemas, refer to the [BQE CORE integration page](https://truto.one/integrations/detail/bqecore).

## Workflows in Action

Providing an LLM with a list of tools is only the first step. The true power of an AI agent emerges when it chains these tools together to execute multi-step workflows. Here is how specific personas use these BQE CORE tools in production.

### Scenario 1: The Autonomous Project Manager

Project managers spend hours reconciling unbilled time and generating draft invoices. An AI agent can run this workflow autonomously at the end of every week.

> "Find all unbilled time entries for the 'Titan Migration' project from this week, generate a new invoice draft, and attach those time entries to the invoice."

**Tool execution sequence:**
1.  **`list_all_bqe_core_projects`**: The agent queries the project list using a `where` filter to resolve the text string "Titan Migration" to its internal BQE CORE project ID (e.g., ID 402).
2.  **`list_all_bqe_core_time_entries`**: The agent queries the time entries table, filtering for `projectId=402` and the current date range, retrieving a list of unbilled time entry IDs.
3.  **`create_a_bqe_core_invoice`**: The agent creates a new draft invoice shell for the client associated with the project, returning a new `invoice_id`.
4.  **`bqe_core_invoices_attach`**: The agent passes the `invoice_id` and the array of time entry IDs to safely bind the labor records to the new invoice.

*Result:* The human project manager opens BQE CORE on Friday afternoon to find a fully populated draft invoice waiting for final review, saving them an hour of manual data entry.

### Scenario 2: The Sales Operations Sync Agent

When new leads land in BQE CORE, sales operations teams need to ensure they are assigned to the right resources and tracked. An AI agent can monitor this pipeline and orchestrate the workforce assignment.

> "Check for any new BQE CORE leads added today. If you find any, check our resource schedules to find an available sales engineer, and log a To-Do for them to contact the lead."

**Tool execution sequence:**
1.  **`list_all_bqe_core_leads`**: The agent fetches leads created within the last 24 hours.
2.  **`list_all_bqe_core_resource_schedules`**: The agent reads the schedules of users tagged as 'sales engineers' to calculate who has the most availability this week.
3.  **`create_a_bqe_core_todo`**: The agent creates a To-Do record, assigning it to the `assignedToId` of the chosen sales engineer, linking the lead's entity ID in the `linkedEntityId` field.

*Result:* Lead routing becomes instantaneous and perfectly load-balanced based on actual PSA capacity data, entirely eliminating manual triage.

## Building Multi-Step Workflows

To build these workflows, you need an agent loop that fetches tools, parses schemas, executes API calls, and handles state. 

Because Truto normalizes the BQE CORE API into standard OpenAI-compatible tool schemas via the `/tools` endpoint, this works with any modern framework (LangChain, Vercel AI SDK, CrewAI). You are not restricted to Model Context Protocol (MCP) servers.

Below is a conceptual architecture using TypeScript and LangChain to bind Truto tools to an LLM. It highlights the critical step of catching rate limit errors and reading Truto's normalized `ratelimit-reset` headers.

```mermaid
sequenceDiagram
    participant Agent as AI Agent (LangChain)
    participant SDK as TrutoToolManager
    participant Proxy as Truto Unified Proxy
    participant BQE as Upstream API (BQE CORE)

    Agent->>SDK: Initialize with Integrated Account ID
    SDK->>Proxy: GET /integrated-account/{id}/tools
    Proxy-->>SDK: Return JSON schemas for BQE CORE tools
    SDK-->>Agent: bindTools(llm)
    
    Note over Agent: Agent reasoning loop begins
    Agent->>SDK: Call create_a_bqe_core_time_entry
    SDK->>Proxy: POST /proxy/bqe_core/time_entries
    Proxy->>BQE: POST /bqe/api/timeentries
    BQE-->>Proxy: HTTP 429 Too Many Requests
    
    Note over Proxy: Truto passes 429 directly<br>and normalizes limit headers
    Proxy-->>SDK: HTTP 429 (ratelimit-reset: 171500000)
    
    Note over SDK: Agent catches error,<br>reads header, waits,<br>and retries.
    SDK-->>Agent: Throw RateLimitError with reset timestamp
```

### Example Implementation

Here is how you initialize the agent and safely handle execution loops using the Truto Langchain.js SDK.

```typescript
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 runBQECoreAgent() {
  // 1. Initialize the LLM
  const llm = new ChatOpenAI({
    modelName: "gpt-4o",
    temperature: 0,
  });

  // 2. Fetch BQE CORE tools for a specific integrated account.
  // We can filter to only fetch read and write tools, ignoring unneeded scopes.
  const trutoManager = new TrutoToolManager({
    trutoApiKey: process.env.TRUTO_API_KEY,
    integratedAccountId: "bqe-core-account-id-123",
  });

  const tools = await trutoManager.getTools({ 
    methods: ["read", "write", "custom"] 
  });

  // 3. Set up the agent prompt
  const prompt = ChatPromptTemplate.fromMessages([
    ["system", "You are a BQE CORE PSA administrator. Use the provided tools to manage projects, time entries, and resources."],
    ["human", "{input}"],
    ["placeholder", "{agent_scratchpad}"],
  ]);

  // 4. Bind tools and create the executor
  const agent = createToolCallingAgent({ llm, tools, prompt });
  const agentExecutor = new AgentExecutor({ 
      agent, 
      tools, 
      maxIterations: 10 
  });

  try {
    // 5. Execute a multi-step workforce op
    const result = await agentExecutor.invoke({
      input: "Find project ID 102. Update its status to Active, then check resource schedules to find an available engineer, and log a To-Do for them to review the project brief."
    });
    console.log("Workflow complete:", result.output);

  } catch (error: any) {
    // 6. Deterministic Rate Limit Handling
    // Truto does NOT absorb 429s. You must read the normalized IETF headers.
    if (error.status === 429) {
      const resetTime = error.headers['ratelimit-reset'];
      console.error(`BQE CORE rate limit hit. Agent must backoff until UNIX timestamp: ${resetTime}`);
      // Implement your custom sleep/retry logic here
    } else {
      console.error("Agent execution failed:", error.message);
    }
  }
}

runBQECoreAgent();
```

Notice how the error block explicitly checks for a 429 status and parses the `ratelimit-reset` header. Because Truto standardizes these headers across every upstream provider, your agent's retry logic remains identical whether it is talking to BQE CORE, Salesforce, or Zendesk.

By routing your agent's API calls through a unified tool layer, you drastically reduce the attack surface for LLM hallucinations. The model never has to invent optimistic concurrency tokens, OData query structures, or complex pagination limits. It simply reads the schema, provides the logical arguments, and drives the workflow forward.

> Ready to connect your AI agents to BQE CORE and 100+ other enterprise APIs? Truto provides auto-generated, strictly typed tools for any SaaS platform without the integration boilerplate. Book a demo today.
>
> [Talk to us](https://truto.one/book-a-demo/)
