Skip to main content

Quick Start

Install the plugin:
pnpm install @corsair-dev/intercom
Add the Intercom plugin to your Corsair instance:
corsair.ts
import { createCorsair } from "corsair";
import { intercom } from "@corsair-dev/intercom";

export const corsair = createCorsair({
    plugins: [intercom()],
    database: db,
    kek: process.env.CORSAIR_KEK!,
});

Authentication

Supported Auth Types

  • api_key (default) - Access token

API Key Setup

pnpm corsair setup --intercom api_key=your-access-token
For webhook signature verification:
pnpm corsair setup --intercom webhook_signature=your-client-secret
See Get Credentials for step-by-step instructions.

Options

OptionTypeDescription
authType'api_key'Authentication method
keystringAccess token (optional, uses database if not provided)
webhookSecretstringClient secret for webhook verification (optional)
hooksobjectEndpoint hooks for custom logic
webhookHooksobjectWebhook hooks for event handling
errorHandlersobjectCustom error handlers

Usage

// List contacts
const contacts = await corsair.intercom.api.contacts.list({});

// Search contacts
const results = await corsair.intercom.api.contacts.search({
    query: {
        field: "email",
        operator: "=",
        value: "user@example.com",
    },
});

// List open conversations
const conversations = await corsair.intercom.api.conversations.list({
    open: true,
});

// Reply to a conversation
await corsair.intercom.api.conversations.reply({
    conversationId: "conv-id",
    body: "Thanks for reaching out!",
    type: "admin",
});

// Create an article
await corsair.intercom.api.articles.create({
    title: "Getting Started",
    body: "<p>Welcome to our product...</p>",
    state: "published",
});

Query cached data

const contacts = await corsair.intercom.db.contacts.search({
    data: { email: "user@example.com" },
});

Multi-Tenancy

const tenant = corsair.withTenant("workspace-123");

const conversations = await tenant.intercom.api.conversations.list({});