slack-link-surfer
v1.3.0
Published
Easily scrape links from a Slack channel
Downloads
4
Maintainers
Readme
Slack Link Surfer🏄🏾
Easily scrape links from a Slack channel
Great for sending out newsletters, generating "You may have missed.." posts, and much more!
Overview
A minimal-dependency, promise-based library.
This application makes use of Slack's conversation.history
API to provide single channel link-scraping.
Additionally, there are a few configurable options that aim to give greater flexibility into how far you'd like to search for your messages.
Installation
If using npm
$ npm install slack-link-surfer
Alternately if using yarn
$ yarn add slack-link-surfer
Usage
import fetchSlackLinks from "slack-link-surfer";
const myConfig = {
token: mySlackUserToken,
channel: aSlackChannel,
week: true
// or day:true or custom: ${seconds}
};
fetchSlackLinks(myConfig).then(links => {
//do stuff with the goods!
});
//If using with NodeJS/commonJS:
const fetchSlackLinks = require("slack-link-surfer").default;
Configuration Options
| Config Key | Default Value | Required | | ---------- | ------------- | -------- | | token | "" | YES | | channel | "" | YES | | day | false | NO* | | week | false | NO* | | custom | false | NO* | | exclude | [String] | NO |
Note that one timeframe must be present
{token, channel, week:true}
excluded strings are based on the
service_name
key returned from the API
Obtaining A Token and Channel ID
Note that Slack has many different types of tokens. A user token is needed for this application. A user token is essentially a placeholder for an actual user. This means any channels one can normally access in the app, a user token can be used to do the same.
Simply head HERE and in the Legacy Token Generator section, create a new user token (it should start with xoxp
).
Obtaining the channel you'd wish to scrape is even easier. Simply visit your channel in a browser, and the URL will contain the channel ID.
Limitations
Because this application looks for .attachments
within a message object--which is where Slack puts the links, links that don't unfurl (expand) aren't currently displayed. In most cases, this in a non issue, however something to be mindful of.
This application only support single-link messages. This means if a user posts a slack message with several links, only the first link will be captured.