How to integrate Intercom MCP with LangChain

This guide walks you through connecting Intercom to LangChain using the Composio tool router. By the end, you'll have a working Intercom agent that can add tag 'vip' to contact john doe, assign open conversation #123 to support team, create note for contact emily about refund through natural language commands. This guide will help you understand how to give your LangChain agent real control over a Intercom account through Composio's Intercom MCP server. Before we dive in, let's take a quick look at the key ideas and tools involved.

Intercom logoIntercom
Oauth2

Intercom is a customer messaging platform for live chat and support automation. It helps businesses engage, convert, and support customers at scale.

133 Tools

Introduction

This guide walks you through connecting Intercom to LangChain using the Composio tool router. By the end, you'll have a working Intercom agent that can add tag 'vip' to contact john doe, assign open conversation #123 to support team, create note for contact emily about refund through natural language commands.

This guide will help you understand how to give your LangChain agent real control over a Intercom account through Composio's Intercom MCP server.

Before we dive in, let's take a quick look at the key ideas and tools involved.

Also integrate Intercom with

TL;DR

Here's what you'll learn:
  • Get and set up your OpenAI and Composio API keys
  • Connect your Intercom project to Composio
  • Create a Tool Router MCP session for Intercom
  • Initialize an MCP client and retrieve Intercom tools
  • Build a LangChain agent that can interact with Intercom
  • Set up an interactive chat interface for testing

What is LangChain?

LangChain is a framework for developing applications powered by language models. It provides tools and abstractions for building agents that can reason, use tools, and maintain conversation context.

Key features include:

  • Agent Framework: Build agents that can use tools and make decisions
  • MCP Integration: Connect to external services through Model Context Protocol adapters
  • Memory Management: Maintain conversation history across interactions
  • Multi-Provider Support: Works with OpenAI, Anthropic, and other LLM providers

What is the Intercom MCP server, and what's possible with it?

The Intercom MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Intercom account. It provides structured and secure access to your customer engagement platform, so your agent can perform actions like managing conversations, tagging contacts, creating articles, and updating company records on your behalf.

  • Conversation management and assignment: Let your agent assign conversations to teams or admins, create new conversations, and close them when resolved, streamlining your support workflow.
  • Contact tagging and note creation: Effortlessly tag contacts with relevant labels or add detailed notes for context, making customer follow-ups more organized and actionable.
  • Automated company and contact updates: Enable your agent to attach contacts to companies, create or update company records, and keep your Intercom data clean and up to date.
  • Article and collection creation: Let your agent publish new articles or create help center collections to expand your self-serve support resources without manual effort.
  • Subscription and message preferences management: Allow your agent to add or manage subscriptions for contacts, helping you personalize communication and respect user preferences automatically.

What is the Composio tool router, and how does it fit here?

What is Composio SDK?

Composio's Composio SDK helps agents find the right tools for a task at runtime. You can plug in multiple toolkits (like Gmail, HubSpot, and GitHub), and the agent will identify the relevant app and action to complete multi-step workflows. This can reduce token usage and improve the reliability of tool calls. Read more here: Getting started with Composio SDK

The tool router generates a secure MCP URL that your agents can access to perform actions.

How the Composio SDK works

The Composio SDK follows a three-phase workflow:

  1. Discovery: Searches for tools matching your task and returns relevant toolkits with their details.
  2. Authentication: Checks for active connections. If missing, creates an auth config and returns a connection URL via Auth Link.
  3. Execution: Executes the action using the authenticated connection.

Step-by-step Guide

Step by step10 STEPS
1

Prerequisites

Before starting this tutorial, make sure you have:
  • Python 3.10 or higher installed on your system
  • A Composio account with an API key
  • An OpenAI API key
  • Basic familiarity with Python and async programming
2

Getting API Keys for OpenAI and Composio

OpenAI API Key
  • Go to the OpenAI dashboard and create an API key. You'll need credits to use the models, or you can connect to another model provider.
  • Keep the API key safe.
Composio API Key
  • Log in to the Composio dashboard.
  • Navigate to your API settings and generate a new API key.
  • Store this key securely as you'll need it for authentication.
3

Install dependencies

npm install @composio/langchain @langchain/core @langchain/openai @langchain/mcp-adapters dotenv

