@foodello/intercom
Capacitor plugin for Intercom β iOS, Android, and Web with a unified API
This version is for Capacitor > v8. If you are looking for plugin for another Capacitor versions use:
@foodello/intercom@^4.2.2for v4@foodello/intercom@^5.0.0for v5@foodello/intercom@^6.0.0for v6@foodello/intercom@^7.0.0for v7@foodello/intercom@^8.0.0for v8
Original work based on the @capacitor-community/intercom. So, we want to thank and acknowledge all the contributors and authors of their hard work in @capacitor-community/intercom. We needed unified API with all Capacitor.js supported platforms (Android, iOS, and Web), so we decided to serve the these capabilities with this seperate Capacitor.js plugin.
This plugin is built for the Capacitor v4 upwards.
- Unified API across iOS, Android, and Web β write your Intercom integration once and run it on all three platforms with the same method calls
- Full Intercom Messenger β display the messenger, help center, news, tickets, and all Intercom spaces
- User authentication β identified and unidentified user login, HMAC identity verification, and JWT authentication
- Rich content β present articles, surveys, conversations, carousels, checklists, tours, tickets, and news items
- Push notifications β register tokens, receive and process Intercom push messages on iOS and Android
- Event tracking β log custom events with metadata for Intercom campaigns and automation
- User management β update user attributes, custom attributes, and company data
- Unread conversations β listen for real-time unread count changes across all platforms
- Messenger lifecycle events β listen for show, hide, new conversation, and email-supplied events
- Capacitor 4, 5, 6, 7, and 8 β maintained across major Capacitor versions
| Platform | SDK | Version |
|---|---|---|
| iOS | Intercom iOS SDK | ~> 17.0 |
| Android | Intercom Android SDK | 17.x |
| Web | @intercom/messenger-js-sdk |
^0.0.18 |
| Method | iOS | Android | Web |
|---|---|---|---|
load() |
β | β | β |
loadWithKeys() |
β | β | β |
loginIdentifiedUser() |
β | β | β |
loginUnidentifiedUser() |
β | β | β |
logout() |
β | β | β |
updateUser() |
β | β | β |
logEvent() |
β | β | β |
present() |
β | β | β |
presentContent() |
β | β | β |
displayMessenger() |
β | β | β |
displayMessageComposer() |
β | β | β |
displayHelpCenter() |
β | β | β |
hideMessenger() |
β | β | β |
displayLauncher() |
β | β | β |
hideLauncher() |
β | β | β |
displayInAppMessages() |
β | β | β |
hideInAppMessages() |
β | β | β |
setUserHash() |
β | β | β |
setUserJwt() |
β | β | β |
isUserLoggedIn() |
β | β | β |
fetchLoggedInUserAttributes() |
β | β | β |
setBottomPadding() |
β | β | β |
setupUnreadConversationListener() |
β | β | β |
removeUnreadConversationListener() |
β | β | β |
getUnreadConversationCount() |
β | β | β |
sendPushTokenToIntercom() |
β | β | β |
receivePush() |
β | β | β |
displayArticle() |
β | β | β |
displayCarousel() |
β | β | β |
Event listeners:
| Event | iOS | Android | Web |
|---|---|---|---|
updateUnreadCount |
β | β | β |
userEmailSupplied |
β | β | β |
messengerWillShow |
β | β | β |
messengerDidShow |
β | β | β |
messengerWillHide |
β | β | β |
messengerDidHide |
β | β | β |
newConversationStarted |
β | β | β |
unreadTicketCountChanged |
β | β | β |
npm install @foodello/intercom
npx cap syncimport { Capacitor } from '@capacitor/core';
import { Intercom } from '@foodello/intercom';iOS and Android initialize automatically from your Capacitor config. Web requires an explicit load() call:
if (!Capacitor.isNativePlatform()) {
await Intercom.load({
app_id: 'your_app_id',
// Optional: regional data hosting
// api_base: 'https://api-iam.eu.intercom.io',
});
}If you need to initialize Intercom at runtime instead of from the Capacitor config (for example, when the app ID comes from a remote config):
await Intercom.loadWithKeys({
appId: 'your_app_id',
iosApiKey: 'ios_sdk-xxx', // required on iOS
androidApiKey: 'android_sdk-xxx', // required on Android
});// Login with user ID, email, or both
await Intercom.loginIdentifiedUser({ userId: '12345' });
await Intercom.loginIdentifiedUser({ email: 'user@example.com' });
await Intercom.loginIdentifiedUser({ userId: '12345', email: 'user@example.com' });
// Login as anonymous visitor
await Intercom.loginUnidentifiedUser();
// Check login status
const { isLoggedIn } = await Intercom.isUserLoggedIn();
// Fetch current user attributes (returns userId, email, name, etc.)
const attrs = await Intercom.fetchLoggedInUserAttributes();
// Logout
await Intercom.logout();If you have Messenger Security enabled, set the user hash or JWT before calling loginIdentifiedUser():
// HMAC-based identity verification
await Intercom.setUserHash({ hmac: 'your_hmac_hash' });
await Intercom.loginIdentifiedUser({ userId: '12345' });
// JWT-based identity verification
await Intercom.setUserJwt({ jwt: 'your_jwt_token' });
await Intercom.loginIdentifiedUser({ userId: '12345' });await Intercom.updateUser({
name: 'John Doe',
email: 'john@example.com',
phone: '+1234567890',
languageOverride: 'en',
customAttributes: {
plan: 'premium',
signup_date: '2025-01-01',
},
company: {
companyId: 'company_123',
name: 'Acme Inc',
plan: 'enterprise',
monthlySpend: 499,
},
});// Open a specific space
import { IntercomSpace } from '@foodello/intercom';
await Intercom.present({ space: IntercomSpace.Home });
await Intercom.present({ space: IntercomSpace.Messages });
await Intercom.present({ space: IntercomSpace.HelpCenter });
await Intercom.present({ space: IntercomSpace.Tickets });
// Web-only spaces
await Intercom.present({ space: IntercomSpace.News });
await Intercom.present({ space: IntercomSpace.Tasks });
// Open with a pre-filled message
await Intercom.displayMessageComposer({ message: 'I need help with...' });
// Show or hide the Messenger
await Intercom.displayMessenger();
await Intercom.hideMessenger();
// Show or hide the launcher button
await Intercom.displayLauncher();
await Intercom.hideLauncher();import { IntercomContent } from '@foodello/intercom';
// Articles (iOS, Android, Web)
await Intercom.presentContent({ contentType: IntercomContent.Article, contentId: '123' });
// Surveys (iOS, Android, Web)
await Intercom.presentContent({ contentType: IntercomContent.Survey, contentId: '456' });
// Conversations (iOS, Android, Web)
await Intercom.presentContent({ contentType: IntercomContent.Conversation, contentId: '789' });
// Tickets (Android, Web)
await Intercom.presentContent({ contentType: IntercomContent.Ticket, contentId: '321' });
// Carousels (iOS, Android)
await Intercom.presentContent({ contentType: IntercomContent.Carousel, contentId: '654' });
// Web-only content types
await Intercom.presentContent({ contentType: IntercomContent.Checklist, contentId: '111' });
await Intercom.presentContent({ contentType: IntercomContent.News, contentId: '222' });
await Intercom.presentContent({ contentType: IntercomContent.Tour, contentId: '333' });// Simple event
await Intercom.logEvent({ name: 'completed_onboarding' });
// Event with metadata
await Intercom.logEvent({
name: 'purchased_item',
data: {
item_name: 'Premium Plan',
price: 49.99,
currency: 'USD',
},
});// Set up the listener first
await Intercom.setupUnreadConversationListener();
// Listen for count changes
Intercom.addListener('updateUnreadCount', ({ unreadCount }) => {
console.log('Unread conversations:', unreadCount);
});
// Get the current count
const { unreadCount } = await Intercom.getUnreadConversationCount();// Messenger visibility (iOS and Web)
Intercom.addListener('messengerDidShow', () => {
console.log('Messenger is now visible');
});
Intercom.addListener('messengerDidHide', () => {
console.log('Messenger was closed');
});
// iOS-only events
Intercom.addListener('messengerWillShow', () => {});
Intercom.addListener('messengerWillHide', () => {});
Intercom.addListener('newConversationStarted', () => {});
Intercom.addListener('unreadTicketCountChanged', () => {});
// Web-only events
Intercom.addListener('userEmailSupplied', () => {
console.log('Visitor entered their email');
});On iOS, Intercom automatically registers for push notifications when the Capacitor push notification delegate fires. On Android, you need to forward the token manually:
import { PushNotifications } from '@capacitor/push-notifications';
// Request permission and register
await PushNotifications.requestPermissions();
await PushNotifications.register();
// Forward token to Intercom (Android only)
PushNotifications.addListener('registration', async ({ value: token }) => {
if (Capacitor.getPlatform() === 'android') {
await Intercom.sendPushTokenToIntercom({ value: token });
}
});
// Handle incoming Intercom push notifications (Android only)
PushNotifications.addListener('pushNotificationReceived', async (notification) => {
if (Capacitor.getPlatform() === 'android') {
await Intercom.receivePush(notification.data);
}
});// Adjust the bottom padding of the Messenger (minimum value: 20)
await Intercom.setBottomPadding({ value: '80' });Web-specific configuration options can be passed to load():
await Intercom.load({
app_id: 'your_app_id',
custom_launcher_selector: '#my-intercom-button',
alignment: 'left', // 'left' or 'right'
vertical_padding: 40,
horizontal_padding: 20,
hide_default_launcher: true, // use your own button with custom_launcher_selector
session_duration: 300000, // 5 minutes in ms
action_color: '#FF5733',
background_color: '#1A1A2E',
});load(...)loadWithKeys(...)registerIdentifiedUser(...)loginIdentifiedUser(...)registerUnidentifiedUser()loginUnidentifiedUser()updateUser(...)logout()logEvent(...)displayMessenger()displayMessageComposer(...)displayHelpCenter()hideMessenger()displayLauncher()hideLauncher()displayInAppMessages()hideInAppMessages()displayCarousel(...)setUserHash(...)setUserJwt(...)isUserLoggedIn()fetchLoggedInUserAttributes()setBottomPadding(...)sendPushTokenToIntercom(...)receivePush(...)displayArticle(...)presentContent(...)present(...)setupUnreadConversationListener()removeUnreadConversationListener()getUnreadConversationCount()addListener('updateUnreadCount', ...)addListener('userEmailSupplied', ...)addListener('messengerWillShow', ...)addListener('messengerDidShow', ...)addListener('messengerWillHide', ...)addListener('messengerDidHide', ...)addListener('newConversationStarted', ...)addListener('unreadTicketCountChanged', ...)- Interfaces
- Type Aliases
- Enums
IntercomPlugin Interface
load(config: IntercomWebConfig) => Promise<void>Load Intercom and set configs on Web environment.
Only available for Web
| Param | Type |
|---|---|
config |
IntercomWebConfig |
Since: 4.2.0
loadWithKeys(options: LoadWithKeysOption) => Promise<void>Load Intercom and set configs on Web environment.
Only available for iOS and Android
| Param | Type |
|---|---|
options |
LoadWithKeysOption |
Since: 4.2.0
registerIdentifiedUser(options: { userId?: string; email?: string; }) => Promise<void>| Param | Type |
|---|---|
options |
{ userId?: string; email?: string; } |
Since: 1.0.0
loginIdentifiedUser(options: { userId?: string; email?: string; }) => Promise<void>Login an identified user with Intercom.
| Param | Type |
|---|---|
options |
{ userId?: string; email?: string; } |
Since: 4.1.0
registerUnidentifiedUser() => Promise<void>Since: 1.0.0
loginUnidentifiedUser() => Promise<void>Login an unidentified user with Intercom.
Since: 4.1.0
updateUser(options: IntercomUserUpdateOptions) => Promise<void>Updates a user's attributes in Intercom.
| Param | Type |
|---|---|
options |
IntercomUserUpdateOptions |
Since: 1.0.0
logout() => Promise<void>Logs the user out of Intercom.
Since: 1.0.0
logEvent(options: { name: string; data?: any; }) => Promise<void>Logs an event with optional metadata in Intercom.
| Param | Type |
|---|---|
options |
{ name: string; data?: any; } |
Since: 1.0.0
displayMessenger() => Promise<void>Since: 1.0.0
displayMessageComposer(options: { message: string; }) => Promise<void>Displays the Intercom Message Composer with an initial message.
| Param | Type |
|---|---|
options |
{ message: string; } |
Since: 1.0.0
displayHelpCenter() => Promise<void>Since: 1.0.0
hideMessenger() => Promise<void>Hides the Intercom Messenger.
Since: 1.0.0
displayLauncher() => Promise<void>Displays the default Intercom Launcher.
Since: 1.0.0
hideLauncher() => Promise<void>Hides the Intercom Launcher.
Since: 1.0.0
displayInAppMessages() => Promise<void>Displays Intercom In-App Messages.
Since: 1.0.0
hideInAppMessages() => Promise<void>Hides Intercom In-App Messages.
Since: 1.0.0
displayCarousel(options: { carouselId: string; }) => Promise<void>| Param | Type |
|---|---|
options |
{ carouselId: string; } |
Since: 1.0.0
setUserHash(options: { hmac: string; }) => Promise<void>Sets the HMAC user hash for Intercom Identity Verification.
| Param | Type |
|---|---|
options |
{ hmac: string; } |
Since: 1.0.0
setUserJwt(options: { jwt: string; }) => Promise<void>Sets a JSON Web Token (JWT) for user authentication in the Messenger.
Must be called before loginIdentifiedUser() or loginUnidentifiedUser().
| Param | Type |
|---|---|
options |
{ jwt: string; } |
Since: 8.0.0
isUserLoggedIn() => Promise<{ isLoggedIn: boolean; }>Returns whether a user is currently logged in to Intercom.
Returns: Promise<{ isLoggedIn: boolean; }>
Since: 8.0.0
fetchLoggedInUserAttributes() => Promise<IntercomUserAttributes | Record<string, string> | undefined>Fetches the attributes of the currently logged-in Intercom user.
Returns: Promise<IntercomUserAttributes | Record<string, string>>
Since: 8.0.0
setBottomPadding(options: { value: string; }) => Promise<void>Sets the bottom padding for the Intercom Messenger.
| Param | Type |
|---|---|
options |
{ value: string; } |
Since: 1.0.0
sendPushTokenToIntercom(options: { value: string; }) => Promise<void>Sends a push token to Intercom.
| Param | Type |
|---|---|
options |
{ value: string; } |
Since: 1.0.0
receivePush(notification: IntercomPushNotificationData) => Promise<void>Processes a received Intercom push notification.
| Param | Type |
|---|---|
notification |
IntercomPushNotificationData |
Since: 1.0.0
displayArticle(options: { articleId: string; }) => Promise<void>| Param | Type |
|---|---|
options |
{ articleId: string; } |
Since: 1.0.0
presentContent(options: { contentType: IntercomContent; contentId: string; }) => Promise<void>Presents an Intercom content item by its type and ID.
| Param | Type |
|---|---|
options |
{ contentType: IntercomContent; contentId: string; } |
Since: 4.1.0
present(options: { space: IntercomSpace; }) => Promise<void>Presents the Intercom's space.
| Param | Type |
|---|---|
options |
{ space: IntercomSpace; } |
Since: 4.1.0
setupUnreadConversationListener() => Promise<void>Setup listener for unread conversation count updates.
Since: 4.1.0
removeUnreadConversationListener() => Promise<void>Remove listener for unread conversation count updates.
Since: 4.1.0
getUnreadConversationCount() => Promise<{ unreadCount: number; }>Get current unread conversation count.
Returns: Promise<{ unreadCount: number; }>
Since: 4.1.0
addListener(eventName: 'updateUnreadCount', listenerFunc: (data: { unreadCount: number; }) => void) => Promise<PluginListenerHandle>Listen for when the unread conversation count is changed.
| Param | Type |
|---|---|
eventName |
'updateUnreadCount' |
listenerFunc |
(data: { unreadCount: number; }) => void |
Returns: Promise<PluginListenerHandle>
Since: 4.1.0
addListener(eventName: 'userEmailSupplied', listenerFunc: () => void) => Promise<PluginListenerHandle>Listen for when a visitor enters their email into the Messenger.
Only available for Web
| Param | Type |
|---|---|
eventName |
'userEmailSupplied' |
listenerFunc |
() => void |
Returns: Promise<PluginListenerHandle>
Since: 7.0.0
addListener(eventName: 'messengerWillShow', listenerFunc: () => void) => Promise<PluginListenerHandle>Listen for when the Messenger is about to be shown.
Only available for iOS
| Param | Type |
|---|---|
eventName |
'messengerWillShow' |
listenerFunc |
() => void |
Returns: Promise<PluginListenerHandle>
Since: 7.0.0
addListener(eventName: 'messengerDidShow', listenerFunc: () => void) => Promise<PluginListenerHandle>Listen for when the Messenger is shown.
Only available for iOS and Web
| Param | Type |
|---|---|
eventName |
'messengerDidShow' |
listenerFunc |
() => void |
Returns: Promise<PluginListenerHandle>
Since: 7.0.0
addListener(eventName: 'messengerWillHide', listenerFunc: () => void) => Promise<PluginListenerHandle>Listen for when the Messenger is about to be hidden.
Only available for iOS
| Param | Type |
|---|---|
eventName |
'messengerWillHide' |
listenerFunc |
() => void |
Returns: Promise<PluginListenerHandle>
Since: 7.0.0
addListener(eventName: 'messengerDidHide', listenerFunc: () => void) => Promise<PluginListenerHandle>Listen for when the Messenger is hidden.
Only available for iOS and Web
| Param | Type |
|---|---|
eventName |
'messengerDidHide' |
listenerFunc |
() => void |
Returns: Promise<PluginListenerHandle>
Since: 7.0.0
addListener(eventName: 'newConversationStarted', listenerFunc: () => void) => Promise<PluginListenerHandle>Listen for when new conversation is started.
Only available for iOS
| Param | Type |
|---|---|
eventName |
'newConversationStarted' |
listenerFunc |
() => void |
Returns: Promise<PluginListenerHandle>
Since: 7.0.0
addListener(eventName: 'unreadTicketCountChanged', listenerFunc: () => void) => Promise<PluginListenerHandle>Listen for when unread ticket count changes.
Only available for iOS
| Param | Type |
|---|---|
eventName |
'unreadTicketCountChanged' |
listenerFunc |
() => void |
Returns: Promise<PluginListenerHandle>
Since: 7.0.0
IntercomWebConfig Interface
Represent configs that are available on Intercom Web SDK.
| Prop | Type | Description | Default | Since |
|---|---|---|---|---|
app_id |
string |
Configure Intercom Web APP ID. The APP ID of your Intercom app which will indicate where to store any data. Only available for Web | 4.2.0 | |
api_base |
IntercomRegionalApiBase |
Configure Intercom's regional API baseurl. For customers who are using Regional Data Hosting for Intercom, there is an additional parameter to set, to ensure your Messenger is pointing to your Regional workspace. Only available for Web | 4.2.0 | |
custom_launcher_selector |
string |
Configure Intercom custom launcher selector. The CSS selector of an element to trigger Intercom("show") in order to activate the messenger. To target an element by ID: "#id_of_element". To target elements by class ".classname_of_elements" Only available for Web | 4.2.0 | |
alignment |
IntercomAlignment |
Configure Intercom default launcher alignment. Dictate the alignment of the default launcher icon to be on the left/right. Possible values: "left" or "right" (any other value is treated as right). Only available for Web | "right" |
4.2.0 |
vertical_padding |
number |
Configure Intercom default launcher icon's vertical padding. Move the default launcher icon vertically. Padding from bottom of screen. Minimum value: 20. Does not work on mobile. Only available for Web | 4.2.0 | |
horizontal_padding |
number |
Configure Intercom default launcher icon's horizontal padding. Move the default launcher icon horizontally. Padding from right side of screen Minimum value: 20. Does not work on mobile. Only available for Web | 4.2.0 | |
hide_default_launcher |
boolean |
Configure Intercom default launcher icon's visibility. Hide the default launcher icon. Setting to false will forcefully show the launcher icon. Only available for Web | 4.2.0 | |
session_duration |
number |
Configure Intercom session duration. Time in milliseconds for the Intercom session to be considered active. A value of 5 * 60 * 1000 would set the expiry time to be 5 minutes Only available for Web | 4.2.0 | |
action_color |
string |
Configure action color for Intercom. Used in button links and more to highlight and emphasise. The color string can be any valid CSS Color Name HEX or RGB Only available for Web | 4.2.0 | |
background_color |
string |
Configure background color for Intercom. Used behind your team profile and other attributes. The color string can be any valid CSS Color Name HEX or RGB Only available for Web | 4.2.0 |
LoadWithKeysOption Interface.
Represents options required for dynamic load of native Intercom SDK.
Only available for iOS and Android.
| Prop | Type | Description |
|---|---|---|
appId |
string |
|
iosApiKey |
string |
Required for iOS |
androidApiKey |
string |
Required for Android |
IntercomUserUpdateOptions Interface
Represents the options for updating a user's attributes in Intercom.
Only available for iOS and Android.
| Prop | Type |
|---|---|
userId |
string |
email |
string |
name |
string |
phone |
string |
languageOverride |
string |
customAttributes |
Record<string, any> |
company |
CompanyOption |
companies |
CompanyOption[] |
CompanyOption Interface.
Represents Intercom option to include company details.
| Prop | Type | Description |
|---|---|---|
name |
string |
Required for Web |
companyId |
string |
Required for Native platforms |
createdAt |
number |
Unix timestamp |
monthlySpend |
number |
|
plan |
string |
|
customAttributes |
Record<string, any> |
IntercomUserAttributes Interface
Attributes returned by fetchLoggedInUserAttributes().
Only available for iOS and Android.
| Prop | Type |
|---|---|
userId |
string |
email |
string |
name |
string |
phone |
string |
languageOverride |
string |
customAttributes |
Record<string, any> |
IntercomPushNotificationData Interface
Represents the structure of a received Intercom push notification.
Only available for iOS and Android.
| Prop | Type |
|---|---|
conversation_id |
string |
message |
string |
body |
string |
author_name |
string |
image_url |
string |
app_name |
string |
receiver |
string |
conversation_part_type |
string |
intercom_push_type |
string |
uri |
string |
push_only_conversation_id |
string |
instance_id |
string |
title |
string |
priority |
number |
| Prop | Type |
|---|---|
remove |
() => Promise<void> |
Construct a type with a set of properties K of type T
{
[P in K]: T;
}
| Members | Value |
|---|---|
Us |
'https://api-iam.intercom.io' |
Eu |
'https://api-iam.eu.intercom.io' |
Au |
'https://api-iam.au.intercom.io' |
| Members | Value |
|---|---|
Left |
'left' |
Right |
'right' |
| Members | Value | Description | Since |
|---|---|---|---|
Article |
'article' |
||
Survey |
'survey' |
||
Carousel |
'carousel' |
Only available for iOS and Android | 4.1.0 |
Checklist |
'checklist' |
Only available for Web | 4.2.0 |
News |
'news' |
Only available for Web | 4.2.0 |
Tour |
'tour' |
Only available for Web | 4.2.0 |
Ticket |
'ticket' |
Only available for Web | 7.0.0 |
Conversation |
'conversation' |
7.0.0 |
| Members | Value | Description | Since |
|---|---|---|---|
Home |
'home' |
||
Messages |
'messages' |
||
HelpCenter |
'help' |
||
News |
'news' |
Only available on web. | 4.2.0 |
Tasks |
'tasks' |
Only available on web. | 4.2.0 |
Tickets |
'tickets' |
7.0.0 |
Add your Intercom credentials to capacitor.config.ts (or capacitor.config.json):
{
"plugins": {
"Intercom": {
"iosApiKey": "ios_sdk-xxx",
"iosAppId": "yyy"
}
}
}Then run:
npx cap sync ios
npx cap open iosSign your app in Xcode under the General tab.
Tip: After changing native code, clean the build cache (Product > Clean Build Folder) before running again.
Add your Intercom credentials to capacitor.config.ts (or capacitor.config.json):
{
"plugins": {
"Intercom": {
"androidApiKey": "android_sdk-xxx",
"androidAppId": "yyy"
}
}
}Then run:
npx cap sync android
npx cap open androidTip: After changing native code, clean the build cache (Build > Clean Project) before running again.
No native configuration needed. Call Intercom.load() with your app_id in your application code. See the Usage section above.
MIT
This repository is based on the wonderful work of the official @capacitor-community/intercom -plugin. Here we want to acknowledge the mastermind and sponsors behind that work.
|
|
Intenseloop |
| Maintainer | GitHub | Social |
|---|---|---|
| Stewan Silva | stewones | @stewones |
If you have any ideas what we should include, please open a new issue for it.
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!