npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@slack/deno-slack-sdk

v2.15.0

Published

Official library for using Deno Slack SDK in node Slack apps

Downloads

1,625

Readme

A Deno SDK to build Slack apps with the latest platform features. Read the quickstart guide and look at our code samples to learn how to build apps.

Versioning

Releases for this repository follow the SemVer versioning scheme. The SDK's contract is determined by the top-level exports from src/mod.ts and src/types.ts. Exports not included in these files are deemed internal and any modifications will not be treated as breaking changes. As such, internal exports should be treated as unstable and used at your own risk.

Setup

Make sure you have a development workspace where you have permission to install apps. Please note that the features in this project require that the workspace be part of a Slack paid plan.

Install the Slack CLI

You need to install and configure the Slack CLI. Step-by-step instructions can be found on our install & authorize page.

Creating an app

Create a blank project by executing the following command:

slack create my-app --template slack-samples/deno-blank-template

cd my-app/

The manifest.ts file contains the app's configuration. This file defines attributes like app name, description and functions.

Create a function

mkdir ./functions && touch ./functions/hello_world.ts
// Contents of ./functions/hello_world.ts
import { DefineFunction, Schema, SlackFunction } from "deno-slack-sdk/mod.ts";

export const HelloWorldFunctionDef = DefineFunction({
  callback_id: "hello_world_function",
  title: "Hello World",
  source_file: "functions/hello_world.ts",
  input_parameters: {
    properties: {},
    required: [],
  },
  output_parameters: {
    properties: {
      message: {
        type: Schema.types.string,
        description: "Hello world message",
      },
    },
    required: ["message"],
  },
});

export default SlackFunction(
  HelloWorldFunctionDef,
  () => {
    return {
      outputs: { message: "Hello World!" },
    };
  },
);

DefineFunction is used to define a custom function and provide Slack with the information required to use it.

SlackFunction uses the definition returned by DefineFunction and your custom executable code to export a Slack-usable custom function.

Create a workflow

mkdir ./workflows && touch ./workflows/hello_world.ts
// Contents of ./workflows/hello_world.ts
import { DefineWorkflow, Schema } from "deno-slack-sdk/mod.ts";
import { HelloWorldFunctionDef } from "../functions/hello_world.ts";

const HelloWorldWorkflowDef = DefineWorkflow({
  callback_id: "hello_world_workflow",
  title: "Hello World Workflow",
  input_parameters: {
    properties: {
      channel: {
        type: Schema.slack.types.channel_id,
      },
    },
    required: ["channel"],
  },
});

const helloWorldStep = HelloWorldWorkflowDef.addStep(HelloWorldFunctionDef, {});

HelloWorldWorkflowDef.addStep(Schema.slack.functions.SendMessage, {
  channel_id: HelloWorldWorkflowDef.inputs.channel,
  message: helloWorldStep.outputs.message,
});

export default HelloWorldWorkflowDef;

DefineWorkflow is used to define a workflow and provide Slack with the information required to use it.

HelloWorldWorkflow.addStep is used to add a step to the workflow; here we add the HelloWorldFunction and then the SendMessage Slack Function that will post the message to a Slack channel.

Update the manifest

// Contents of manifest.ts
import { Manifest } from "deno-slack-sdk/mod.ts";
import HelloWorldWorkflow from "./workflows/hello_world.ts";

export default Manifest({
  name: "my-app",
  description: "A Hello World app",
  icon: "assets/default_new_app_icon.png",
  workflows: [HelloWorldWorkflow],
  outgoingDomains: [],
  botScopes: ["chat:write", "chat:write.public"],
});

Manifest is used to define your apps manifest and provides Slack with the information required to manage it.

Create a trigger

mkdir ./triggers && touch ./triggers/hello_world.ts
// Contents of ./triggers/hello_world.ts
import { Trigger } from "deno-slack-sdk/types.ts";
import { TriggerContextData, TriggerTypes } from "deno-slack-api/mod.ts";
import HelloWorldWorkflow from "../workflows/hello_world.ts";

const trigger: Trigger<typeof HelloWorldWorkflow.definition> = {
  type: TriggerTypes.Shortcut,
  name: "Reverse a string",
  description: "Starts the workflow to reverse a string",
  workflow: `#/workflows/${HelloWorldWorkflow.definition.callback_id}`,
  inputs: {
    channel: {
      value: TriggerContextData.Shortcut.channel_id,
    },
  },
};

export default trigger;

The Trigger object is used to define a trigger that will invoke the HelloWorldWorkflow. The Slack CLI will detect this file and prompt you for its creation.

Running an app

slack run

When prompted, create the triggers/hello_world.ts trigger. This will send your trigger configuration to Slack.

Post the Hello world shortcut trigger in a slack message and use it

Getting Help

This documentation has more information on basic and advanced concepts of the SDK.

Information on how to get started developing with Deno can be found in this documentation.

If you get stuck, we're here to help. The following are the best ways to get assistance working through your issue:

  • Issue Tracker for questions, bug reports, feature requests, and general discussion. Try searching for an existing issue before creating a new one.
  • Email our developer support team: [email protected]

Contributing

Contributions are more than welcome. Please look at the contributing guidelines for more info!