From 19aa20078385e28da029d39db662927f39e63cd8 Mon Sep 17 00:00:00 2001 From: Shane DeWael Date: Tue, 15 Sep 2020 11:59:28 -0700 Subject: [PATCH] Add documentation for publishing to home tab' --- docs/_basic/authenticating_oauth.md | 2 +- docs/_basic/listening_responding_options.md | 2 +- docs/_basic/publishing_views.md | 50 +++++++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 docs/_basic/publishing_views.md diff --git a/docs/_basic/authenticating_oauth.md b/docs/_basic/authenticating_oauth.md index b01b261b0..777a1c109 100644 --- a/docs/_basic/authenticating_oauth.md +++ b/docs/_basic/authenticating_oauth.md @@ -2,7 +2,7 @@ title: Authenticating with OAuth lang: en slug: authenticating-oauth -order: 14 +order: 15 ---
diff --git a/docs/_basic/listening_responding_options.md b/docs/_basic/listening_responding_options.md index efd7d49d2..31c80d8a8 100644 --- a/docs/_basic/listening_responding_options.md +++ b/docs/_basic/listening_responding_options.md @@ -2,7 +2,7 @@ title: Listening and responding to options lang: en slug: options -order: 13 +order: 14 ---
diff --git a/docs/_basic/publishing_views.md b/docs/_basic/publishing_views.md new file mode 100644 index 000000000..fab686129 --- /dev/null +++ b/docs/_basic/publishing_views.md @@ -0,0 +1,50 @@ +--- +title: Publishing views to App Home +lang: en +slug: publishing-views +order: 13 +--- + +
+Home tabs are customizable surfaces accessible via the sidebar and search that allow apps to display views on a per-user basis. After enabling App Home within your app configuration, home tabs can be published and updated by passing a `user_id` and view payload to the `views.publish` method. + +You can subscribe to the `app_home_opened` event to listen for when users open your App Home. +
+ +```javascript +// Listen for users opening your App Home +app.event('app_home_opened', async ({ event, client }) => { + try { + // Call views.publish with the built-in client + const result = await client.views.publish({ + // Use the user ID associated with the event + user_id: event.user, + view: { + // Home tabs must be enabled in your app configuration page under "App Home" + "type": "home", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Welcome home, <@" + event.user + "> :house:*" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "Learn how home tabs can be more useful and interactive ." + } + } + ] + } + }); + + console.log(result); + } + catch (error) { + console.error(error); + } +}); +```