Skip to content

Connect Intercom to AI Agents: Sync Contacts and Track Events

Learn how to connect Intercom to AI Agents using Truto's /tools endpoint. Fetch dynamic schemas, handle API rate limits natively, and automate support.

Uday Gajavalli Uday Gajavalli · · 9 min read
Connect Intercom to AI Agents: Sync Contacts and Track Events

Customer support is transitioning from static decision trees to autonomous resolution. You want to connect Intercom to an AI agent so your system can read conversation threads, execute complex searches, track behavioral events, and reply to customers autonomously. Here is exactly how to do it using Truto's /tools endpoint and SDK, bypassing the need to maintain a custom integration from scratch.

If your team uses ChatGPT, check out our guide on connecting Intercom to ChatGPT, or if you are building on Anthropic's models, read our guide on connecting Intercom to Claude. For developers building custom autonomous workflows, you need a programmatic way to fetch these tools and bind them to your agent framework. Similar workflows can be applied to other platforms; for instance, see our guides on connecting Zendesk to AI agents or streamlining Pylon operations.

Giving a Large Language Model (LLM) read and write access to your Intercom instance is a complex engineering challenge. You either spend sprints building, hosting, and maintaining a custom connector, or you use an infrastructure layer that handles the boilerplate. As we covered in our guide on architecting AI agents and the SaaS integration bottleneck, the integration layer is where agentic prototypes typically fail in production.

This guide breaks down exactly how to fetch AI-ready tools for Intercom, bind them natively to an LLM using LangChain (or any framework like LangGraph, CrewAI, or Vercel AI SDK), and execute complex support workflows autonomously.

The Engineering Reality of the Intercom API

Building AI agents is easy. Connecting them to external SaaS APIs is hard. Giving an LLM access to external data sounds simple in a notebook prototype: you write a Python or Node.js function that makes a network request and wrap it in a tool decorator. In a production environment, this approach collapses entirely. If you decide to build a custom integration for Intercom, you own the entire API lifecycle.

Intercom's API introduces several specific integration quirks that break standard CRUD assumptions for LLM tool calling.

The Conversation Parts Abstraction

Unlike flat ticketing systems where a ticket has a single body of text, Intercom treats support threads as a timeline of conversation_parts. When you query a conversation, Intercom does not return a simple string of text that an LLM can easily summarize. It returns an array of conversation parts - consisting of notes, replies, state changes, and assignment events.

If you blindly pass an Intercom conversation object to an LLM, the context window fills with raw HTML strings, system event metadata, and deeply nested author objects. You must carefully map and truncate this nested data model before presenting it to an agent to avoid blowing up the context window with paginated results, or your LLM will hallucinate who said what, confusing internal admin notes with customer-facing replies.

Intercom relies heavily on nested query objects for its search endpoints. Searching for a specific contact or conversation requires an exact JSON structure utilizing logical operators (AND, OR) and specific field criteria. LLMs notoriously struggle to construct vendor-specific, deeply nested query DSLs (Domain Specific Languages) from scratch. Without strict schema enforcement and description definitions injected into the tool binding, the LLM will hallucinate search parameters and trigger HTTP 400 Bad Request errors.

Rate Limits and 429 Error Ownership

Intercom enforces strict rate limits depending on the workspace plan, typically capping at 1000 requests per minute, but dropping drastically for bulk or search endpoints.

A critical factual note on architecture: Truto does not retry, throttle, or apply exponential backoff on rate limit errors for you. When the Intercom upstream API returns an HTTP 429 Too Many Requests, Truto passes that exact error directly back to the caller. What Truto does is normalize the fragmented upstream rate limit information into standardized IETF HTTP headers: ratelimit-limit, ratelimit-remaining, and ratelimit-reset.

Because Truto acts as a transparent proxy for these limits, the caller - meaning your agent's execution loop - is responsible for handling the retry and backoff logic. If you do not explicitly write logic into your LangGraph or AgentExecutor loop to catch 429s, read the ratelimit-reset header, and pause execution, your agent will spiral into a failure loop.

Auto-Generating Intercom Tools for AI Agents

Every integration on Truto operates as a comprehensive JSON object mapping the underlying product's API behavior. Truto abstracts endpoints into Resources (like contacts or conversations) and Methods (like List, Get, Create, Update, Delete, and custom methods like Reply).

Truto provides all these mapped methods as Proxy APIs. These Proxy APIs handle authentication, standard pagination, and query parameter processing.

To make this agent-ready, Truto provides a /tools endpoint. When you call the /integrated-account/<id>/tools endpoint, Truto dynamically returns all available Proxy APIs for that connected Intercom account, formatted complete with descriptions and JSON schemas optimized for LLM consumption.