Install the required packages for LangChain with MCP support.

What's happening:

  • @composio/langchain provides Composio integration for LangChain
  • @langchain/mcp-adapters enables MCP client connections
  • @langchain/core is the core agent framework
  • dotenv/config loads environment variables
4

Set up environment variables

bash
COMPOSIO_API_KEY=your_composio_api_key_here
COMPOSIO_USER_ID=your_composio_user_id_here
OPENAI_API_KEY=your_openai_api_key_here

Create a .env file in your project root.

What's happening:

  • COMPOSIO_API_KEY authenticates your requests to Composio's API
  • COMPOSIO_USER_ID identifies the user for session management
  • OPENAI_API_KEY enables access to OpenAI's language models
5

Import dependencies

import { Composio } from '@composio/core';
import { LangchainProvider } from '@composio/langchain';
import { MultiServerMCPClient } from "@langchain/mcp-adapters";
import { createAgent } from "langchain";
import * as readline from 'readline';
import 'dotenv/config';

dotenv.config();
What's happening:
  • We're importing LangChain's MCP adapter and Composio SDK
  • The dotenv/config import loads environment variables from your .env file
  • This setup prepares the foundation for connecting LangChain with Intercom functionality through MCP
6

Initialize Composio client

const composioApiKey = process.env.COMPOSIO_API_KEY;
const userId = process.env.COMPOSIO_USER_ID;

if (!composioApiKey) throw new Error('COMPOSIO_API_KEY is not set');
if (!userId) throw new Error('COMPOSIO_USER_ID is not set');

async function main() {
    const composio = new Composio({
        apiKey: composioApiKey as string,
        provider: new LangchainProvider()
    });
What's happening:
  • We're loading the COMPOSIO_API_KEY from environment variables and validating it exists
  • Creating a Composio instance that will manage our connection to Intercom tools
  • Validating that COMPOSIO_USER_ID is also set before proceeding
7

Create a Tool Router session

const session = await composio.create(
    userId as string,
    {
        toolkits: ['intercom']
    }
);

const url = session.mcp.url;
What's happening:
  • We're creating a Tool Router session that gives your agent access to Intercom tools
  • The create method takes the user ID and specifies which toolkits should be available
  • The returned session.mcp.url is the MCP server URL that your agent will use
  • This approach allows the agent to dynamically load and use Intercom tools as needed
8

Configure the agent with the MCP URL

const client = new MultiServerMCPClient({
    "intercom-agent": {
        transport: "http",
        url: url,
        headers: {
            "x-api-key": process.env.COMPOSIO_API_KEY
        }
    }
});

const tools = await client.getTools();

const agent = createAgent({ model: "gpt-5", tools });
What's happening:
  • We're creating a MultiServerMCPClient that connects to our Intercom MCP server via HTTP
  • The client is configured with a name and the URL from our Tool Router session
  • getTools() retrieves all available Intercom tools that the agent can use
  • We're creating a LangChain agent using the GPT-5 model
9

Set up interactive chat interface

let conversationHistory: any[] = [];

console.log("Chat started! Type 'exit' or 'quit' to end the conversation.\n");
console.log("Ask any Intercom related question or task to the agent.\n");

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    prompt: 'You: '
});

rl.prompt();

rl.on('line', async (userInput: string) => {
    const trimmedInput = userInput.trim();

    if (['exit', 'quit', 'bye'].includes(trimmedInput.toLowerCase())) {
        console.log("\nGoodbye!");
        rl.close();
        process.exit(0);
    }

    if (!trimmedInput) {
        rl.prompt();
        return;
    }

    conversationHistory.push({ role: "user", content: trimmedInput });
    console.log("\nAgent is thinking...\n");

    const response = await agent.invoke({ messages: conversationHistory });
    conversationHistory = response.messages;

    const finalResponse = response.messages[response.messages.length - 1]?.content;
    console.log(`Agent: ${finalResponse}\n`);
        
        rl.prompt();
    });

    rl.on('close', () => {
        console.log('\n👋 Session ended.');
        process.exit(0);
    });
What's happening:
  • We initialize an empty conversationHistory list to maintain context across interactions
  • A readline interface is used to continuously accept user input from the command line
  • When a user types a message, it's added to the conversation history and sent to the agent
  • The agent processes the request using the invoke() method with the full conversation history
  • Users can type 'exit', 'quit', or 'bye' to end the chat session gracefully
