Skip to content

Commit 6b4b587

Browse files
committed
Add startChecklist method
1 parent 5a0fe40 commit 6b4b587

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

packages/react-use-intercom/src/provider.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,15 @@ export const IntercomProvider: React.FC<
209209
[ensureIntercom],
210210
);
211211

212+
const startChecklist = React.useCallback(
213+
(checklistId: number) => {
214+
ensureIntercom('startChecklist', () => {
215+
IntercomAPI('startChecklist', checklistId);
216+
});
217+
},
218+
[ensureIntercom],
219+
);
220+
212221
const trackEvent = React.useCallback(
213222
(event: string, metaData?: object) => {
214223
ensureIntercom('trackEvent', () => {
@@ -260,6 +269,7 @@ export const IntercomProvider: React.FC<
260269
showNewMessage,
261270
getVisitorId,
262271
startTour,
272+
startChecklist,
263273
trackEvent,
264274
showArticle,
265275
startSurvey,
@@ -277,6 +287,7 @@ export const IntercomProvider: React.FC<
277287
showNewMessage,
278288
getVisitorId,
279289
startTour,
290+
startChecklist,
280291
trackEvent,
281292
showArticle,
282293
startSurvey,

packages/react-use-intercom/src/types.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ export type IntercomMethod =
244244
| 'trackEvent'
245245
| 'getVisitorId'
246246
| 'startTour'
247+
| 'startChecklist'
247248
| 'showArticle'
248249
| 'showSpace';
249250

@@ -365,9 +366,22 @@ export type IntercomContextValues = {
365366
* the “Use tour everywhere” section must be turned on.
366367
* If you're calling this API using an invalid tour id, nothing will happen.
367368
*
368-
* @see {@link https://developers.intercom.com/installing-intercom/docs/intercom-javascript#section-intercomstarttour-tourid}
369+
* @see {@link https://developers.intercom.com/installing-intercom/docs/intercom-javascript#intercomstarttour-tourid}
369370
*/
370371
startTour: (tourId: number) => void;
372+
/**
373+
* Triggers a checklist based on an action a user or visitor takes in your site or application,
374+
* You need to call this method with the id of the checklist you wish to show.
375+
*
376+
* The id of the checklist can be found in the “Aditional ways to share your checklist” section
377+
* of the tour editor.
378+
*
379+
* @remarks Please note that checklists shown via this API must be published.
380+
* If you're calling this API using an invalid tour id, nothing will happen.
381+
*
382+
* @see {@link https://developers.intercom.com/installing-intercom/web/methods/#intercomstartchecklist-checklistid}
383+
*/
384+
startChecklist: (checklistId: number) => void;
371385
/**
372386
* Submits an event, this will associate the event with the currently
373387
* tracked visitor, lead or user and send it to Intercom

0 commit comments

Comments
 (0)