Contacts (users and leads): create, read, update, list and search with starting_after paging, find by email or external id, contact notes, and company attachment.
Context Vars
intercom.tokenintercom.admin.id
Functions
attach-company
fn (contact-id: Str, company-id: Str): Any
fn (contact-id: Str, company-id: Str, opts: Map): Any
POST /contacts/{id}/companies - Attach a contact to a company by the
company's Intercom id (not your company_id).
Example
::intercom::contacts/attach-company("6643703ffae7834d1792fd30", "66f1a2b3c4d5e6f708192a3b")
build-note-body
fn (body: Str, admin-id: Str?): Map
Contact note body: {body, admin_id?}. A null admin id is omitted
(Intercom then attributes the note to the token's admin). Exposed for
testing.
Example
::intercom::contacts/build-note-body("Called about renewal.", "814860") // {body: "Called about renewal.", admin_id: "814860"}
::intercom::contacts/build-note-body("Called about renewal.", null) // {body: "Called about renewal."}
create-contact
fn (fields: Map): Any
fn (fields: Map, opts: Map): Any
POST /contacts - Create a contact. fields: email, external_id,
name, phone, role ("user" by default, or "lead"), owner_id,
signed_up_at, custom_attributes (attributes must already exist).
Unset fields are omitted.
Example
contact ::intercom::contacts/create-contact({
email: "ada@example.com",
name: "Ada Lovelace",
external_id: "user-42"
})
contact.id
create-note
fn (contact-id: Str, body: Str): Any
fn (contact-id: Str, body: Str, opts: Map): Any
fn (contact-id: Str, body: Str, admin-id: Str?): Any
fn (contact-id: Str, body: Str, admin-id: Str?, opts: Map): Any
POST /contacts/{id}/notes - Add a note to a contact's profile (HTML
allowed), authored by admin-id in opts or intercom.admin.id when
set, or by an explicit admin id.
Example
::intercom::contacts/create-note("6643703ffae7834d1792fd30", "Asked for a <b>renewal quote</b>.")
// As one admin, for this call
::intercom::contacts/create-note("6643703ffae7834d1792fd30", "Renewal signed.", {admin-id: "814860"})
intercom.admin.id
detach-company
fn (contact-id: Str, company-id: Str): Any
fn (contact-id: Str, company-id: Str, opts: Map): Any
DELETE /contacts/{id}/companies/{company_id} - Detach a contact from a company (Intercom ids).
Example
::intercom::contacts/detach-company("6643703ffae7834d1792fd30", "66f1a2b3c4d5e6f708192a3b")
find-contact-by-email
fn (email: Str): Any
fn (email: Str, opts: Map): Any
POST /contacts/search by exact email. Returns the first matching contact, or null.
Example
contact ::intercom::contacts/find-contact-by-email("ada@example.com")
if(is-null(contact), "not found", contact.id)
find-contact-by-external-id
fn (external-id: Str): Any
fn (external-id: Str, opts: Map): Any
GET /contacts/find_by_external_id/{external_id} - The contact with your
external_id, or an Err with status 404.
Example
contact ::intercom::contacts/find-contact-by-external-id("user-42")
contact.id
get-contact
fn (id: Str): Any
fn (id: Str, opts: Map): Any
GET /contacts/{id} - One contact by Intercom id.
Example
contact ::intercom::contacts/get-contact("6643703ffae7834d1792fd30")
contact.email
list-companies
fn (contact-id: Str): Any
fn (contact-id: Str, opts: Map): Any
GET /contacts/{id}/companies - The companies a contact belongs to.
Example
companies ::intercom::contacts/list-companies("6643703ffae7834d1792fd30")
map(companies.data, %.name)
list-contacts
fn (): Any
fn (options: Map): Any
fn (options: Map, opts: Map): Any
GET /contacts - One page of contacts: {data, pages, total_count}.
options: per_page (default 10, max 150), starting_after.
Example
page ::intercom::contacts/list-contacts({per_page: 50})
length(page.data)
// The next page
more ::intercom::contacts/list-contacts({per_page: 50, starting_after: ::intercom::api/next-cursor(page)})
list-notes
fn (contact-id: Str): Any
fn (contact-id: Str, options: Map): Any
fn (contact-id: Str, options: Map, opts: Map): Any
GET /contacts/{id}/notes - A contact's notes, newest first: {data, pages, total_count}. options: page, per_page, order
("asc"/"desc").
Example
notes ::intercom::contacts/list-notes("6643703ffae7834d1792fd30", {per_page: 20, order: "desc"})
map(notes.data, %.body)
search-all-contacts
fn (query: Map, limit: Int): Vec
fn (query: Map, limit: Int, opts: Map): Vec
Run search-contacts across pages until limit contacts or the last
page. Returns a Vec.
Example
contacts ::intercom::contacts/search-all-contacts({field: "custom_attributes.plan", operator: "=", value: "enterprise"}, 500)
length(contacts)
search-contacts
fn (query: Map): Any
fn (query: Map, options: Map): Any
fn (query: Map, options: Map, opts: Map): Any
POST /contacts/search - One page of contacts matching a query
({field, operator, value} or an AND/OR combinator). options:
per_page, starting_after, sort ({field, order}). Returns
{data, pages, total_count}.
Example
page ::intercom::contacts/search-contacts({field: "custom_attributes.plan", operator: "=", value: "enterprise"}, {per_page: 50})
update-contact
fn (id: Str, fields: Map): Any
fn (id: Str, fields: Map, opts: Map): Any
PUT /contacts/{id} - Update a contact's fields (same names as create). Unset fields are omitted.
Example
::intercom::contacts/update-contact("6643703ffae7834d1792fd30", {
name: "Ada King",
custom_attributes: {plan: "enterprise"}
})