10

Run the application

main().catch((err) => {
    console.error('Fatal error:', err);
    process.exit(1);
});
What's happening:
  • We call the main() function to start the application

Complete Code

Here's the complete code to get you started with Intercom and LangChain:

import { Composio } from '@composio/core';
import { LangchainProvider } from '@composio/langchain';
import { MultiServerMCPClient } from "@langchain/mcp-adapters";  
import { createAgent } from "langchain";
import * as readline from 'readline';
import 'dotenv/config';

const composioApiKey = process.env.COMPOSIO_API_KEY;
const userId = process.env.COMPOSIO_USER_ID;

if (!composioApiKey) throw new Error('COMPOSIO_API_KEY is not set');
if (!userId) throw new Error('COMPOSIO_USER_ID is not set');

async function main() {
    const composio = new Composio({
        apiKey: composioApiKey as string,
        provider: new LangchainProvider()
    });

    const session = await composio.create(
        userId as string,
        {
            toolkits: ['intercom']
        }
    );

    const url = session.mcp.url;
    
    const client = new MultiServerMCPClient({
        "intercom-agent": {
            transport: "http",
            url: url,
            headers: {
                "x-api-key": process.env.COMPOSIO_API_KEY
            }
        }
    });
    
    const tools = await client.getTools();
  
    const agent = createAgent({ model: "gpt-5", tools });
    
    let conversationHistory: any[] = [];
    
    console.log("Chat started! Type 'exit' or 'quit' to end the conversation.\n");
    console.log("Ask any Intercom related question or task to the agent.\n");
    
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout,
        prompt: 'You: '
    });

    rl.prompt();

    rl.on('line', async (userInput: string) => {
        const trimmedInput = userInput.trim();
        
        if (['exit', 'quit', 'bye'].includes(trimmedInput.toLowerCase())) {
            console.log("\nGoodbye!");
            rl.close();
            process.exit(0);
        }
        
        if (!trimmedInput) {
            rl.prompt();
            return;
        }
        
        conversationHistory.push({ role: "user", content: trimmedInput });
        console.log("\nAgent is thinking...\n");
        
        const response = await agent.invoke({ messages: conversationHistory });
        conversationHistory = response.messages;
        
        const finalResponse = response.messages[response.messages.length - 1]?.content;
        console.log(`Agent: ${finalResponse}\n`);
        
        rl.prompt();
    });

    rl.on('close', () => {
        console.log('\nSession ended.');
        process.exit(0);
    });
}

main().catch((err) => {
    console.error('Fatal error:', err);
    process.exit(1);
});

Conclusion

You've successfully built a LangChain agent that can interact with Intercom through Composio's Tool Router.

Key features of this implementation:

  • Dynamic tool loading through Composio's Tool Router
  • Conversation history maintenance for context-aware responses
  • Async Python provides clean, efficient execution of agent workflows
You can extend this further by adding error handling, implementing specific business logic, or integrating additional Composio toolkits to create multi-app workflows.
TOOLS

Supported Tools

Every Intercom action and event your agent gets out of the box.

Add subscription to a contact

You can add a specific subscription to a contact.

Add tag to contact

Tool to add a tag to a contact in Intercom.

Archive contact

Tool to archive a single contact in Intercom.

Assign conversation

Assigns a conversation to a specific admin or team in Intercom.

Attach contact to company

Tool to attach a contact to a company in Intercom.

Attach contact to conversation

Tool to attach a contact participant to a conversation on behalf of admin or contact.

Attach tag to conversation

Tool to add a tag to a specific conversation in Intercom.

Attach tag to ticket

Tool to add a tag to a ticket in Intercom.

Block contact

Tool to block a single contact in Intercom.

Cancel data export

Tool to cancel an active content data export job.

Close conversation

Closes a conversation in Intercom, marking it as resolved.

Create a collection

You can create a new collection by making a POST request to `https://api.

Create an article

You can create a new article by making a POST request to `https://api.

Create a note

You can add a note to a single contact.

Create contact

Tool to create a new contact in Intercom workspace.

Create content import source

Tool to create a new content import source for the Fin Content Library.

Create conversation

