5 min read

Slack List Files

Purpose

The node is designed to retrieve a list of files from a specified Slack workspace. This can include various file types such as documents, images, and video files associated with a particular user, channel, or timestamp range. The function serves as an integration point between the Vantage analytics platform and Slack, facilitating easy access to files stored in the Slack environment.

Settings

The node has several configurable settings, each of which influences its behavior and the data it retrieves. The settings are as follows:

1. userId

2. tsFrom

3. tsTo

4. channel

5. limit

6. page

How It Works

The node begins by extracting input values from the inputs, config, and context objects. It uses these values to configure a connection to the Slack integration via the integration connection. This allows the function to communicate with the Slack API and retrieve the files according to the specified parameters. It handles error management by catching exceptions thrown during the integration process and returning an appropriate error message if an issue arises. Upon successful file retrieval, the function returns an object containing output1, which holds the list of files.

Expected Data

The function expects the following data types to be provided via inputs or configuration:

Use Cases & Examples

Use Case 1: File Audit for a User

A company needs to audit all files uploaded by a specific employee to ensure compliance with company policies. By utilizing the node with their user ID, the compliance team can filter through files and review their contents efficiently.

Use Case 2: Reporting on Team Activity

A project manager wishes to generate reports on file sharing activity within a Slack channel over a specific time period. By setting appropriate timestamp values, they can analyze trends in file uploads and usage within their team.

Use Case 3: Archiving Documents

An organization may want to archive all files uploaded in a specific channel during a particular timeframe for record-keeping purposes. Using the node, the team can easily extract and store these files in their document management system.

Example Configuration

To solve the second use case regarding reporting on team activity, the configuration for the node might look like this:

javascript
const inputs = {
    userId: 'U12345678', // Slack user ID
    tsFrom: '1633036800', // Start timestamp (e.g., October 1, 2021)
    tsTo: '1635724800',   // End timestamp (e.g., October 31, 2021)
    channel: 'C87654321', // Slack channel ID
    limit: 50,            // Retrieve a maximum of 50 files
    page: 1               // Start with the first page of results
};

const config = {
    userId: 'U12345678',
    tsFrom: '1633036800',
    tsTo: '1635724800',
    channel: 'C87654321',
    limit: 30,          // Default value
    page: 1             // Default value
};

const context = {}; // Additional context as required

listFilesNode({ inputs, config, context })
    .then(response => console.log(response))
    .catch(error => console.error(error));

This configuration will retrieve files uploaded by the specific user in the defined channel between the given timestamps, allowing the project manager to analyze file sharing activity accurately.