Skip to content

Commit a2ae138

Browse files
aaboydclaude
andcommitted
Add hideNotifications method and tickets space support
Add the missing `hideNotifications` JS SDK method and add `tickets` to the `IntercomSpace` type. Update README with docs for both additions and the previously undocumented `showNews` method. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b37a112 commit a2ae138

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

packages/react-use-intercom/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ Used to retrieve all methods bundled with Intercom. These are based on the offic
149149
| showArticle | (articleId: string) => void | opens the Messenger with the specified article by `articleId`
150150
| startSurvey | (surveyId: number) => void | Trigger a survey in the Messenger by `surveyId`
151151
| showSpace | (spaceName: IntercomSpace) => void | Opens the Messenger with the specified space
152+
| showNews | (newsId: number) => void | Opens the Messenger with the specified news item by `newsId`
152153
| showTicket | (ticketId: number) => void | Opens the Messenger with the specified ticket by `ticketId`
153154
| showConversation | (conversationId: number) => void | Opens the Messenger with the specified conversation by `conversationId`
155+
| hideNotifications | (hidden: boolean) => void | Controls the visibility of Intercom notifications
154156

155157
#### Example
156158
```ts
@@ -183,8 +185,10 @@ const HomePage = () => {
183185
showArticle,
184186
startSurvey,
185187
showSpace,
188+
showNews,
186189
showTicket,
187-
showConversation
190+
showConversation,
191+
hideNotifications,
188192
} = useIntercom();
189193

190194
const bootWithProps = () => boot({ name: 'Russo' });
@@ -202,8 +206,10 @@ const HomePage = () => {
202206
const handleShowArticle = () => showArticle(123456);
203207
const handleStartSurvey = () => startSurvey(123456);
204208
const handleShowSpace = () => showSpace('tasks');
209+
const handleShowNews = () => showNews(123);
205210
const handleShowTicket = () => showTicket(123);
206211
const handleShowConversation = () => showConversation(123);
212+
const handleHideNotifications = () => hideNotifications(true);
207213

208214
return (
209215
<>
@@ -230,8 +236,10 @@ const HomePage = () => {
230236
<button onClick={handleShowArticle}>Open article in Messenger</button>
231237
<button onClick={handleStartSurvey}>Start survey in Messenger</button>
232238
<button onClick={handleShowSpace}>Open space in Messenger</button>
239+
<button onClick={handleShowNews}>Open news in Messenger</button>
233240
<button onClick={handleShowTicket}>Open ticket in Messenger</button>
234241
<button onClick={handleShowConversation}>Open conversation in Messenger</button>
242+
<button onClick={handleHideNotifications}>Hide notifications</button>
235243
</>
236244
);
237245
};

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,15 @@ export const IntercomProvider: React.FC<
291291
[ensureIntercom],
292292
);
293293

294+
const hideNotifications = React.useCallback(
295+
(hidden: boolean) => {
296+
ensureIntercom('hideNotifications', () => {
297+
IntercomAPI('hideNotifications', hidden);
298+
});
299+
},
300+
[ensureIntercom],
301+
);
302+
294303
const providerValue = React.useMemo<IntercomContextValues>(() => {
295304
return {
296305
boot,
@@ -312,6 +321,7 @@ export const IntercomProvider: React.FC<
312321
showNews,
313322
showTicket,
314323
showConversation,
324+
hideNotifications,
315325
};
316326
}, [
317327
boot,
@@ -333,6 +343,7 @@ export const IntercomProvider: React.FC<
333343
showNews,
334344
showTicket,
335345
showConversation,
346+
hideNotifications,
336347
]);
337348

338349
return (

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ export type IntercomMethod =
262262
| 'showSpace'
263263
| 'showNews'
264264
| 'showTicket'
265-
| 'showConversation';
265+
| 'showConversation'
266+
| 'hideNotifications';
266267

267268
export type RawIntercomProps = RawMessengerAttributes & RawDataAttributes;
268269

@@ -280,7 +281,7 @@ export type IntercomBootProps = {
280281

281282
export type LogLevel = 'info' | 'error' | 'warn';
282283

283-
export type IntercomSpace = 'home' | 'messages' | 'help' | 'news' | 'tasks';
284+
export type IntercomSpace = 'home' | 'messages' | 'help' | 'news' | 'tasks' | 'tickets';
284285

285286
export type IntercomContextValues = {
286287
/**
@@ -476,6 +477,14 @@ export type IntercomContextValues = {
476477
* @see {@link https://developers.intercom.com/installing-intercom/web/methods/#intercomshowconversation-conversationid}
477478
*/
478479
showConversation: (conversationId: number) => void;
480+
/**
481+
* Controls the visibility of Intercom notifications
482+
*
483+
* @see {@link https://developers.intercom.com/installing-intercom/web/methods/#intercomhidenotifications-hidden}
484+
*
485+
* @param hidden `true` to hide notifications, `false` to show them
486+
*/
487+
hideNotifications: (hidden: boolean) => void;
479488
};
480489

481490
export type IntercomProviderProps = {

0 commit comments

Comments
 (0)