Skip to main content

Actions

This reference covers all operations exposed by the ballerinax/intercom connector. All operations are available on the intercom:Client.

Initialize the client

import ballerinax/intercom;

configurable string token = ?;

intercom:ConnectionConfig config = {auth: {token}};
intercom:Client intercomClient = check new (config);

Admins

Identify the current admin

Returns the admin corresponding to the access token in use.

intercom:AdminWithApp me = check intercomClient->/me;

Returns: AdminWithApp|error


List all admins

Returns a list of all admins in the workspace.

intercom:AdminList admins = check intercomClient->/admins;

Returns: AdminList|error


Retrieve an admin

intercom:Admin admin = check intercomClient->/admins/[adminId];
ParameterTypeDescription
adminIdintThe unique identifier of the admin

Returns: Admin|error


Set away status

intercom:Admin admin = check intercomClient->/admins/[adminId]/away.put({
awayModeEnabled: true,
awayModeReassign: false
});
ParameterTypeDescription
adminIdintThe unique identifier of the admin
payloadAdminIdAwayBodyAway mode settings

Returns: Admin|error


Articles

List all articles

intercom:ArticleList articles = check intercomClient->/articles;

Returns: ArticleList|error


Create an article

intercom:Article article = check intercomClient->/articles.post({
title: "Getting Started",
body: "<p>Welcome to our Help Center.</p>",
authorId: 123456,
state: "published"
});
FieldTypeRequiredDescription
titlestringYesThe title of the article
bodystringNoHTML body of the article
authorIdintYesID of the admin authoring the article
state"draft"|"published"NoPublication state (default: "draft")
parentIdintNoID of the parent collection

Returns: Article|error


Retrieve an article

intercom:Article article = check intercomClient->/articles/[articleId];
ParameterTypeDescription
articleIdintThe unique identifier of the article

Returns: Article|error


Update an article

intercom:Article article = check intercomClient->/articles/[articleId].put({
title: "Updated Title",
body: "<p>Updated content.</p>",
state: "published"
});
ParameterTypeDescription
articleIdintThe unique identifier of the article
payloadUpdateArticleRequestFields to update

Returns: Article|error


Delete an article

intercom:DeletedArticleObject result = check intercomClient->/articles/[articleId].delete();
ParameterTypeDescription
articleIdintThe unique identifier of the article

Returns: DeletedArticleObject|error


Search articles

intercom:ArticleSearchResponse results = check intercomClient->/articles/search(phrase = "getting started");
Query parameterTypeDescription
phrasestringThe phrase to search for
statestringFilter by state: "draft" or "published"

Returns: ArticleSearchResponse|error


Companies

List companies

intercom:CompanyList companies = check intercomClient->/companies;

Returns: CompanyList|error


Create or update a company

If a company with the given companyId already exists, it is updated; otherwise a new company is created.

intercom:Company company = check intercomClient->/companies.post({
companyId: "acme-corp",
name: "Acme Corp",
plan: "Enterprise"
});
FieldTypeRequiredDescription
companyIdstringNoYour internal company identifier
namestringNoCompany display name
planstringNoThe plan the company is on
monthlySpendintNoMonthly revenue from the company
sizeintNoNumber of employees

Returns: Company|error


Retrieve a company

intercom:Company company = check intercomClient->/companies/[companyId];
ParameterTypeDescription
companyIdstringThe unique identifier of the company

Returns: Company|error


Update a company

intercom:Company company = check intercomClient->/companies/[companyId].put({
name: "Acme Corporation"
});

Returns: Company|error


Delete a company

intercom:DeletedCompanyObject result = check intercomClient->/companies/[companyId].delete();

Returns: DeletedCompanyObject|error


List all companies (paginated)

Use the POST endpoint for pagination with a cursor.

intercom:CompanyList companies = check intercomClient->/companies/list.post();

Returns: CompanyList|error


Contacts

List contacts

intercom:ContactList contacts = check intercomClient->/contacts;

Returns: ContactList|error


Create a contact

intercom:ContactWithPush contact = check intercomClient->/contacts.post({
email: "[email protected]",
name: "Alice Smith",
role: "user"
});
FieldTypeRequiredDescription
emailstringNoContact email address
namestringNoFull name
rolestringNo"user" or "lead"
externalIdstringNoYour system's identifier for this contact
phonestringNoPhone number in E.164 format

Returns: ContactWithPush|error


Retrieve a contact

intercom:ContactWithPush contact = check intercomClient->/contacts/[contactId];
ParameterTypeDescription
contactIdstringThe Intercom-assigned contact ID

Returns: ContactWithPush|error


Update a contact

intercom:ContactWithPush contact = check intercomClient->/contacts/[contactId].put({
name: "Alice Johnson",
email: "[email protected]"
});

Returns: ContactWithPush|error


Delete a contact

intercom:ContactDeleted result = check intercomClient->/contacts/[contactId].delete();

Returns: ContactDeleted|error


Search contacts

intercom:ContactList results = check intercomClient->/contacts/search.post({
query: <intercom:MultipleFilterSearchRequest>{
operator: "AND",
value: [
<intercom:SingleFilterSearchRequest>{
'field: "email",
operator: "=",
value: "[email protected]"
}
]
}
});

Available operators: =, !=, IN, NIN, <, >, ~, !~, ^, $

Returns: ContactList|error


Archive a contact

intercom:ContactArchived result = check intercomClient->/contacts/[contactId]/archive.post();

Returns: ContactArchived|error


Merge contacts

Merges a lead into a user contact.

intercom:ContactWithPush merged = check intercomClient->/contacts/merge.post({
'from: "lead_contact_id",
into: "user_contact_id"
});

