Skip to content

Commit

Permalink
Fix slackapi#632 Add Japanese version of PR slackapi#626 (App Home do…
Browse files Browse the repository at this point in the history
…cument)
  • Loading branch information
seratch committed Mar 24, 2021
1 parent 02970e1 commit 8d05fbd
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/_basic/ja_authenticating_oauth.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: OAuth フローの実装
lang: ja-jp
slug: authenticating-oauth
order: 14
order: 15
---

<div class="section-content">
Expand Down
2 changes: 1 addition & 1 deletion docs/_basic/ja_listening_responding_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: オプションのリスニングと応答
lang: ja-jp
slug: options
order: 13
order: 14
---

<div class="section-content">
Expand Down
50 changes: 50 additions & 0 deletions docs/_basic/ja_publishing_views.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: ホームタブの更新
lang: ja-jp
slug: publishing-views
order: 13
---

<div class="section-content">
<a href="https://api.slack.com/surfaces/tabs/using">ホームタブ</a>は、サイドバーや検索画面からアクセス可能なサーフェスエリアです。アプリはこのエリアを使ってユーザーごとのビューを表示することができます。アプリ設定ページで App Home の機能を有効にすると、<a href="https://api.slack.com/methods/views.publish">`views.publish`</a> API メソッドの呼び出しで `user_id` と<a href="https://api.slack.com/reference/block-kit/views">ビューのペイロード</a>を指定して、ホームタブを公開・更新することができるようになります。

エンドユーザーが App Home(ホームタブやアプリとの DM など)にアクセスしたことを知るために、<a href="https://api.slack.com/events/app_home_opened">`app_home_opened`</a> イベントをサブスクライブすることができます。
</div>

```javascript
// ユーザーが App Home にアクセスしたことを伝えるイベントをリッスン
app.event('app_home_opened', async ({ event, client }) => {
try {
// 組み込みの API クライアントを使って views.publish を呼び出す
const result = await client.views.publish({
// イベントに紐づけられたユーザー ID を指定
user_id: event.user,
view: {
// ホームタブはあらかじめアプリ設定ページで有効にしておく必要があります
"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 <https://api.slack.com/surfaces/tabs/using|*in the documentation*>."
}
}
]
}
});

console.log(result);
}
catch (error) {
console.error(error);
}
});
```

0 comments on commit 8d05fbd

Please sign in to comment.