Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ project is to provide modules for:
3. Dispatching event payloads to individual functions by callback ID and running
them (`src/dispatch-payload.ts`)

This library has two modes of operation:
This library has four modes of operation:

1. Using `mod.ts` as the entrypoint, a directory containing function code files
to be loaded at runtime must be provided as an argument. This directory must
Expand All @@ -22,13 +22,21 @@ This library has two modes of operation:
contain a `manifest.json`, `manifest.ts` or `manifest.js` file, which in turn
must contain function definitions that include a `source_file` property. This
property is used to determine which function to load and run at runtime.
3. Using `self-hosted-socket-mode.ts` as the entrypoint. This establishes a persistent
WebSocket connection to Slack using Socket Mode and maintains a long-running process that listens for events.
4. Using `self-hosted-http-mode.ts` as the entrypoint. This starts an HTTP server that
accepts events via POST requests to `/events` endpoints, similar to Bolt JS's
HTTPReceiver. The only required environment variable is
`SLACK_SIGNING_SECRET`; optional variables include `PORT`,
`SLACK_SIGNATURE_VERIFICATION`, and `SLACK_API_URL` (e.g.
`SLACK_SIGNING_SECRET=xxx PORT=3000 deno run src/self-hosted-http-mode.ts`).

Regardless of which mode of operation used, each runtime definition for a
function is specified in its own file and must be the default export.

## Usage

By default, your Slack app has a `/slack.json` file that defines a `get-hooks`
By default, your Slack app has a `.slack/hooks.json` file that defines a `get-hooks`
hook. The Slack CLI will automatically use the version of the
`deno-slack-runtime` that is specified by the version of the `get-hooks` script
that you're using. To use this library via the Slack CLI out of the box, use the
Expand All @@ -42,7 +50,7 @@ You also have the option to
You can change the script that runs by specifying a new script for the `start`
command. For instance, if you wanted to point to your local instance of this
repo, you could accomplish that by adding a `start` command to your
`/slack.json` file and setting it to the following:
`.slack/hooks.json` file and setting it to the following:

```json
{
Expand All @@ -60,6 +68,10 @@ operating this library in:
`deno run -q --config=deno.jsonc --allow-read --allow-net https://deno.land/x/deno_slack_runtime@0.1.1/mod.ts ./<required-function-directory>`
2. Local project with a manifest file:
`deno run -q --config=deno.jsonc --allow-read --allow-net https://deno.land/x/deno_slack_runtime@0.1.1/local-run.ts`
3. Self-hosted socket mode:
`deno run -q --config=deno.jsonc --allow-read --allow-net --allow-run --allow-env --allow-sys=osRelease https://deno.land/x/deno_slack_runtime@0.1.1/self-hosted-socket-mode.ts`
4. Self-hosted HTTP Receiver:
`deno run -q --config=deno.jsonc --allow-read --allow-net --allow-env --allow-sys=osRelease https://deno.land/x/deno_slack_runtime@0.1.1/self-hosted-http-mode.ts`

⚠️ Don't forget to update the version specifier in the URL inside the above
commands to match the version you want to test! You can also drop the `@` and
Expand Down
5 changes: 5 additions & 0 deletions src/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ export { getManifest } from "https://deno.land/x/deno_slack_hooks@1.4.0/get_mani
export { parse } from "https://deno.land/std@0.99.0/flags/mod.ts";
export { getProtocolInterface } from "https://deno.land/x/deno_slack_protocols@0.0.2/mod.ts";
export type { Protocol } from "https://deno.land/x/deno_slack_protocols@0.0.2/types.ts";

// Socket Mode dependencies (npm packages via Deno)
export { SocketModeClient } from "npm:@slack/socket-mode@2.0.5";
export { ConsoleLogger, LogLevel } from "npm:@slack/logger@4.0.0";
export type { Logger } from "npm:@slack/logger@4.0.0";
1 change: 1 addition & 0 deletions src/local-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const getCommandline = function (
"--config=deno.jsonc",
"--allow-read",
"--allow-env",
"--allow-sys=osRelease",
];

const allowedDomains = manifest.outgoing_domains ?? [];
Expand Down
Loading
Loading