Creates a new conversation in Intercom.

Create data attribute

Tool to create a custom data attribute for contacts or companies.

Create data event

Tool to submit a data event to Intercom to track user activities.

Create data export

Tool to initiate an async data export job for message content.

Create external page

Tool to create an external page in Fin Content Library or update an existing page by external ID.

Create help center section

Tool to create a new help center section within a collection.

Create internal article

Tool to create a new internal article for team knowledge sharing.

Create or update a company

You can create or update a company.

Create or update tag

Tool to create or update a tag, and optionally tag/untag companies or tag contacts.

Create ticket

Tool to create a ticket in Intercom to track customer requests and issues.

Create a ticket type

Tool to create a new ticket type that defines the data structure for tracking customer requests.

Create ticket type attribute

Tool to create a new attribute for a ticket type in Intercom.

Create event summaries

Tool to create event summaries for a user to track event occurrences.

Delete a collection

You can delete a single collection by making a DELETE request to `https://api.

Delete a company

You can delete a single company.

Delete an article

You can delete a single article by making a DELETE request to `https://api.

Delete a tag

Tool to delete a tag from Intercom workspace.

Delete a visitor

Tool to delete a visitor from the Intercom workspace.

Delete a contact

Tool to delete a contact from the Intercom workspace.

Delete content import source

Tool to delete a content import source and all its external pages.

Delete external page

Tool to delete an external page from content library and AI answers.

Delete internal article

Tool to delete a single internal article by ID.

Delete ticket

Tool to delete a ticket from the Intercom system.

Detach a contact from tag

Tool to remove a tag from a specific contact in Intercom.

Detach contact from company

Tool to detach a contact from a company in Intercom.

Detach tag from conversation

Tool to remove a tag from a specific conversation in Intercom.

Detach tag from ticket

Tool to remove a tag from a ticket in Intercom.

Download data export

Tool to download content data export from Intercom.

Enqueue create ticket

Tool to enqueue ticket creation for asynchronous processing.

Find a tag

Tool to retrieve details for a specific tag by its ID.

Get a contact

You can fetch the details of a single contact.

Get content import source

Tool to retrieve a content import source by its ID.

Get conversation

Retrieves a specific conversation by ID with all messages and details.

Get entity counts

Tool to retrieve summary counts for Intercom app entities including companies, users, leads, tags, segments, and conversations.

Get custom object instance by external ID

Tool to retrieve a custom object instance by its external_id.

Get external page

Tool to retrieve an external page from Fin Content Library by ID.

Get ticket

Tool to retrieve a ticket from Intercom.

Get a ticket type

Tool to retrieve details for a specific ticket type by its ID.

Identify an admin

You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology).

Retrieve job status

Tool to retrieve the status of job execution.

List all activity logs

You can get a log of activities by all admins in an app.

List all admins

You can fetch a list of admins for a given workspace.

List all articles

You can fetch a list of all articles by making a GET request to `https://api.

List all collections

You can fetch a list of all collections by making a GET request to `https://api.

List all companies

You can list companies.

List all help centers

You can list all Help Centers by making a GET request to `https://api.

List all macros

Tool to fetch a list of all macros (saved replies) in your workspace for use in automating responses.

List all notes

You can fetch a list of notes that are associated to a contact.

List attached companies for contact

You can fetch a list of companies that are associated to a contact.

List attached contacts

You can fetch a list of all contacts that belong to a company.

List attached segments for companies

You can fetch a list of all segments that belong to a company.

List attached segments for contact

You can fetch a list of segments that are associated to a contact.

List away status reasons

Tool to retrieve all away status reasons for a workspace including deleted ones.

List calls

Tool to list all phone calls from Intercom with pagination support.

List calls with transcripts

Tool to retrieve calls by conversation IDs with transcripts when available.

List company notes

Tool to list all notes associated with a specific company.

List all contacts

Tool to list all contacts (users or leads) in your Intercom workspace with pagination support.

List content import sources

Tool to retrieve all content import sources for the workspace.

List conversations

Lists all conversations from Intercom with pagination support.

List data attributes

Tool to list all data attributes for contacts, companies, and conversations.

List data events

Tool to retrieve a log of data events belonging to a customer.

List external pages

Tool to list all external pages from Fin Content Library.

List help center sections

Tool to fetch a list of all help center sections in descending order by updated_at.

List internal articles

Fetches one page of internal articles from Intercom.

List all news items

Tool to fetch a list of all news items from Intercom.

List all segments

Tool to retrieve all segments defined within a workspace for filtering and categorizing contacts.

List subscriptions for a contact

You can fetch a list of subscription types that are attached to a contact.

List subscription types

Tool to list all subscription types available in the workspace.

List all tags

Tool to fetch all tags for the workspace.

List tags attached to a contact

You can fetch a list of all tags that are attached to a specific contact.

List all teams

Tool to retrieve all teams within a workspace.

List all ticket states

Tool to fetch all ticket states for the workspace.

List all ticket types

Tool to retrieve all ticket types for the workspace.

Merge a lead and a user

You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`.

