Node.jsからSlackへのレスポンス際に「あなただけに表示されています」と表示されるのを、どうにかしたい
2955 ワード
はじめに
- Slackのslash commandのリクエストに対して、普通にレスポンスを返すと「あなただけに表示されています」という状態で投稿されます
- 他の人に投稿した内容が見えるようにする方法を簡単にまとめます。
「あなただけに表示されています」を解消する方法
- レスポンス内で
response_type: 'in_channel'
を指定します。
- ちなみに、Slackの公式サイトにも以下のように記載されています。
The response_type parameter in the JSON payload controls this visibility, by default it is set to ephemeral, but you can specify a value of in_channel to post the response into the channel, like this:
{
"response_type": "in_channel",
"text": "It's 80 degrees right now."
}
参考URL : https://api.slack.com/interactivity/slash-commands
- レスポンス内で
response_type: 'in_channel'
を指定します。 - ちなみに、Slackの公式サイトにも以下のように記載されています。
The response_type parameter in the JSON payload controls this visibility, by default it is set to ephemeral, but you can specify a value of in_channel to post the response into the channel, like this:
{
"response_type": "in_channel",
"text": "It's 80 degrees right now."
}
参考URL : https://api.slack.com/interactivity/slash-commands
デフォルトでは、"response_type": "ephemeral"
が設定されていると書いてありますね。
サンプルコード
body
内で、response_type: 'in_channel'
を指定すればOKです。
Node.js
const requestPromise = require('request-promise');
const options = {
url: responseURL, // SlackへのレスポンスURL
headers: {
'Content-type': 'application/json'
},
body: {
response_type: 'in_channel', // ★ ここで in_channelを指定
text: response // Slackへのレスポンス内容
},
json: true
};
res = requestPromise.post(options);
Author And Source
この問題について(Node.jsからSlackへのレスポンス際に「あなただけに表示されています」と表示されるのを、どうにかしたい), 我々は、より多くの情報をここで見つけました https://qiita.com/memomaruRey/items/82f7ea73cb3cfb856925著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .