Skip to content

AI Content

With the AI Content APIs, you can create and manage External Pages and Content Import Sources for your Fin Content Library.

 

External Pages are pages that you want Fin to be able to answer questions about. The API for External Pages is a great way to ingest into your Fin Content Library pages that are not publicly accessible and hence can't be crawled by Intercom.

 

Content Import Sources are the sources of those pages, and they are used to determine the default audience for the pages (configured via the UI). You should create a Content Import Source for each source of External Pages that you want to ingest into your Fin Content Library.

 

You can then iterate through the content from that source via its API and POST it to the External Pages endpoint. That endpoint has an external_id parameter which allows you to specify the identifier from the source. The endpoint will then either create a new External Page or update an existing one as appropriate.",

Create an API template source

Request

You can create a source that imports content from a knowledge base's REST API. Send a template that describes the vendor's API and an auth_token for the knowledge base. Write each value the vendor's API needs, such as a space or project ID, into the template itself.

Intercom checks the request, then checks the token by sending the template's tree request. If both pass, Intercom saves the source, starts its first sync and returns the source. The auth_token is never returned. If the first sync can't start, the source is still created, with a latest_sync that is null or has the status failed; use Sync an API template source to start one. Intercom also syncs each source automatically, about once a day, unless the vendor has rejected the token.

If the request isn't valid, the response is a 422 with one or more errors. Each error has a field that names the request field, such as auth_token, template.base_url or template.tree.paging. A missing value has the code parameter_not_found; any other failure has the code parameter_invalid. When the template fails a check, the message names the check, such as base_url fails the not_https check. The template fields below list their checks. A template without mapping.updated_at, or with null there, fails on template.mapping.updated_at with the message mapping.updated_at is required. Sending variables, at the top level or in template, fails on variables or template.variables with the message variables is no longer supported: write each value into the template itself.

A tree response over 25 MB fails on template.tree with the message <name>'s tree response is too large: over the 25 MB cap. If tree has no paging and the tree response says it has more, as described under tree.paging, the request fails on template.tree.paging with the code parameter_not_found and the message <name>'s first page says more pages exist: declare paging to read them all. In both messages, <name> is the template's name.

If the vendor answers the tree request with 401 or 403, the error is parameter_invalid on auth_token with the message <name> rejected the token. Any other failed answer, such as a 404 for tree.path, a redirect, a 429, a 5xx or a timeout, gives parameter_invalid on auth_token with the message <name> could not be reached to check the token. In both messages, <name> is the template's name.

OAuth tokens must have the read_write_ai_content scope.

Security
bearerAuth
Headers
Intercom-Versionstring(intercom_version_preview)

Preview Intercom API version. Used for closed beta endpoints or other features under managed availability.

Default:"Preview"
Value:"Preview"
Example:Preview
Bodyapplication/jsonrequired
templateobject(API Template)required

Describes a knowledge base's REST API so that Intercom can import its content. On each sync, Intercom:

  1. Sends a GET request to base_url and tree.path, and reads the list of nodes at tree.nodes in the JSON response, following tree.children into nested nodes. With tree.child_calls, it then sends each child call for every node the level above listed, and adds the nodes it returns as that node's children. When the tree request or a child call has paging, Intercom requests every page of that call's list in turn. Intercom lists the whole tree before it imports anything.
  2. Creates a folder for each node that matches tree.folder_if, or that has children when tree.folder_if_has_children is true.
  3. For each node that matches tree.content_if, or every node if it's left out, imports the page using the fields set in mapping. If the template has an item, Intercom first sends a GET request to base_url and item.path for the node, and mapping can read from that response.

Imported content goes into a Knowledge Hub folder named after name.

Placeholders. Write each fixed value, such as a space or project ID, into the template itself. base_url, tree.path and tree.query values can't use placeholders. In item.path and item.query values, {name} is replaced with one of the item's node_values, filled from the node being imported. In a child call's path and query values, {name} is one of that child call's node_values, filled from the node the call is sent for. A query value of exactly {token} is replaced with the source's auth_token. A value filled into a path can only use letters, digits, ., _ and -, and can't be only dots. A node value that's blank, or that's filled into a path and doesn't meet this rule, fails the sync.

Defaults. Only name, base_url, tree and mapping are required. A field that has a default takes it when it's left out or null: auth sends the token in an Authorization header with the value Bearer {token}, tree.content_if imports every node as content, and body_format is html. Leave out item when the tree's nodes hold everything mapping reads. The source returns the template as you sent it, without the defaults filled in.

Checks. When the template fails a check, creating the source returns a 422 parameter_invalid error whose field names the template field and whose message names the check. For example, the field is template.base_url and the message is base_url fails the not_https check. Each field below lists its checks. Top-level keys that aren't template fields are ignored and not saved, except variables, which fails the request. A tree response over 25 MB isn't a check: it fails on template.tree with the message <name>'s tree response is too large: over the 25 MB cap. Nor is a tree response that says it has more when tree has no paging; see tree.paging.

