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.",

API Template

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.
namestringrequired

The knowledge base's name. Imported content goes into a Knowledge Hub folder with this name, and error messages use it. Checks: blank.

Example:"Example Docs"
base_urlstringrequired

The base URL of the vendor's API. It must use https, can't include a query string, a fragment or a user name and password, can't point to an Intercom domain, and can't include placeholders. Intercom only sends the token to this URL's host. A URL that can't be parsed fails not_https, and a host whose percent-encoding doesn't decode to valid UTF-8 text, such as %ff, fails invalid. Checks: not_https, query_or_fragment, userinfo, intercom_host, invalid, undeclared_placeholder.

Example:"https://api.example.com/v1"
authobject

How to send the source's auth_token. Intercom sends this header on every request. If it's left out, the header is Authorization with the value Bearer {token}, unless a query value in the tree request, a child call or the item is exactly {token}. Then no header is sent, and each of those requests must have a query value of {token}; one without it fails missing_token on its query, such as template.item.query. Intercom only sends the token over https to the base_url host. Checks: invalid.

Example:
{ "header": "Authorization", "value": "Bearer {token}" }
treeobjectrequired

The request that lists the knowledge base's pages, and how to read its response. Checks: invalid, and missing_keys when path or nodes is missing.

Example:
{ "path": "/spaces/help-center/pages", "query": { "status": "published" }, "nodes": [ "pages" ], "children": "pages", "folder_if": [ { … } ], "folder_if_has_children": true, "content_if": [ { … } ] }
itemobject

Optional. The request that fetches one page, sent for each node that matches tree.content_if. Leave it out if the tree's nodes hold everything mapping reads: no item is then requested, and every mapping value must read from node. Checks: invalid, and missing_keys when path is missing.

Example:
{ "path": "/spaces/help-center/pages/{page_id}", "node_values": { "page_id": [ … ] } }
mappingobjectrequired

Where to read each page's fields. Each value is a list that starts with node, to read from the tree node, or item, to read from the item response, followed by at least one key or array index. For example, ["item", "body"] reads body from the item response. A value can only start with item if the template has an item. Checks: invalid, missing_keys when id, title or body is missing, and invalid or missing_item on a single field, such as mapping.body.

Example:
{ "id": [ "node", "id" ], "title": [ "node", "title" ], "body": [ "item", "body" ], "updated_at": [ "item", "updatedAt" ] }
body_formatstring

Optional; defaults to html. The format of the page content that mapping.body reads. Markdown is converted to HTML, without a leading YAML front matter block. Unsafe HTML is removed. Checks: unknown.

Enum:"html""markdown""plain_text"
Example:"html"
{ "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" }