These schemas act as strict guardrails. When your LLM framework reads the tool schema for searching Intercom conversations, it understands exactly what query operators are permitted, eliminating the syntax hallucinations common to Intercom's complex search DSL.

Hero Tools for Intercom Agent Workflows

Below are six high-leverage tools available via the Truto API for Intercom. We have designed the schemas for these tools specifically to handle Intercom's nested abstractions, allowing the LLM to focus on logic rather than parsing.

list_all_intercom_search_conversations

Search conversations in Intercom using a query object with filters. Returns conversations matching the filters with fields like ID, creation timestamps, state, priority, and conversation rating.

Usage Note: Crucial for triaging. You can instruct the agent to poll for conversations where state is open and no reply has been sent in the last 2 hours.

"Find all open conversations in Intercom that have a priority of 'high' and have not been updated since yesterday."

get_single_intercom_conversation_by_id

Get details of a single conversation in Intercom by ID. Returns fields including type, state, tags, priority, and importantly, conversation_parts with the total count.

Usage Note: After finding a conversation ID via the search tool, the agent must call this tool to read the actual thread history and internal notes before formulating a reply.

"Fetch the full conversation history and internal notes for conversation ID 10934812."

intercom_conversations_reply

Reply to a conversation in Intercom using ID. Returns the updated conversation object. This tool handles the specific payload required to append a new conversation part of type comment.

Usage Note: The LLM uses this tool to actually send the message to the end-user. It can also be configured to add internal notes without alerting the customer.

"Reply to conversation ID 10934812 with the following message: 'We have identified the bug and deployed a fix. Please refresh your browser.'"

list_all_intercom_search_contacts

Search contacts in Intercom using a query object with filters. Returns contacts matching the filters with fields such as ID, name, email, and custom attributes.

Usage Note: Before replying, an agent should verify the identity of the user. This tool allows the LLM to pull up the contact's custom attributes - such as their pricing tier or active feature flags - to provide context-aware support.

"Search for the Intercom contact associated with the email 'admin@acme.corp' and return their subscription tier."

create_a_intercom_data_event

Submit a data event with event_name and created_at timestamp for a user identified by ID or email in Intercom.

Usage Note: Agents aren't just for chatting. You can use an agent to monitor server logs, and if it detects a specific user experiencing an error rate, it can trigger an Intercom event. That event can then kick off an automated Intercom Series or marketing campaign.

"Log a data event called 'encountered_api_error' for the user admin@acme.corp."

Search articles in Intercom by phrase, state, and help center ID. Returns articles with fields including ID, title, and body text.

Usage Note: This provides native Retrieval-Augmented Generation (RAG). Before an agent asks a human for help, it can query the Intercom Help Center to see if an article already exists for the customer's problem.

"Search the Intercom Help Center for articles related to 'SAML SSO configuration' and summarize the steps."

To view the complete inventory of Intercom tools and their exact JSON schemas, visit the Intercom integration page.

Workflows in Action

Exposing these tools to an LLM unlocks complex, multi-step autonomous behaviors. Instead of writing rigid if/else scripts to manage Intercom routing, you define an agentic loop. Here are two real-world workflows demonstrating how an LLM utilizes these tools.

Scenario 1: Autonomous Tier 1 Support and KB Deflection

Support teams waste thousands of hours copy-pasting links to Help Center articles. An AI agent can intercept incoming inquiries, search the knowledge base, and resolve the issue without human intervention.

"Read the latest unassigned conversation. If they are asking how to reset their password, find the relevant help article and reply to them with the instructions. If they are asking about something else, leave it unassigned."

  1. The agent calls list_all_intercom_search_conversations with a filter for state: open and assigned_to: null.
  2. The agent identifies a conversation and extracts the ID.
  3. The agent calls get_single_intercom_conversation_by_id to read the conversation_parts and understands the user is locked out.
  4. The agent calls list_all_intercom_articles_search with the phrase "password reset".
  5. The agent parses the returned article body, formats a polite summary, and calls intercom_conversations_reply to send the message to the customer.

The customer receives an immediate, accurate response natively inside the Intercom messenger window, and the support queue remains clear.

Scenario 2: Identity Sync and VIP Escalation

Context is everything in B2B support. When a high-value customer encounters an issue, they should bypass the standard queue. An agent can enrich the conversation context and escalate automatically.

"Check the newest open conversation. Look up the user's email to see if they belong to an Enterprise tier company. If they are Enterprise, add an internal note tagging the on-call engineer and assign the conversation to the VIP team."

  1. The agent calls list_all_intercom_search_conversations to pull the latest open ticket.
  2. The agent extracts the user's email address from the conversation metadata.
  3. The agent calls list_all_intercom_search_contacts filtering by that email to inspect their custom attributes.
  4. Discovering the plan_tier attribute equals Enterprise, the agent calls intercom_conversations_reply formatting the payload as an internal note (invisible to the customer) to alert the engineer.
  5. The agent calls intercom_conversations_manage to change the assignee ID to the VIP team's inbox.

