### Fetch Next Page using Starting After Cursor Source: https://developers.intercom.com/docs/guides/mcp.md This example demonstrates how to construct a query to fetch the next page of results by using the 'starting_after' cursor obtained from a previous response. ```plaintext object_type:conversations state:open limit:50 starting_after:cursor_abc123 ``` -------------------------------- ### Start MCP Inspector Source: https://developers.intercom.com/docs/guides/mcp.md Use this command to start the MCP Inspector for server exploration. Ensure you have Node.js and npm installed. ```bash npx @modelcontextprotocol/inspector ``` -------------------------------- ### Install .NET Intercom SDK Source: https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/sdks-plugins.md Use this NuGet command to install the .NET client library for Intercom. ```.NET Install-Package Intercom.Dotnet.Client ``` -------------------------------- ### Card Creation Options Example Source: https://developers.intercom.com/docs/references/canvas-kit/requestobjects/card-creation-options.md A basic example of the card_creation_options object structure, which can contain multiple key-value pairs. ```json card_creation_options: { "key": "value" } //Can be more than one pair ``` -------------------------------- ### Ruby SDK Example Source: https://developers.intercom.com/docs/references/rest-api/errors/rate-limiting.md An example of how to retrieve rate limit details using the Intercom Ruby SDK. ```APIDOC ## Ruby SDK Example An example of how to retrieve rate limit details using the Intercom Ruby SDK. ```ruby intercom.rate_limit_details #=> {:limit=>1000, :remaining=>999, :reset_at=>2019-08-05 14:59:00 +0100} ``` ``` -------------------------------- ### Install PHP Intercom SDK Source: https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/sdks-plugins.md Use this command to install the PHP SDK and the Guzzle adapter for HTTP requests. ```PHP composer require intercom/intercom-php php-http/guzzle6-adapter ``` -------------------------------- ### Example Search Conversations Next Request with starting_after Source: https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination.md This example shows how to request the next page of results by including the `starting_after` cursor from the previous response. ```APIDOC ## POST /conversations/search with starting_after ### Description Fetches the next page of search results by providing the `starting_after` cursor. ### Method POST ### Endpoint https://api.intercom.io/conversations/search ### Parameters #### Request Body - **query** (Object) - Required - The search query object. - **operator** (String) - Required - The logical operator for the query (e.g., "AND"). - **value** (Array) - Required - An array of filter conditions. - **field** (String) - Required - The field to filter on (e.g., "created_at"). - **operator** (String) - Required - The comparison operator (e.g., ">"). - **value** (String) - Required - The value to compare against. - **pagination** (Object) - Optional - The pagination object. - **per_page** (Integer) - Optional - The number of items to return per page. Defaults to 20, max is 150. - **starting_after** (String) - Required - The cursor used for pagination to fetch the next page of results. ### Request Example ```json { "query": { "operator": "AND", "value": [ { "field": "created_at", "operator": ">", "value": "1693782000" } ] }, "pagination": { "per_page": 10, "starting_after": "WzE3MDk2NTMxODUwMDAsMTkwLDJd" } } ``` ### Response #### Success Response (200) - **pages** (Object) - Contains pagination details. - **type** (String) - Type of pagination object. - **next** (Object) - Information about the next page. - **page** (Integer) - The next page number. - **starting_after** (String) - The cursor for the next page. - **page** (Integer) - The current page number. - **per_page** (Integer) - The number of items per page. - **total_pages** (Integer) - The total number of pages. - **total_count** (Integer) - The total number of items matching the search criteria. - **conversations** (Array) - An array of conversation objects. #### Response Example ```json { "pages": { "type": "pages", "next": { "page": 3, "starting_after": "WzE3MDk2NTMxMjgwMDAsMTgwLDNd" }, "page": 2, "per_page": "10", "total_pages": 8 }, "total_count": 72, "conversations": [...] } ``` ``` -------------------------------- ### Example URL Action Object Source: https://developers.intercom.com/docs/references/canvas-kit/actioncomponents/url-action.md An example of a JSON object representing a URL action. ```APIDOC ## Example URL Action Object ### Description This is an example of how a URL action object should be structured. ### Request Example ```json { "type": "url", "url": "https://www.example.com" } ``` ``` -------------------------------- ### Initialize Request Payload Example (JSON) Source: https://developers.intercom.com/docs/canvas-kit.md This is an example of the JSON payload received for an Initialize request. It contains workspace, admin, conversation, and contact information. ```json { "workspace_id": "abcd123", "admin": { /* Object: See link in table for the full model */ }, "conversation": { /* Object: See link in table for the full model */ }, "contact": { /* Object: See link in table for the full model */} } ``` -------------------------------- ### Create Project Directory and Navigate Source: https://developers.intercom.com/docs/guides/tickets/import-tickets.md Sets up a new directory for the ticket import project and changes into it. ```bash mkdir import_tickets cd import_tickets ``` -------------------------------- ### Initialize Node.js Project and Install Dependencies Source: https://developers.intercom.com/docs/guides/tickets/import-contacts.md Initialize a new Node.js project and install the 'dotenv' and 'node-fetch' packages. 'dotenv' is used for managing environment variables like your Intercom Access Token, and 'node-fetch' enables making HTTP requests to the Intercom API. ```bash npm init npm install dotenv node-fetch ``` -------------------------------- ### List all activity logs Source: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/admins/listadmins You can get a log of activities by all admins in an app. This endpoint supports filtering by a start and end date using Unix timestamps. ```APIDOC ## GET /admins/activity_logs ### Description Retrieves a log of activities performed by all admins in an app, with optional date filtering. ### Method GET ### Endpoint /admins/activity_logs ### Parameters #### Query Parameters - **created_at_after** (string) - Required - The start date for the activity log data, formatted as a Unix timestamp. - **created_at_before** (string) - Optional - The end date for the activity log data, formatted as a Unix timestamp. #### Headers - **Intercom-Version** (string) - Optional - The Intercom API version. Defaults to the version set in the app package (e.g., 2.15). ### Request Example ``` curl -i -X GET \ 'https://api.intercom.io/admins/activity_logs?created_at_after=1677253093&created_at_before=1677861493' \ -H 'Authorization: Bearer ' \ -H 'Intercom-Version: 2.15' ``` ### Response #### Success Response (200) - **type** (string) - Represents the object's type, always `activity_log.list`. - **pages** (object or null) - Cursor-based pagination information. - **activity_logs** (Array of objects or null) - An array containing activity log objects. #### Response Example ```json { "type": "activity_log.list", "pages": { "type": "pages", "next": null, "page": 1, "per_page": 20, "total_pages": 1 }, "activity_logs": [ { ... }, { ... } ] } ``` ``` -------------------------------- ### Create Project Directory and Navigate Source: https://developers.intercom.com/docs/guides/tickets/import-contacts.md Use these commands to create a new directory for your project and navigate into it. This is the first step in setting up your Node.js project for contact import. ```bash mkdir import_contacts cd import_contacts ``` -------------------------------- ### Install Go Intercom SDK Source: https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/sdks-plugins.md Use this command to fetch the Go SDK for Intercom. ```Go go get gopkg.in/intercom/intercom-go.v2 ``` -------------------------------- ### Apache VirtualHost Configuration for SSL Source: https://developers.intercom.com/docs/guides/help-center/custom-domains.md Example Apache VirtualHost configuration for handling SSL traffic with a custom domain. Ensure mod_ssl, mod_proxy, and mod_proxy_http are enabled. This configuration is for a TLS termination proxy setup. ```apache ServerName your-help-site.custom-domain.com # specify your custom domain here ``` -------------------------------- ### Retrieve Admin and App Information with PHP Guzzle Source: https://developers.intercom.com/docs/build-an-integration/learn-more/authentication/setting-up-oauth.md Use the Guzzle HTTP client in PHP to make a GET request to the /me endpoint. Ensure you have installed Guzzle via Composer and set the appropriate headers. ```php // composer require guzzlehttp/guzzle request('GET', 'https://api.intercom.io/me', [ 'headers' => [ 'Intercom-Version' => '2.8', 'accept' => 'application/json', 'authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` -------------------------------- ### Example Segment Object Source: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/Segments/listSegmentsForAContact This is an example of a Segment object as returned by the API. ```json { "type": "segment", "id": "56203d253cba154d39010062", "name": "Active", "created_at": 1394621988, "updated_at": 1394622004, "person_type": "contact", "count": 3 } ``` -------------------------------- ### Successful Response Example Source: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/contacts/detachtagfromcontact This is an example of a successful response when a tag is detached from a contact. ```json { "type": "contact_tag_removal", "contact_id": "6762f0ad1bb69f9f2193bb62", "tag_id": "32" } ``` -------------------------------- ### Connect to SSE using EventSource Source: https://developers.intercom.com/docs/guides/fin-agent-api.md This example shows how to establish an SSE connection after obtaining an sse_subscription_url and how to handle 'fin_replied' and 'fin_status_updated' events. The connection is closed when Fin indicates it's awaiting user reply or the conversation is complete. ```javascript // After calling an endpoint that returns an sse_subscription_url (e.g. /fin/ask) const response = await fetch('https://api.intercom.io/fin/ask', { method: 'POST', headers: { 'Authorization': 'Bearer ', 'Content-Type': 'application/json', 'Intercom-Version': 'Preview' }, body: JSON.stringify({ /* request payload */ }) }); const data = await response.json(); // Connect to SSE using the subscription URL const eventSource = new EventSource(data.sse_subscription_url); eventSource.onmessage = (event) => { const eventData = JSON.parse(event.data); if (eventData.event_name === 'fin_replied') { // Handle Fin's reply console.log('Fin replied:', eventData.message.body); } if (eventData.event_name === 'fin_status_updated') { console.log('Status updated:', eventData.status); if (eventData.status === 'awaiting_user_reply' || eventData.status === 'complete') { // Fin is done with this cycle — close the SSE connection eventSource.close(); } } }; eventSource.onerror = (error) => { console.error('SSE connection error:', error); eventSource.close(); }; ``` -------------------------------- ### Create Example Contacts Source: https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination-cursor.md Use this Node.js script to create 50 example contacts in your Intercom workspace for testing pagination. Ensure you replace '' with your actual Intercom access token. ```javascript for (let i = 0; i < 50; i++) { const resp = await fetch( `https://api.intercom.io/contacts`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Intercom-Version': '2.10', Authorization: 'Bearer ' }, body: JSON.stringify({ email: 'user_' + i + '@example.com' }) } ); const data = await resp.json(); console.log(data.id); } ``` -------------------------------- ### Contact Response Example Source: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/contacts/blockcontact Example of a successful response when retrieving contact information. ```APIDOC ## Response ### Success Response (200) ```json { "type": "contact", "id": "6762f0dd1bb69f9f2193bb83", "workspace_id": "this_is_an_id303_that_should_be_at_least_", "external_id": null, "role": "user", "email": "joebloggs@intercom.io", "phone": null, "name": null, "avatar": null, "owner_id": null, "social_profiles": { "type": "list", "data": [] }, "has_hard_bounced": false, "marked_email_as_spam": false, "unsubscribed_from_emails": false, "created_at": 1734537437, "updated_at": 1734537437, "signed_up_at": null, "last_seen_at": null, "last_replied_at": null, "last_contacted_at": null, "last_email_opened_at": null, "last_email_clicked_at": null, "language_override": null, "browser": null, "browser_version": null, "browser_language": null, "os": null, "location": { "type": "location", "country": null, "region": null, "city": null, "country_code": null, "continent_code": null }, "android_app_name": null, "android_app_version": null, "android_device": null, "android_os_version": null, "android_sdk_version": null, "android_last_seen_at": null, "ios_app_name": null, "ios_app_version": null, "ios_device": null, "ios_os_version": null, "ios_sdk_version": null, "ios_last_seen_at": null, "custom_attributes": {}, "tags": { "type": "list", "data": [], "url": "/contacts/6762f0dd1bb69f9f2193bb83/tags", "total_count": 0, "has_more": false }, "notes": { "type": "list", "data": [], "url": "/contacts/6762f0dd1bb69f9f2193bb83/notes", "total_count": 0, "has_more": false }, "companies": { "type": "list", "data": [], "url": "/contacts/6762f0dd1bb69f9f2193bb83/companies", "total_count": 0, "has_more": false }, "opted_out_subscription_types": { "type": "list", "data": [], "url": "/contacts/6762f0dd1bb69f9f2193bb83/subscriptions", "total_count": 0, "has_more": false }, "opted_in_subscription_types": { "type": "list", "data": [], "url": "/contacts/6762f0dd1bb69f9f2193bb83/subscriptions", "total_count": 0, "has_more": false }, "utm_campaign": null, "utm_content": null, "utm_medium": null, "utm_source": null, "utm_term": null, "referrer": null, "enabled_push_messaging": null } ``` ``` -------------------------------- ### Company Schema Example Source: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/Companies/listAllCompanies This is an example of the JSON structure for a company object in Intercom. ```json { "type": "company", "id": "531ee472cce572a6ec000006", "name": "Blue Sun", "app_id": "ecahpwf5", "plan": { "type": "plan", "id": "269315", "name": "Pro" }, "company_id": "6", "remote_created_at": 1663597223, "created_at": 1663597223, "updated_at": 1663597223, "last_request_at": 1663597223, "size": 100, "website": "https://www.intercom.com", "industry": "Software", "monthly_spend": 100, "session_count": 100, "user_count": 100, "custom_attributes": { "paid_subscriber": true, "monthly_spend": 155.5, "team_mates": 9 }, "tags": { "type": "tag.list", "tags": [ … ] }, "segments": { "type": "segment.list", "segments": [ … ] } } ``` -------------------------------- ### GET /articles/search Source: https://developers.intercom.com/docs/references/rest-api/api.intercom.io.md You can search for articles by making a GET request to https://api.intercom.io/articles/search. ```APIDOC ## GET /articles/search ### Description You can search for articles by making a GET request to https://api.intercom.io/articles/search. ### Method GET ### Endpoint /articles/search ``` -------------------------------- ### Start Fin Agent Source: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/Segments/listSegments Initiates a session with the Fin Agent API. ```APIDOC ## POST /fin/start ### Description Initiates a session with the Fin Agent API. This is the primary endpoint for starting interactions with Fin. ### Method POST ### Endpoint /fin/start ``` -------------------------------- ### Delete Article Response Example Source: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/Articles This is an example of a successful JSON response when an article is deleted. ```json { "id": "51", "object": "article", "deleted": true } ``` -------------------------------- ### Contact Tags Response Example Source: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/contacts/createnote Example JSON response when listing or adding tags to a contact. ```json { "type": "list", "data": [ { … } ] } ``` ```json { "type": "tag", "id": "81", "name": "Manual tag", "applied_at": 1663597223, "applied_by": { "type": "admin", "id": "456" } } ``` -------------------------------- ### Create Data and Environment Files Source: https://developers.intercom.com/docs/guides/tickets/import-contacts.md Create the 'contacts.json' file for your contact data and the '.env' file for your Intercom API credentials. Ensure your 'package.json' includes '"type": "module"' to use ES module syntax. ```bash touch contacts.json touch .env ``` -------------------------------- ### Example Call Transcript Content Source: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/calls/collectfinvoicecallbyexternalid This is an example of the text content returned when retrieving a call transcript. ```text [00:00:03] Teammate 1: "Hello, thanks for calling. How can I help today?" [00:00:09] User: "I need help recovering access to my account." [00:00:15] Teammate 1: "I can help with that. For security, I’ll ask a few generic verification questions." [00:00:22] User: "Okay." [00:00:28] Teammate 1: "Please confirm general details on the account (no sensitive data over this call)." [00:00:35] User: "I can provide non-sensitive info." [00:00:41] Teammate 1: "Thank you. I’ll initiate a standard account recovery process and send the next steps." [00:00:48] User: "Great, thanks." [00:00:53] Teammate 1: "You should receive a message shortly with instructions to complete recovery." ``` -------------------------------- ### Pagination Example for Universal Search Source: https://developers.intercom.com/docs/guides/mcp.md To fetch the next page of search results, append the 'starting_after' parameter with the cursor value provided in the previous response. ```plaintext object_type:conversations state:open starting_after:cursor_abc123 ``` -------------------------------- ### Webhook Signature Example Source: https://developers.intercom.com/docs/guides/fin-agent-api/setup.md Example of an HTTP POST request header including the webhook signature for verification. ```http POST https://example.org/hooks X-Fin-Agent-API-Webhook-Signature: sha256=21ff2e149e0fdcac6f947740f6177f6434bda921 Content-Type: application/json ``` -------------------------------- ### Get Company Source: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/Companies/listAllCompanies Retrieves a specific company by its ID. Use this to get detailed information about a single company. ```APIDOC ## GET /companies/{company_id} ### Description Retrieves a specific company by its ID. ### Method GET ### Endpoint /companies/{company_id} ### Parameters #### Path Parameters - **company_id** (string) - Required - The Intercom defined ID of the company to retrieve. ### Response #### Success Response (200) - **type** (string) - The type of the object, always "company". - **id** (string) - The Intercom defined id representing the company. - **name** (string) - The name of the company. - **company_id** (string) - The company id you have defined for the company. - **remote_created_at** (integer) - The time the company was created by you. - **created_at** (integer) - The time the company was added in Intercom. - **updated_at** (integer) - The last time the company was updated. - **custom_attributes** (object) - The custom attributes you have set on the company. #### Response Example ```json { "type": "company", "id": "531ee472cce572a6ec000006", "name": "Blue Sun", "company_id": "6", "remote_created_at": 1663597223, "created_at": 1663597223, "updated_at": 1663597223, "custom_attributes": { "paid_subscriber": true, "monthly_spend": 155.5, "team_mates": 9 } } ``` ``` -------------------------------- ### Full Sample Server Code (Node.js) Source: https://developers.intercom.com/docs/build-an-integration/getting-started/build-an-app-for-your-messenger/sheets-app.md This is the complete server-side code for the scheduling app. It sets up an Express server, handles CORS, JSON parsing, static file serving, and defines routes for initializing the app, handling submissions, and displaying sheets. ```javascript import express from "express"; import bodyParser from "body-parser"; import { fileURLToPath } from "url"; import path from "path"; import cors from "cors"; import crypto from "crypto"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const app = express(); app.use(function (req, res, next) { res.setHeader( "Content-Security-Policy", "frame-src 'self' https://intercom-sheets.com", ); res.setHeader("X-Requested-With", "XMLHttpRequest"); next(); }); app.use(cors()); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); app.use(express.static("public")); app.use(express.static(path.join(__dirname))); const listener = app.listen(process.env.PORT, () => { console.log("Your app is listening on port " + listener.address().port); }); const initialCanvas = { canvas: { content: { components: [ { type: "text", id: "book-meeting", text: "Book a Meeting", align: "center", style: "header", }, { type: "button", label: "See dates", style: "primary", id: "submit_button", action: { type: "sheet", url: "https://your-replit-url.replit.app/sheet", }, }, ], }, }, }; // Serve static files from the "public" directory app.use(express.static(path.join(__dirname, "public"))); app.get("/", (req, res) => { res.sendFile(path.join(__dirname, "index.html")); }); // Send the first canvas which will display a button app.post("/initialize", (req, res) => { res.send(initialCanvas); }); // Handle submit actions (required webhook, returns the current canvas) app.post("/submit", (req, res) => { res.send({ canvas: req.body.current_canvas }); }); /* When this endpoint is called, it will decode and verify the user, then display the sheet in the iFrame. */ app.post("/sheet", (req, res) => { const jsonParsed = JSON.parse(req.body.intercom_data); const encodedUser = jsonParsed.user; console.log(encodedUser); let decodedUser = decodeUser(encodedUser); console.log(decodedUser); res.sendFile(path.join(__dirname, "public", "sheet.html")); }); /* When this endpoint is called from within the sheet, it will: - close the sheet - gather the user-submitted data - display the final canvas you would like to show the user You could also take the user data and pass it from here to perform other actions. */ app.post("/submit-sheet", (req, res) => { // you can get data about the contact, company, and sheet from the request console.log(req.body); const chosenDate = new Date(req.body.sheet_values.date); // Extract the date part in YYYY-MM-DD format const displayDate = chosenDate.toISOString().split("T")[0]; const finalCanvas = { canvas: { content: { components: [ { type: "text", id: "closing", text: "Thanks! Your meeting is booked for " + displayDate, align: "center", style: "header", }, ], }, }, }; res.send(finalCanvas); }); /* This function can be used to decode the user object, which will allow you to verify the identity of the user. */ function decodeUser(encodedUser) { const masterkey = process.env["CLIENT_SECRET"]; // base64 decoding const bData = Buffer.from(encodedUser, "base64"); // convert data to buffers const ivlen = 12; const iv = bData.slice(0, ivlen); const taglen = 16; const tag = bData.slice(bData.length - taglen, bData.length); ``` -------------------------------- ### Data Event Type Examples Source: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/data-events.md Examples demonstrating how to format different data types for events, including String, Number, Date, Link, Rich Link, and Monetary Amount. ```JSON "source":"desktop" ``` ```JSON "load": 3.67 ``` ```JSON "contact_date": 1392036272 ``` ```JSON "article": "https://example.org/ab1de.html" ``` ```JSON "article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"} ``` ```JSON "price": {"amount": 34999, "currency": "eur"} ``` -------------------------------- ### Get Email by ID Source: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/calls/listcallswithtranscripts Retrieves a specific email by its unique identifier. Use this to get details for a single email. ```APIDOC ## GET /emails/{id} ### Description Retrieves a specific email by its unique identifier. ### Method GET ### Endpoint /emails/{id} #### Path Parameters - **id** (string) - Required - The unique identifier of the email. ``` -------------------------------- ### Start Fin Agent Session Source: https://developers.intercom.com/docs/references/rest-api/api.intercom.io/conversations/convertconversationtoticket Initiates a session with the Fin Agent API. ```APIDOC ## POST /fin/start ### Description Initiates a session with the Fin Agent API. This is the entry point for programmatic interaction with Fin. ### Method POST ### Endpoint /fin/start ``` -------------------------------- ### Install Node.js Intercom SDK Source: https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/sdks-plugins.md Use this command to add the Node.js Intercom client to your project. ```Node.js yarn add intercom-client ```