Register Fin Voice call

Tool to register a Fin Voice call with Intercom.

Remove subscription from a contact

You can remove a specific subscription from a contact.

Remove tag from a contact

You can remove tag from a specific contact.

Reopen conversation

Reopens a closed conversation in Intercom.

Reply to ticket

Tool to reply to a ticket with a message from admin or contact, or with a note for admins.

Reply to conversation

Sends a reply to an existing conversation in Intercom.

Retrieve a collection

You can fetch the details of a single collection by making a GET request to `https://api.

Retrieve a company by id

You can fetch a single company.

Retrieve a help center

You can fetch the details of a single Help Center by making a GET request to `https://api.

Retrieve job status

Tool to retrieve the status of a data export job.

Retrieve a macro

Tool to fetch a single macro (saved reply) by its ID.

Retrieve an admin

You can retrieve the details of a single admin.

Retrieve an article

You can fetch the details of a single article by making a GET request to `https://api.

Retrieve a segment

Tool to retrieve details for a single segment by its ID.

Retrieve companies

You can fetch a single company by passing in `company_id` or `name`.

Retrieve internal article

Tool to retrieve an internal article by ID from Intercom.

Retrieve note

Tool to retrieve details of a single note by its identifier.

Retrieve a team

Tool to retrieve detailed information about a specific team by ID.

Retrieve visitor with user ID

Tool to retrieve a specific visitor's details using their user_id.

Scroll over all companies

The `list all companies` functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply.

Search contacts

Tool to search for contacts using query filters with operators.

Search conversations

Searches for conversations using query string with support for filtering and sorting

Search for articles

You can search for articles by making a GET request to `https://api.

Search internal articles

Searches one page of internal articles in Intercom.

Search tickets

Tool to search tickets in Intercom by filtering attribute values.

Set admin to away

Tool to set an admin to away status in Intercom.

Set an admin to away

You can set an Admin as away for the Inbox.

Show call

Tool to retrieve a single call by ID from Intercom.

Show call transcript

Tool to get call transcript by call ID.

Show contact by external ID

Tool to retrieve a contact by their external ID.

Unarchive contact

Tool to unarchive a previously archived contact in Intercom.

Update a collection

You can update the details of a single collection by making a PUT request to `https://api.

Update a company

You can update a single company using the Intercom provisioned `id`.

Update a contact

You can update an existing contact (ie.

Update an article

You can update the details of a single article by making a PUT request to `https://api.

Update contact

Tool to update an existing contact in Intercom.

Update content import source

Tool to update an existing content import source in Fin Content Library.

Update data attribute

Tool to update an existing data attribute in Intercom.

Update external page

Tool to update an existing external page in Fin Content Library.

Update internal article

Tool to update an internal article with new title, body, author or owner information.

Update ticket

Tool to update an existing ticket in Intercom.

Update a ticket type

Tool to update an existing ticket type in the workspace.

Update ticket type attribute

Tool to update an existing attribute for a ticket type.

FAQ

Frequently asked questions

With a standalone Intercom MCP server, the agents and LLMs can only access a fixed set of Intercom tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Intercom and many other apps based on the task at hand, all through a single MCP endpoint.

Yes, you can. LangChain fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Intercom tools.

Yes, absolutely. You can configure which Intercom scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Intercom data and credentials are handled as safely as possible.

Start with Intercom.It takes 30 seconds.

Managed auth, hosted MCP servers, and every Intercom tool your agent needs.Free to start.

Start building