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
- Input Type: String
- Description: This setting specifies the ID of the user whose files will be listed. By providing a specific user ID, the output will be limited to files uploaded by that user. If this parameter is not provided, it defaults to the value specified in the configuration.
- Default Value: Depends on the context configuration, with no hard-coded default.
2. tsFrom
- Input Type: String (timestamp)
- Description: This parameter allows the user to specify the start timestamp for the range of files to be retrieved. Files created after this timestamp will be included in the output. Changing this value affects the range of historical files queried.
- Default Value: Depends on the context configuration, with no hard-coded default.
3. tsTo
- Input Type: String (timestamp)
- Description: This setting specifies the end timestamp for the range of files to be retrieved. Files created before this timestamp will be included. Adjusting this parameter helps refine the time range of file retrieval.
- Default Value: Depends on the context configuration, with no hard-coded default.
4. channel
- Input Type: String
- Description: This setting specifies the Slack channel ID from which to list files. If a channel ID is provided, the function will filter files to return only those from that specific channel. If not supplied, the default behavior is to retrieve files from all channels associated with the user.
- Default Value: Depends on the context configuration, with no hard-coded default.
5. limit
- Input Type: Numeric
- Description: This setting controls the maximum number of files to retrieve in a single call. Setting a limit ensures that responses are manageable in size, especially when users may have uploaded numerous files. The default value is set to 30, which can be adjusted based on user needs.
- Default Value: 30
6. page
- Input Type: Numeric
- Description: This parameter determines the page number for pagination of the results. When there are more files than the limit allows, users can specify a page number to navigate through the results. This supports querying files in chunks, making it easier to process large data sets.
- Default Value: 1
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:
- Strings (for
userId,tsFrom,tsTo, andchannel) - Numbers (for
limitandpage)
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:
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.