### Customizing Slack CLI Installation with Flags Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/installing-the-slack-cli-for-windows.md Demonstrates how to download the installation script locally to apply custom flags such as versioning, aliasing, and Git skipping. This is required when specific configuration parameters are needed during the setup process. ```pwsh # Download the installer locally irm https://downloads.slack-edge.com/slack-cli/install-windows.ps1 -outfile 'install-windows.ps1' # View help documentation .\install-windows.ps1 -? # Run with custom flags .\install-windows.ps1 -Version 2.1.0 -Alias slackcli -SkipGit $true ``` -------------------------------- ### Install PowerShell 7 Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/installing-the-slack-cli-for-windows.md This command installs PowerShell 7 on a machine using the recommended script. It utilizes the `Invoke-Expression` cmdlet to download and execute the installation script from the provided URL, ensuring the MSI installer is used. ```powershell iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI" ``` -------------------------------- ### Verify Slack CLI Installation Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/installing-the-slack-cli-for-windows.md After installing the Slack CLI and ensuring it's in the system's PATH, this command verifies the installation by displaying the installed version of the Slack CLI. It confirms that the CLI is accessible from the command line. ```powershell slack version ``` -------------------------------- ### Manual Slack CLI Installation and Path Configuration (Shell) Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/installing-the-slack-cli-for-mac-and-linux.md Manually installs the Slack CLI by downloading the appropriate binary for macOS or Linux, and then creates a symbolic link to add it to the system's PATH. This method allows for custom path configurations. ```shell ln -s "$HOME/.slack/bin/slack" "$HOME/.local/bin/slack" ``` ```shell $ slack version ``` -------------------------------- ### Automated Slack CLI Installation via PowerShell Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/installing-the-slack-cli-for-windows.md Executes the remote Slack CLI installation script directly in PowerShell. This is the standard method for setting up the Slack CLI on Windows machines. ```pwsh irm https://downloads.slack-edge.com/slack-cli/install-windows.ps1 | iex ``` -------------------------------- ### Initialize Slack project using CLI Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/commands/slack_create.md Examples of using the 'slack create' command to generate new projects. This includes basic creation, AI agent initialization, and template-specific scaffolding. ```bash # Create a new project from a template slack create my-project # Create a new AI Agent app slack create agent my-agent-app # Start a new project from a specific template slack create my-project -t slack-samples/deno-hello-world # Create a project named 'my-project' slack create --name my-project # Create from a subdirectory of a template slack create my-project -t org/monorepo --subdir apps/my-app ``` -------------------------------- ### Define Slack CLI hooks Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/hooks/index.md Examples of configuring hooks in the Slack CLI, including simple hook definitions, overriding default hooks, and a complete SDK-managed configuration. ```json { "hooks": { "get-hooks": "deno run -q --unstable --allow-read --allow-net https://deno.land/x/deno_slack_hooks@0.0.4/mod.ts" } } ``` ```json { "hooks": { "get-hooks": "deno run -q --unstable --allow-read --allow-net https://deno.land/x/deno_slack_hooks@0.0.4/mod.ts", "get-manifest": "deno run -q --unstable --config=deno.jsonc --allow-read --allow-net https://deno.land/x/deno_slack_builder@0.0.8/mod.ts --manifest", "custom-hook": "deno run my-custom-hook.ts" } } ``` ```json { "hooks": { "get-manifest": "deno run -q --unstable --config=deno.jsonc --allow-read --allow-net https://deno.land/x/deno_slack_builder@0.0.8/mod.ts --manifest", "build": "deno run -q --unstable --config=deno.jsonc --allow-read --allow-write --allow-net https://deno.land/x/deno_slack_builder@0.0.8/mod.ts", "start": "deno run -q --unstable --config=deno.jsonc --allow-read --allow-net https://deno.land/x/deno_slack_runtime@0.0.5/local-run.ts" }, "config": { "watch": { "manifest": { "paths": ["manifest.json"] }, "app": { "paths": ["app.js", "listeners/"], "filter-regex": "\\.(ts|js)$" } }, "sdk-managed-connection-enabled": "true" } } ``` -------------------------------- ### Automated Slack CLI Installation (Shell) Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/installing-the-slack-cli-for-mac-and-linux.md Installs the Slack CLI using an automated script downloaded via curl. This method configures the command automatically. It can also accept optional arguments for aliasing or specifying a version. ```shell curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash ``` ```shell curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s ``` ```shell curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s -- -v 2.1.0 ``` ```shell curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s -- -v 2.1.0 ``` -------------------------------- ### Deploy Deno App to Slack Cloud using GitHub Actions (YAML) Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/setting-up-ci-cd-with-the-slack-cli.md This workflow automates the deployment of a Deno application to Slack Cloud. It checks out the repository, installs the Slack CLI, and then uses the 'slack deploy' command with provided secrets to deploy the application. This is intended for already-deployed applications and requires specific secrets to be configured in the GitHub repository. ```yaml # deploy.yml name: Deploy to Slack Cloud on: push: tags: [ '*.*.*' ] jobs: deploy: runs-on: macos-latest steps: - name: Set up repo uses: actions/checkout@v3 - name: Install CLI run: curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash - name: Deploy run: slack deploy --app ${{ secrets.APP }} --workspace ${{ secrets.WORKSPACE }} --token ${{ secrets.SLACK_SERVICE_TOKEN }} ``` -------------------------------- ### Slack CLI Trigger Definition JSON Example Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/hooks/index.md Provides an example of a JSON blob representing a Slack trigger definition, used by the `triggers create` and `triggers update` CLI commands. This structure includes type, name, description, workflow details, and input mappings. ```json { "type": "shortcut", "name": "Submit an issue", "description": "Submit an issue to the channel", "workflow": "#/workflows/submit_issue", "workflow_app_id": "A0168GS8ZFV", "inputs": { "channel": { "value": "{{data.channel_id}}" }, "interactivity": { "value": "{{data.interactivity}}" } } } ``` -------------------------------- ### Define GitHub Actions CI pipeline Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/setting-up-ci-cd-with-the-slack-cli.md The deno.yml workflow file automates the CI process by defining steps for environment setup, code formatting checks, linting, and executing unit tests upon push or pull request events. ```yaml # deno.yml name: Deno app build and testing on: push: branches: [ main ] pull_request: branches: [ main ] jobs: deno: runs-on: ubuntu-latest timeout-minutes: 5 steps: - name: Set up repo uses: actions/checkout@v3 - name: Install Deno uses: denoland/setup-deno@v1 with: deno-version: v1.x - name: Verify formatting run: deno fmt --check - name: Run linter run: deno lint - name: Run tests run: deno task test - name: Run type check run: deno check *.ts && deno check **/*.ts ``` -------------------------------- ### Check and Set PowerShell Language Mode Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/installing-the-slack-cli-for-windows.md This snippet demonstrates how to check the current language mode of a PowerShell session and how to set it to 'FullLanguage' if necessary. 'FullLanguage' mode is required for the Slack CLI installer to function correctly. ```powershell $ExecutionContext.SessionState.LanguageMode $ExecutionContext.SessionState.LanguageMode = "FullLanguage" ``` -------------------------------- ### Query Slack Datastore via CLI Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/commands/slack_datastore_query.md Examples of using the 'slack datastore query' command to fetch data from a specified datastore. These commands demonstrate filtering, pagination using cursors, and limiting results. ```bash # Collect a limited set of items from the datastore slack datastore query --datastore tasks '{"limit": 8}' --output json # Collect items from the datastore starting at a cursor slack datastore query --datastore tasks '{"cursor": "eyJfX2NWaV..."}' # Query the datastore for specific items slack datastore query --datastore tasks '{"expression": "#status = :status", "expression_attributes": {"#status": "status"}, "expression_values": {":status": "In Progress"}}' # Query the datastore for specific items with only an expression slack datastore query '{"datastore": "tasks", "expression": "#status = :status", "expression_attributes": {"#status": "status"}, "expression_values": {":status": "In Progress"}}' ``` -------------------------------- ### Create a Bolt App using Slack CLI Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/using-slack-cli-with-bolt-frameworks.md Initiates the creation of a new Slack app using the Slack CLI. Users are prompted to select an app template, such as 'Starter app', and then choose between Bolt for JavaScript or Bolt for Python. The CLI clones the selected template and installs project dependencies. ```zsh slack create > Starter app - Getting started Slack app Automation app - Custom steps and workflows AI app - Slack agents & assistants View more samples ``` -------------------------------- ### Delete Slack Trigger Example Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/commands/slack_trigger_delete.md Examples demonstrating how to delete a Slack trigger. The first example shows deletion in a selected workspace using only the trigger ID. The second example shows deletion for a specific app by providing both the trigger ID and the app ID. ```bash # Delete a specific trigger in a selected workspace $ slack trigger delete --trigger-id Ft01234ABCD # Delete a specific trigger for an app $ slack trigger delete --trigger-id Ft01234ABCD --app A0123456 ``` -------------------------------- ### Troubleshooting 'command not found' for Slack CLI (Shell) Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/installing-the-slack-cli-for-mac-and-linux.md Adds the Slack CLI to the system's PATH environment variable for bash, fish, and zsh shells to resolve 'command not found' errors after installation. Requires sourcing the shell profile to apply changes. ```shell basename "$SHELL" ``` ```shell echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc source ~/.bashrc ``` ```shell mkdir -p $HOME/.config/fish echo 'fish_add_path $HOME/.local/bin' >> $HOME/.config/fish/config.fish source $HOME/.config/fish/config.fish ``` ```shell echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc source ~/.zshrc ``` -------------------------------- ### Retrieve Datastore Item via Slack CLI Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/commands/slack_datastore_get.md Fetches a single item from a specified datastore using a JSON expression. Supports optional flags for output formatting and experimental feature access. ```bash # Get an item from the datastore slack datastore get --datastore tasks '{"id": "42"}' # Get an item from the datastore with an expression slack datastore get '{"datastore": "tasks", "id": "42"}' ``` -------------------------------- ### Run a Bolt App using Slack CLI Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/using-slack-cli-with-bolt-frameworks.md Executes a Bolt app created with the Slack CLI. After running this command, users will be prompted to select their team/workspace, and the app will then start running. ```zsh slack run ``` -------------------------------- ### Open Environment Variables Dialog Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/installing-the-slack-cli-for-windows.md This command opens the Environment Variables dialog box on Windows, allowing users to add or modify system and user environment variables. This is useful for adding the Slack CLI to the system's PATH. ```powershell rundll32.exe sysdm.cpl,EditEnvironmentVariables ``` -------------------------------- ### GitHub Actions Workflow for Slack App Deployment Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/deploying-with-the-slack-cli-and-github-actions.md This YAML file defines a GitHub Actions workflow that checks out the repository, sets up the Deno runtime, installs the Slack CLI, and deploys the Slack app using a service token stored as a GitHub secret. It triggers on pushes to the main branch and runs on an Ubuntu-hosted runner. ```yaml name: Slack App Deployment on: push: branches: [ main ] jobs: build: runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v4 - name: Install Deno runtime uses: denoland/setup-deno@v1 with: deno-version: v1.x - name: Install Slack CLI if: steps.cache-slack.outputs.cache-hit != 'true' run: | curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash - name: Deploy the app env: SLACK_SERVICE_TOKEN: ${{ secrets.SLACK_SERVICE_TOKEN }} run: | cd gh-actions-demo/ slack deploy -s --token $SLACK_SERVICE_TOKEN ``` -------------------------------- ### List Authorized Slack Accounts (Shell) Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/commands/slack_auth_list.md This snippet demonstrates how to use the `slack auth list` command to display all authorized Slack accounts. It shows the basic command usage and an example of listing accounts. ```shell slack auth list [flags] # Example: $ slack auth list # List all authorized accounts ``` -------------------------------- ### Get Multiple Datastore Items with slack cli Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/commands/slack_datastore_bulk-get.md This command retrieves multiple items from a specified datastore using a JSON expression. It requires the datastore name and a JSON object containing item IDs. The `--datastore` flag can be used to explicitly set the datastore. ```bash slack datastore bulk-get [flags] # Example: Get two items from datastore $ slack datastore bulk-get --datastore tasks '{"ids": ["12", "42"]}' # Example: Get two items from datastore with an expression $ slack datastore bulk-get '{"datastore": "tasks", "ids": ["12", "42"]}' ``` -------------------------------- ### Collect Service Token using slack auth token CLI Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/commands/slack_auth_token.md This command initiates the process of collecting a service token for Slack authentication. It can be used with or without prompts, and supports authentication via tickets and challenge codes for non-interactive logins. Ensure the Slack CLI is installed and configured. ```bash slack auth token ``` ```bash slack auth token --no-prompt ``` ```bash slack auth token --challenge 6d0a31c9 --ticket ISQWLiZT0OtMLO3YWNTJO0... ``` -------------------------------- ### Execute Slack CLI Commands with a Service Token Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/authorizing-the-slack-cli.md Demonstrates how to pass a service token directly to a specific command, such as deployment, to authorize that individual request. ```bash slack deploy --token ``` -------------------------------- ### Configure Deno project settings Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/setting-up-ci-cd-with-the-slack-cli.md The deno.jsonc file defines project-wide settings for the Deno formatter, linter, and custom task scripts. It ensures consistent code quality by centralizing tool configurations. ```json // deno.jsonc { "$schema": "https://deno.land/x/deno/cli/schemas/config-file.v1.json", "fmt": { "files": { "include": [ "README.md", "datastores", "external_auth", "functions", "manifest.ts", "triggers", "types", "views", "workflows" ] } }, "importMap": "import_map.json", "lint": { "files": { "include": [ "datastores", "external_auth", "functions", "manifest.ts", "triggers", "types", "views", "workflows" ] } }, "lock": false, "tasks": { "test": "deno fmt --check && deno lint && deno test --allow-read --allow-none" } } ``` -------------------------------- ### Configure Deno Imports for Slack SDK Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/using-environment-variables-with-the-slack-cli.md This JSON configuration sets up import aliases for the Deno Slack SDK and standard library modules. It's essential for correctly loading dependencies in your Deno project. ```json { "imports": { "deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@a.b.c/", "deno-slack-api/": "https://deno.land/x/deno_slack_api@x.y.z/", "std/": "https://deno.land/std@0.202.0/" } } ``` -------------------------------- ### Authorize Slack CLI with a Service Token Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/authorizing-the-slack-cli.md Uses the global --token flag to authenticate the Slack CLI session. This command verifies the provided token and establishes a connection for subsequent operations. ```bash slack --token ``` -------------------------------- ### Create or replace datastore item using Slack CLI Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/commands/slack_datastore_put.md This command inserts or updates an item in a specified datastore. It supports direct datastore specification via flags or full JSON expressions, with options for experimental features and forced execution. ```shell # Add a new entry to the datastore slack datastore put --datastore tasks '{"item": {"id": "42", "description": "Create a PR", "status": "Done"}}' # Add a new entry to the datastore with an expression slack datastore put '{"datastore": "tasks", "item": {"id": "42", "description": "Create a PR", "status": "Done"}}' ``` -------------------------------- ### Manage Deno dependency versions Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/setting-up-ci-cd-with-the-slack-cli.md The import_map.json file maps module specifiers to specific URLs and versions, allowing for centralized dependency management within a Deno project. ```json // import_map.json { "imports": { "deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@2.1.5/", "deno-slack-api/": "https://deno.land/x/deno_slack_api@2.1.1/", "mock-fetch/": "https://deno.land/x/mock_fetch@0.3.0/" } } ``` -------------------------------- ### slack datastore query Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/commands/slack_datastore_query.md Query a datastore for items. This command is supported for apps deployed to Slack managed infrastructure, but other apps can attempt to run the command with the --force flag. ```APIDOC ## POST /slackapi/slack-cli/datastore/query ### Description Query a datastore for items. This command is supported for apps deployed to Slack managed infrastructure but other apps can attempt to run the command with the --force flag. ### Method POST ### Endpoint /slackapi/slack-cli/datastore/query ### Parameters #### Query Parameters - **datastore** (string) - Optional - The datastore used to store items. - **output** (string) - Optional - Output format: text, json (default "text"). - **show** (boolean) - Optional - Only construct a JSON expression. - **to-file** (string) - Optional - Save items directly to a file as JSON Lines. - **unstable** (boolean) - Optional - Kick the tires of experimental features. - **app** (string) - Optional - Use a specific app ID or environment. - **config-dir** (string) - Optional - Use a custom path for system config directory. - **experiment** (strings) - Optional - Use the experiment(s) in the command. - **force** (boolean) - Optional - Ignore warnings and continue executing command. - **no-color** (boolean) - Optional - Remove styles and formatting from outputs. - **skip-update** (boolean) - Optional - Skip checking for latest version of CLI. - **team** (string) - Optional - Select workspace or organization by team name or ID. - **token** (string) - Optional - Set the access token associated with a team. - **verbose** (boolean) - Optional - Print debug logging and additional info. #### Request Body - **expression** (string) - Required - The query expression to filter items. - **expression_attributes** (object) - Optional - A mapping of expression attribute names to attribute names. - **expression_values** (object) - Optional - A mapping of expression attribute names to attribute values. - **limit** (integer) - Optional - The maximum number of items to return. - **cursor** (string) - Optional - A cursor for fetching the next page of results. ### Request Example ```json { "datastore": "tasks", "expression": "#status = :status", "expression_attributes": { "#status": "status" }, "expression_values": { ":status": "In Progress" }, "limit": 8, "output": "json" } ``` ### Response #### Success Response (200) - **items** (array) - An array of items matching the query. - **next_cursor** (string) - A cursor for fetching the next page of results, if available. #### Response Example ```json { "items": [ { "id": "item_1", "name": "Task 1", "status": "In Progress" }, { "id": "item_2", "name": "Task 2", "status": "In Progress" } ], "next_cursor": "eyJfX19jVml..." } ``` ``` -------------------------------- ### Configure Slack CLI Protocol Version Source: https://context7.com/slackapi/slack-cli/llms.txt This JSON configuration snippet demonstrates how to set the protocol version for Slack CLI SDK communication. It specifies 'message-boundaries' for protocol-version and disables 'sdk-managed-connection'. ```json { "config": { "protocol-version": ["message-boundaries"], "sdk-managed-connection-enabled": false } } ``` -------------------------------- ### Print Slack CLI Version Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/commands/slack_version.md This command prints the version number of the Slack CLI. It follows semantic versioning (semver) and can include development build information. Flags can be used to modify its behavior, such as skipping update checks. ```bash slack version [flags] ``` ```bash slack --version ``` ```bash slack version # Print version number using the command ``` ```bash slack --version # Print version number using the flag ``` ```bash slack --version --skip-update # Print version and skip update check ``` -------------------------------- ### Define Slack CLI-SDK Interface JSON Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/hooks/index.md This JSON structure defines the interface between the Slack CLI and the SDK. It includes the required runtime, a map of lifecycle hooks, and configuration settings such as file-watching paths and protocol versions. ```json { "runtime": "deno", "hooks": { "get-hooks": "command to be invoked", "get-manifest": "...", "build": "...", "start": "...", "check-update": "...", "install-update": "...", "get-trigger": "...", "doctor": "...", "deploy": "..." }, "config": { "protocol-version": ["message-boundaries"], "sdk-managed-connection-enabled": false, "watch": { "manifest": { "paths": ["manifest.json"] }, "app": { "paths": ["app.js", "listeners/"], "filter-regex": "\\.(ts|js)$" } }, "trigger-paths": ["triggers/"] } } ``` -------------------------------- ### Non-SDK Managed Connection (Socket Mode) Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/hooks/index.md This endpoint describes the process of receiving Slack events via STDIN and sending responses via STDOUT when the Slack CLI manages the Socket Mode connection. ```APIDOC ## Non-SDK Managed Connection (Socket Mode) ### Description This process is invoked when `config.sdk-managed-connection-enabled` is false. The Slack CLI establishes a Socket Mode connection, and events are piped to the application's `start` hook via STDIN. The application SDK processes each event and outputs a JSON response to STDOUT, which the CLI forwards back to Slack. ### Method N/A (This describes a data flow, not a direct HTTP request) ### Endpoint N/A ### Parameters #### Input (STDIN) - **body** (object) - Required - The incoming Slack event payload. The structure depends on the event type. - **context** (object) - Required - Variables relevant for the locally-running application. - **context.bot_access_token** (string) - Required - A bot access token for making Slack API calls. - **context.app_id** (string) - Required - The current application ID. - **context.team_id** (string) - Required - The ID of the workspace the app is installed to. - **context.variables** (object) - Required - Environment variables for the application. ### Request Example ```json { "body": { "type": "app_deleted", "...": "..." }, "context": { "bot_access_token": "xoxb-1234", "app_id": "A1234", "team_id": "T1234", "variables": {} } } ``` ### Response #### Output (STDOUT) - **payload** (object) - The JSON response to be sent back to Slack. The CLI handles acknowledgments. #### Response Example ```json { "...": "..." } ``` ``` -------------------------------- ### Enable Debug Mode with Slack CLI Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/using-environment-variables-with-the-slack-cli.md This section details how to enable debug mode for your Slack application by setting the `SLACK_DEBUG` environment variable. It provides instructions for both local development using a `.env` file and for deployed applications using the `slack env add` command. ```bash # For local apps, add the following to your .env file: SLACK_DEBUG=true ``` ```bash # For deployed apps, run the following command before deployment: slack env add SLACK_DEBUG true ``` -------------------------------- ### Configure Slack CLI file watchers Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/hooks/index.md Defines the watch configuration for the Slack CLI to monitor manifest and application code changes during local development. It uses paths and regex filters to trigger app reinstalls or server reloads. ```json { "config": { "watch": { "manifest": { "paths": ["manifest.json"] }, "app": { "paths": ["app.js", "listeners/"], "filter-regex": "\\.(ts|js)$" } } } } ``` -------------------------------- ### Slack CLI JSON Output Format Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/hooks/index.md Defines the structure of the JSON output for the Slack CLI, detailing fields for package names, release information, messages, and error handling. This format is used to convey release status and update availability. ```json { "name": "", "releases": [ { "name": "", "current": "", "latest": "", "update": true, "breaking": false, "message": "", "url": "", "error": "" } ], "message": "", "url": "", "error": "" } ``` -------------------------------- ### Define Workspace and Environment Variables in JavaScript Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/using-environment-variables-with-the-slack-cli.md This JavaScript snippet demonstrates how to define custom schemas for workspace-specific values, including channel IDs. It shows how to set custom values for each known workspace and environment, and includes fallback options. The code dynamically selects the appropriate value based on the `SLACK_ENV` and `SLACK_WORKSPACE` environment variables. ```javascript // Custom schemas can be defined for workspace values type WorkspaceSchema = { channel_id: string }; type WorkspaceMapSchema = { [workspace: string]: { [environment: string]: WorkspaceSchema; }; }; // Custom values can be set for each known workspace export const workspaceValues: WorkspaceMapSchema = { beagoodhost: { deployed: { channel_id: "C123ABC456", }, local: { channel_id: "C123ABC456", }, }, sandbox: { deployed: { channel_id: "C222BBB222", }, local: { channel_id: "C222BBB222", }, }, }; // Fallback options can also be defined export const defaultValues: WorkspaceSchema = { channel_id: "{{data.channel_id}}", }; // Included environment variables will determine which value is used const environment = Deno.env.get("SLACK_ENV") || ""; const workspace = Deno.env.get("SLACK_WORKSPACE") || ""; const { channel_id } = workspaceValues[workspace]?.[environment] ?? defaultValues; ``` -------------------------------- ### Enforce Required Environment Variables in Slack Manifest (Deno) Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/using-environment-variables-with-the-slack-cli.md This JavaScript code snippet shows how to ensure that environment variables are defined at build time by appending '!' to `Deno.env.get()`. If the variable is not set, it will throw an error, preventing runtime issues. ```javascript outgoingDomains: [ Deno.env.get("CHATBOT_API_URL")!, ], ``` -------------------------------- ### Verify Slack CLI Uninstallation on Windows Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/uninstalling-the-slack-cli.md Verifies that the Slack CLI has been removed by attempting to check the version and inspecting the environment path. A successful uninstallation should result in an error when calling the slack command. ```powershell slack version echo $env:path ``` -------------------------------- ### Slack CLI Event Input Payload (JSON) Source: https://github.com/slackapi/slack-cli/blob/main/docs/reference/hooks/index.md This JSON structure represents the payload received by the SDK via STDIN when a Slack event occurs. It includes the event 'body' and 'context' with details like bot access token, app ID, and team ID. ```json { "body": { "type": "app_deleted", ... }, "context": { "bot_access_token": "xoxb-1234", "app_id": "A1234", "team_id": "T1234", "variables": {} } } ``` -------------------------------- ### Access Environment Variables in Slack Manifest (Deno) Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/using-environment-variables-with-the-slack-cli.md This Deno code snippet demonstrates how to import the dotenv module and access environment variables like `CHATBOT_DISPLAY_NAME` and `CHATBOT_API_URL` within your Slack app's manifest. It uses `Deno.env.get()` to retrieve variable values. ```javascript // manifest.ts import { Manifest } from "deno-slack-sdk/mod.ts"; import ExampleWorkflow from "./workflows/example_workflow.ts"; import "std/dotenv/load.ts"; export default Manifest({ name: "Chatbot4000", displayName: Deno.env.get("CHATBOT_DISPLAY_NAME"), description: "Workflows for communicating with an imagined chatbot", icon: "assets/icon.png", workflows: [ExampleWorkflow], outgoingDomains: [ Deno.env.get("CHATBOT_API_URL")!, ], botScopes: ["commands", "chat:write"], }); ``` -------------------------------- ### Uninstall a Slack app using Slack CLI Source: https://github.com/slackapi/slack-cli/blob/main/docs/guides/removing-an-app.md The uninstall command removes an app's active presence from a specific workspace. This action deletes triggers, workflows, and functions while persisting datastore records, allowing for potential reinstallation later. ```bash slack uninstall -a A123ABC456 -t T123ABC456 ```