Returns: ContactWithPush|error


Conversations

List conversations

intercom:ConversationList conversations = check intercomClient->/conversations;

Returns: ConversationList|error


Create a conversation

Starts a new outbound conversation from a contact.

intercom:ConversationMessage message = check intercomClient->/conversations.post({
body: "Hi, I need help with my account.",
'from: {
'type: "user",
id: "contact_id_here"
}
});
FieldTypeRequiredDescription
bodystringYesThe message body
'fromCreateConversationRequestFromYesThe contact initiating the conversation
'from.'type"lead"|"user"|"contact"YesContact role
'from.idstringYesIntercom contact ID

Returns: ConversationMessage|error


Retrieve a conversation

intercom:Conversation conv = check intercomClient->/conversations/[conversationId];
ParameterTypeDescription
conversationIdintThe unique identifier of the conversation

Returns: Conversation|error


Update a conversation

intercom:Conversation conv = check intercomClient->/conversations/[conversationId].put({
read: true,
customAttributes: {"priority": "high"}
});

Returns: Conversation|error


Delete a conversation

intercom:ConversationDeleted result = check intercomClient->/conversations/[conversationId].delete();

Returns: ConversationDeleted|error


Reply to a conversation

Reply as an admin:

intercom:Conversation conv = check intercomClient->/conversations/[conversationId.toString()]/reply.post(
<intercom:AdminReplyConversationRequest>{
adminId: "admin_id_here",
messageType: "comment",
'type: "admin",
body: "Thanks for reaching out! Let me look into this."
}
);
FieldTypeRequiredDescription
adminIdstringYesID of the admin replying
messageType"comment"|"note"|"quick_reply"YesType of reply
'type"admin"YesMust be "admin"
bodystringNoThe reply text (required for comment/note)

Returns: Conversation|error


Search conversations

intercom:ConversationList results = check intercomClient->/conversations/search.post({
query: <intercom:MultipleFilterSearchRequest>{
operator: "AND",
value: [
<intercom:SingleFilterSearchRequest>{
'field: "state",
operator: "=",
value: "open"
}
]
}
});

Returns: ConversationList|error


Tags

List all tags

intercom:TagList tags = check intercomClient->/tags;

Returns: TagList|error


Create or update a tag

intercom:TagBasic tag = check intercomClient->/tags.post({
name: "vip-customer"
});
FieldTypeRequiredDescription
namestringYesTag name (created if it does not exist)
idstringNoTag ID (provide to update an existing tag)

Returns: TagBasic|error


Tickets

Create a ticket

intercom:Ticket ticket = check intercomClient->/tickets.post({
ticketTypeId: "3036551",
contacts: [{id: "contact_id_here"}]
});
FieldTypeRequiredDescription
ticketTypeIdstringYesID of the ticket type (see Setup guide)
contactsCreateTicketRequestContacts[]YesContacts associated with the ticket
companyIdstringNoCompany to associate with the ticket

Returns: Ticket|error


Retrieve a ticket

intercom:Ticket ticket = check intercomClient->/tickets/[ticketId];
ParameterTypeDescription
ticketIdstringThe unique identifier of the ticket

Returns: Ticket|error


Update a ticket

intercom:Ticket ticket = check intercomClient->/tickets/[ticketId].put({
open: false,
ticketStateId: "resolved_state_id"
});

Returns: Ticket|error


Delete a ticket

intercom:TicketDeleted result = check intercomClient->/tickets/[ticketId].delete();

Returns: TicketDeleted|error


Reply to a ticket

intercom:TicketReply reply = check intercomClient->/tickets/[ticketId]/reply.post(
<intercom:AdminReplyTicketRequest>{
adminId: "admin_id_here",
messageType: "comment",
'type: "admin",
body: "We are looking into your ticket."
}
);
FieldTypeRequiredDescription
adminIdstringYesID of the admin replying
messageType"comment"|"note"|"quick_reply"YesType of reply
'type"admin"YesMust be "admin"
bodystringNoThe reply text

Returns: TicketReply|error


Search tickets

intercom:TicketList results = check intercomClient->/tickets/search.post({
query: <intercom:MultipleFilterSearchRequest>{
operator: "AND",
value: [
<intercom:SingleFilterSearchRequest>{
'field: "open",
operator: "=",
value: "true"
}
]
}
});

Returns: TicketList|error


Search query reference

All search operations (/contacts/search, /conversations/search, /tickets/search) use the same SearchRequest structure.

Simple (single-field) query

intercom:SearchRequest payload = {
query: <intercom:SingleFilterSearchRequest>{
'field: "email",
operator: "=",
value: "[email protected]"
}
};

Composite (multi-field) query

intercom:SearchRequest payload = {
query: <intercom:MultipleFilterSearchRequest>{
operator: "AND", // "AND" or "OR"
value: [
<intercom:SingleFilterSearchRequest>{'field: "role", operator: "=", value: "user"},
<intercom:SingleFilterSearchRequest>{'field: "email", operator: "~", value: "example.com"}
]
}
};

Supported operators

OperatorMeaning
=Equals
!=Not equals
INIn a list of values
NINNot in a list of values
<Less than
>Greater than
~Contains
!~Does not contain
^Starts with
$Ends with

Error handling

All client operations return T|error. Use check to propagate errors or handle them explicitly:

import ballerina/log;

intercom:ContactWithPush|error result = intercomClient->/contacts.post(payload);
if result is error {
log:printError("Failed to create contact", result);
} else {
log:printInfo("Created contact: " + (result.id ?: ""));
}

HTTP errors (4xx/5xx) are returned as http:ApplicationResponseError and include the status code and response body.

What's next