Limits.

  • Nothing is imported until the whole tree is listed, so if a request that lists the tree fails, content from earlier syncs is kept. A 404 on the first tree request fails the sync and stops Intercom syncing the source automatically until a sync you start with Sync an API template source succeeds. A 404 on a later tree page or on a child call doesn't stop automatic syncs.
  • When a request fails with a status other than 401, 403 or 429, or times out, Intercom tries the sync again later, a few times at most. That includes a 400, a 5xx, and a 404 on a later tree page or a child call, but not a 404 on the first tree request, described above, or on an item, which is skipped. The sync's status stays in_progress until a try succeeds or the last one fails.
  • A sync fails without another try if a tree request or child call without paging gets a response that says it has more, as described under tree.paging, or if, in one try, a listing response (a tree page or a child call) is over 25 MB, the listing responses add up to more than 100 MB, the tree has more than 50,000 nodes, or more than 100,000 requests are sent, retries included. When you create the source, a tree response over 25 MB fails on template.tree with the message <name>'s tree response is too large: over the 25 MB cap.
  • A tree can be up to 12 levels deep. The tree request's nodes are the first level, and each level of children or each child call adds one. Deeper nodes are skipped.
  • An item response over 10 MB is skipped, as is an item the vendor returns 404 for.
  • A redirect isn't followed, and fails the sync.
  • During a sync, when the vendor answers 429, Intercom waits for the longest time given by its Retry-After, RateLimit-Reset and X-RateLimit-Reset headers, or 60 seconds if they don't give one, and then retries. Each header is read as seconds, except that Retry-After can also be an HTTP date, and an X-RateLimit-Reset above 1,000,000,000 is read as a Unix time. If the vendor keeps answering 429, the sync fails.
Example:
{ "name": "Example Docs", "base_url": "https://api.example.com/v1", "auth": { "header": "Authorization", "value": "Bearer {token}" }, "tree": { "path": "/spaces/help-center/pages", "query": { … }, "nodes": [ … ], "children": "pages", "folder_if": [ … ], "folder_if_has_children": true, "content_if": [ … ] }, "item": { "path": "/spaces/help-center/pages/{page_id}", "node_values": { … } }, "mapping": { "id": [ … ], "title": [ … ], "body": [ … ], "updated_at": [ … ] }, "body_format": "html" }
auth_tokenstringrequired

The API token for the knowledge base, sent as template.auth describes, or as a {token} query value. It can only use printable ASCII characters. Intercom checks it by sending the template's tree request before saving the source. It's never returned.

Example:"vendor-api-token"
curl -i -X POST \
  https://api.intercom.io/ai/api_template_sources \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -H 'Intercom-Version: Preview' \
  -d '{
    "template": {
      "name": "Example Docs",
      "base_url": "https://api.example.com/v1",
      "auth": {
        "header": "Authorization",
        "value": "Bearer {token}"
      },
      "tree": {
        "path": "/spaces/help-center/pages",
        "query": {
          "status": "published"
        },
        "nodes": [
          "pages"
        ],
        "children": "pages",
        "folder_if": [
          {
            "type": "group"
          }
        ],
        "folder_if_has_children": true,
        "content_if": [
          {
            "type": "document"
          }
        ]
      },
      "item": {
        "path": "/spaces/help-center/pages/{page_id}",
        "node_values": {
          "page_id": [
            "id"
          ]
        }
      },
      "mapping": {
        "id": [
          "node",
          "id"
        ],
        "title": [
          "node",
          "title"
        ],
        "body": [
          "item",
          "body"
        ],
        "updated_at": [
          "item",
          "updatedAt"
        ]
      },
      "body_format": "html"
    },
    "auth_token": "vendor-api-token"
  }'

Responses

API template source created

Bodyapplication/json
typestringrequired

Always api_template_source.

Value:"api_template_source"
Example:"api_template_source"
idstringrequired

The unique identifier for the source, given by Intercom.

Example:"4182"
templateobject(API Template)required

The source's template, as saved. Top-level keys that aren't template fields are removed, and fields that were left out are returned without their defaults.

Example:
{ "name": "Example Docs", "base_url": "https://api.example.com/v1", "auth": { "header": "Authorization", "value": "Bearer {token}" }, "tree": { "path": "/spaces/help-center/pages", "query": { … }, "nodes": [ … ], "children": "pages", "folder_if": [ … ], "folder_if_has_children": true, "content_if": [ … ] }, "item": { "path": "/spaces/help-center/pages/{page_id}", "node_values": { … } }, "mapping": { "id": [ … ], "title": [ … ], "body": [ … ], "updated_at": [ … ] }, "body_format": "html" }
created_atinteger, (date-time)required

The time the source was created.

Example:1792713600
latest_syncobject or nullrequired

The source's most recent sync, or null if no sync has started.

Example:
{ "id": "90817", "status": "in_progress", "created_at": 1792713601, "updated_at": 1792713601 }
Response
{ "type": "api_template_source", "id": "4182", "template": { "name": "Example Docs", "base_url": "https://api.example.com/v1", "auth": { … }, "tree": { … }, "item": { … }, "mapping": { … }, "body_format": "html" }, "created_at": 1792713600, "latest_sync": { "id": "90817", "status": "in_progress", "created_at": 1792713601, "updated_at": 1792713601 } }