ngx-intercom-messenger
Version:
This is an Intercom wrapper for Angular 18+ which supports AoTx
100 lines (99 loc) • 5.11 kB
TypeScript
import { InjectionToken } from '@angular/core';
import type { UserArgs, IntercomSettings } from "@intercom/messenger-js-sdk/types";
import * as i0 from "@angular/core";
export declare const INTERCOM_MESSENGER_SETTINGS: InjectionToken<IntercomSettings>;
/**
* A provider with every Intercom.JS method
*/
export declare class IntercomMessengerService {
private platformId;
private settings;
/**
* If you'd like to control when Intercom is loaded, you can use the 'boot' method.
* This is useful in situations like a one-page Javascript based application where the user may not be logged in
* when the page loads. You call this method with the standard intercomSettings object.
*/
boot(settings?: IntercomSettings): void;
/**
* If you have the Respond product (combined with another product like Engage)
* you should call the Intercom shutdown method to clear your users’ conversations anytime they log out
* of your application. Otherwise, the cookie we use to track who was most recently logged in on a given device
* or computer will keep these conversations in the Messenger for one week.
* This method will effectively clear out any user data that you have been passing through the JS API.
*/
shutdown(): void;
/**
* Calling the update method without any other arguments will trigger the JavaScript to look for new messages
* that should be displayed to the current user (the one whose details are in the window.intercomSettings variable)
* and show them if they exist.
*
* Calling the update method with a JSON object of user details will update those fields on the current user
* in addition to logging an impression at the current URL and looking for new messages for the user.
*/
update(data: UserArgs): void;
/**
* This will hide the main Messenger panel if it is open. It will not hide the Messenger Launcher.
*/
hide(): void;
/**
* This will show the Messenger. If there are no conversations it will open with the new message view,
* if there are it will open with the message list.
*
* If a `message` parameter is supplied, it will automatically open a new message window, aliasing showNewMessage().
*
*/
show(message?: string): void;
/**
* To open the message window with the message list you can call `showMessages()`.
*/
showMessages(): void;
/**
* To open the message window with the new message view you can call showNewMessage().
*
* This function takes an optional parameter that can be used to pre-populate the message composer as shown below.
*/
showNewMessage(message?: string): void;
/**
* You can submit an event using the trackEvent method.
* This will associate the event with the currently logged-in user and send it to Intercom.
* The final parameter is a map that can be used to send optional metadata about the event.
*
* You can also add custom information to events in the form of event metadata.
*/
trackEvent(eventName: string, metadata?: Record<string, number | string | boolean>): void;
/**
* A visitor is someone who goes to your site but does not use the messenger.
* You can track these visitors via the visitor user_id.
* This user_id can be used to retrieve the visitor or lead through the REST API.
*/
getVisitorId(): string;
/**
* Gives you the ability to hook into the show event. Requires a function argument.
*/
onShow(handler: () => void): void;
/**
* Gives you the ability to hook into the hide event. Requires a function argument.
*/
onHide(handler: () => void): void;
/**
* This method allows you to register a function that will be called when the current number of unread messages changes.
*/
onUnreadCountChange(handler: (unreadCount?: number) => void): void;
/**
* If you would like to trigger a tour based on an action a user or visitor takes in your site or application,
* ou can use this API method. You need to call this method with the id of the tour you wish to show. The id of
* the tour can be found in the “Use tour everywhere” section of the tour editor.
*
* Please note that tours shown via this API must be published and the “Use tour everywhere” section must be
* turned on. If you're calling this API using an invalid tour id, nothing will happen.
*/
startTour(tourId: string): void;
/**
* If you would like to trigger an article in the Messenger, you can use the showArticle method.
* The article will be shown within the Messenger, and clicking the Messenger back button will return to the previous context.
* If the Messenger is closed when the method is called, it will be opened first and then the article will be shown.
*/
showArticle(articleId: string): void;
static ɵfac: i0.ɵɵFactoryDeclaration<IntercomMessengerService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<IntercomMessengerService>;
}