The human support team opens Intercom to find the ticket already categorized, enriched with customer context, and correctly assigned.

Building Multi-Step Workflows

To execute these workflows, you need an orchestration framework. Because Truto's /tools endpoint returns standard OpenAI-compatible tool schemas, it is entirely framework-agnostic. You can bind these tools to LangChain, Vercel AI SDK, or CrewAI.

The following code demonstrates how to implement a reliable agent loop in TypeScript using LangChain. Crucially, this example illustrates how to handle Intercom's rate limits. Because Truto passes the HTTP 429 error and normalizes the headers, your agent code must catch the error, extract the ratelimit-reset timestamp, and pause execution.

import { ChatOpenAI } from "@langchain/openai";
import { AgentExecutor, createOpenAIToolsAgent } from "langchain/agents";
import { TrutoToolManager } from "truto-langchainjs-toolset";
import { ChatPromptTemplate } from "@langchain/core/prompts";
 
async function runIntercomAgent() {
  // 1. Initialize the LLM
  const model = new ChatOpenAI({ 
    modelName: "gpt-4o",
    temperature: 0.2, 
  });
 
  // 2. Fetch Intercom Tools from Truto
  // This requires a valid Truto API key and the specific Integrated Account ID for Intercom
  const toolManager = new TrutoToolManager({
    apiKey: process.env.TRUTO_API_KEY,
  });
 
  const tools = await toolManager.getTools(process.env.INTERCOM_ACCOUNT_ID);
 
  // 3. Define the Agent Prompt
  const prompt = ChatPromptTemplate.fromMessages([
    ["system", "You are an elite customer support engineer. You manage Intercom conversations autonomously. You must always read a conversation history before replying. If you hit a rate limit, you must wait and try again."],
    ["placeholder", "{chat_history}"],
    ["human", "{input}"],
    ["placeholder", "{agent_scratchpad}"],
  ]);
 
  // 4. Bind Tools and Create the Executor
  const agent = await createOpenAIToolsAgent({
    llm: model,
    tools,
    prompt,
  });
 
  const executor = new AgentExecutor({
    agent,
    tools,
    maxIterations: 10,
    tools,
    // Custom error handler to respect Truto's normalized rate limit headers
    handleParsingErrors: true,
  });
 
  console.log("Executing workflow...");
 
  try {
    // 5. Invoke the Agent
    const result = await executor.invoke({
      input: "Find the most recent open conversation. Read the history. If they are asking about pricing, reply with a link to our pricing page and close the ticket."
    });
    console.log("Agent finished:", result.output);
 
  } catch (error: any) {
    // 6. Handle HTTP 429 passed through Truto
    if (error.response && error.response.status === 429) {
      const resetTime = error.response.headers.get('ratelimit-reset');
      console.log(`Rate limit hit. Agent execution halted. Reset at ${resetTime}.`);
      // In a production system, you would enqueue this task to retry after resetTime
    } else {
      console.error("Agent execution failed:", error);
    }
  }
}
 
runIntercomAgent();

This architecture fundamentally changes how you build SaaS workflows. Instead of maintaining polling workers, parsing nested conversation_parts manually, and writing fragile API mapping code, you define the objective. The LLM handles the logic, and Truto handles the schema translation, pagination, and unified header normalization.

If you want your AI agents to solve customer problems rather than just summarize text, they need read and write access to the systems where your business operates. Building those connections natively drains engineering bandwidth. By leveraging auto-generated tools from a standardized layer, you isolate your agent's core logic from the chaos of third-party API deprecations, pagination quirks, and schema drift, ensuring your autonomous workflows remain reliable at scale.

FAQ

How do I handle Intercom API rate limits with AI agents?
Truto passes upstream 429 Too Many Requests errors directly to the caller, normalizing the details into standard headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset). Your agent orchestration framework (like LangGraph) must catch these errors and implement retry and exponential backoff logic based on the reset header.
Can an AI agent read an entire Intercom conversation thread?
Yes. Agents use the get_single_intercom_conversation_by_id tool to fetch the conversation object, which includes an array of conversation_parts. This provides the LLM with the full timeline of user replies, admin messages, and internal notes.
Does Truto support custom data attributes in Intercom?
Yes. Truto's dynamic schemas support custom attributes. Tools like list_all_intercom_search_contacts allow the AI agent to search and retrieve a user's custom attributes to provide highly contextual, personalized support.
Can I use frameworks other than LangChain to connect to Intercom?
Absolutely. Truto's /tools endpoint returns standard OpenAI-compatible JSON schemas. These tools can be bound to any framework that supports tool calling, including LangGraph, CrewAI, AutoGen, and the Vercel AI SDK.

More from our Blog