Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@slack/web-api

Package Overview
Dependencies
Maintainers
14
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slack/web-api

Official library for using the Slack Platform's Web API

  • 5.11.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.7M
decreased by-15.75%
Maintainers
14
Weekly downloads
 
Created

What is @slack/web-api?

The @slack/web-api npm package is a JavaScript client for Slack's Web API. It provides an easy-to-use interface for interacting with various Slack API methods, allowing developers to integrate their applications with Slack services. With this package, developers can send messages, manage channels, handle users, and more, all within their Node.js applications.

What are @slack/web-api's main functionalities?

Sending Messages

This feature allows you to send messages to channels or users in Slack. The code sample demonstrates how to use the `chat.postMessage` method to send a 'Hello world!' message to a specified channel.

const { WebClient } = require('@slack/web-api');
const web = new WebClient(process.env.SLACK_TOKEN);

async function sendMessage(channel, message) {
  try {
    const result = await web.chat.postMessage({
      channel: channel,
      text: message
    });
    console.log(result);
  } catch (error) {
    console.error(error);
  }
}

sendMessage('C1234567890', 'Hello world!');

Managing Channels

This feature enables the creation, modification, and management of channels. The code sample shows how to create a new channel using the `conversations.create` method.

const { WebClient } = require('@slack/web-api');
const web = new WebClient(process.env.SLACK_TOKEN);

async function createChannel(name) {
  try {
    const result = await web.conversations.create({
      name: name
    });
    console.log(result);
  } catch (error) {
    console.error(error);
  }
}

createChannel('new-channel');

Handling Users

This feature deals with user information and actions, such as listing users, getting user info, and updating user profiles. The code sample illustrates how to list all users in a Slack workspace using the `users.list` method.

const { WebClient } = require('@slack/web-api');
const web = new WebClient(process.env.SLACK_TOKEN);

async function listUsers() {
  try {
    const result = await web.users.list();
    console.log(result.members);
  } catch (error) {
    console.error(error);
  }
}

listUsers();

Other packages similar to @slack/web-api

Keywords

FAQs

Package last updated on 20 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc