JSPM

  • Created
  • Published
  • Downloads 11281
  • Score
    100M100P100Q176295F
  • License MIT

Streamlined Slack Web API client for TypeScript

Package Exports

  • slack-web-api-client
  • slack-web-api-client/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (slack-web-api-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Slack Web API Client for TypeScript

npm version deno module

The slack-web-api-client library is a type-safe Slack Web API client that provides several key benefits, including:

  • A fetch-based implementation, which is compatible with most runtimes
  • Strong types for Web API responses and Block Kit, which make coding enjoyable and predictable
  • Zero additional dependencies, allowing developers to integrate this library into their projects without any obstacles

Getting Started

Working with the npm package

To install the slack-web-api-client library, simply use the standard npm/yarn command:

npm i slack-web-api-client@latest

Once you have added the slack-web-api-client library to your project's dependencies using the npm/yarn command, you can easily import any functionality you need from "slack-web-api-client" in your TypeScript code:

import { SlackAPIClient } from "slack-web-api-client";

const client = new SlackAPIClient(process.env.SLACK_BOT_TOKEN);
const response = await client.chat.postMessage({
  channel: "#random",
  text: "👋 what's up?",
});

The second argument of the constructor allows for optional customizations:

const client = new SlackAPIClient(process.env.SLACK_BOT_TOKEN, {
  logLevel: "DEBUG",
});

This argument, if provided, allows for further configuration of SlackAPIClient instance to fit your specific needs.

Working with the Deno module

In addition to standard web and Node.js environments, the slack-web-api-client library also offers a native package for the Deno runtime. To import the module for Slack's automation platform, use the following syntax:

import { SlackFunction } from "deno-slack-sdk/mod.ts";

export const def = DefineFunction({
  callback_id: "hello",
  title: "Hello World",
  source_file: "functions/hello.ts",
  input_parameters: { properties: {}, required: [] },
  output_parameters: { properties: {}, required: [] },
});

import { SlackAPIClient } from "https://deno.land/x/slack_web_api_client@0.8.1/mod.ts";

export default SlackFunction(def, async ({ token }) => {
  const client = new SlackAPIClient(token);
  const response = await client.chat.postMessage({
    channel: "#random",
    text: "👋 what's up?",
  });

// ....
});

This allows you to use the powerful features of the slack-web-api-client library in your Deno projects with ease.

An alternative way is to use skypack CDN. If you prefer this way, you need to add "cdn.skypack.dev" to outgoingDomains in manifest.ts.

An alternative way to use the slack-web-api-client library is through the skypack CDN. To do this, simply add "cdn.skypack.dev" to the outgoingDomains section in your manifest.ts file. This allows you to use the library within your project:

import { SlackAPIClient } from "https://cdn.skypack.dev/slack-web-api-client?dts";