Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
March 28, 2022 10:59 pm GMT

GAS UrlFetchApp Slack API conversations.list

GAS

Image description

getSlackChByName

Slack API Doc

api.slack.com Slack API

https://api.slack.com/messaging/retrieving#finding_conversation


const { WebClient, LogLevel } = require("@slack/web-api");

GAS npm

conversations.list

https://api.slack.com/methods/conversations.list

GET

https://slack.com/api/conversations.list

API

https://qiita.com/seratch/items/2158cb0abed5b8e12809

payload

function callWebApi(token, apiMethod) {  const response = UrlFetchApp.fetch(    `https://www.slack.com/api/${apiMethod}`,    {      method: "post",      contentType: "application/x-www-form-urlencoded",      headers: { "Authorization": `Bearer ${token}` },    }  );  console.log(`Web API (${apiMethod}) response: ${response}`)  return response;}

UrlFetchApp GAS fetch

apiMethod GET/POST Slack API Method
Slack Workspace Slack API Method

const token = "xoxp-1234"const apiResponse = callWebApi(token, "conversations.list");

Slack conversations.list Slack API Method

GAS

Web API (conversations.list) response: {  "ok":true,"channels":[  {"id":"C0385KDLRD5","name":"making-bot",... },  {"id":"C038L782V3M","name":"random",... },  {"id":"C038NHHFN3E","name":"general",...},  "response_metadata":{"next_cursor":""},}

json

Image description

random general, making-bot,

making-bot

"name":"making-bot","is_channel":true,"is_group":false,"is_im":false,"is_mpim":false,"is_private":false,"created":1648155092,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"making-bot","is_shared":false,"is_org_shared":false,"is_pending_ext_shared":false,"pending_shared":[],"parent_conversation":null,"creator":"U038DHKP87Q","is_ext_shared":false,"shared_team_ids":["T038NHHEJJY"],"pending_connected_team_ids":[],"is_member":true,


Slack API
DM

Slack DogAPI Twitter API


Original Link: https://dev.to/kaede_io/gas-no-urlfetchapp-de-slack-api-no-conversationslist-dequan-tenotiyannerurisutowoqu-de-suru-2l2b

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To