
Product
Introducing GitHub Actions Scanning Support
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
@weweb/backend-slack
Advanced tools
A WeWeb backend integration for Slack's API, providing access to messaging, channels, users, and other Slack features within WeWeb backend workflows. This integration uses the official @slack/web-api package for robust and type-safe interactions with Slack's API.
This package is designed to work with the WeWeb Supabase Backend Builder and Deno.
import { serve } from '@weweb/backend-core';
import { createSlackIntegration } from '@weweb/backend-slack';
import type { BackendConfig } from '@weweb/backend-core';
import { serve } from '@weweb/backend-core';
import Slack from '@weweb/backend-slack';
// Define your backend configuration
const config: BackendConfig = {
workflows: [
// Your workflows here
],
integrations: [
// Use the default Slack integration
Slack,
// Or add other integrations
],
production: false,
};
// Start the server
const server = serve(config);
You can customize the Slack client by using the createSlackIntegration function:
import { createSlackIntegration } from '@weweb/backend-slack';
// Create a custom Slack integration
const customSlack = createSlackIntegration({
botToken: 'xoxb-your-bot-token', // Override environment variable
userToken: 'xoxp-your-user-token', // Optional
apiUrl: 'https://your-custom-endpoint.com', // Optional
});
If not specified, the integration will use the following environment variables:
SLACK_BOT_TOKEN - Your Slack Bot User OAuth Token (xoxb-...)SLACK_USER_TOKEN - Your Slack User OAuth Token (xoxp-...)SLACK_API_URL - Custom API endpoint URL (optional, defaults to https://slack.com/api)Send messages to channels or users.
// Example workflow action
const config = {
type: 'action',
id: 'send_slack_message',
actionId: 'slack.post_message',
inputMapping: [
{
channel: 'general',
text: 'Hello from WeWeb! đź‘‹',
mrkdwn: true
}
]
};
Create a new public channel in a workspace.
// Example workflow action
const config = {
type: 'action',
id: 'create_slack_channel',
actionId: 'slack.create_channel',
inputMapping: [
{
name: 'project-updates',
validate: true
}
]
};
Invite users to a channel.
// Example workflow action
const config = {
type: 'action',
id: 'invite_users',
actionId: 'slack.invite_to_channel',
inputMapping: [
{
channel: 'project-updates',
users: 'U0123456789,U9876543210'
}
]
};
Get a list of all channels in the workspace.
// Example workflow action
const config = {
type: 'action',
id: 'get_channels',
actionId: 'slack.list_channels',
inputMapping: [
{
exclude_archived: true,
limit: 100
}
]
};
Get a list of all users in the workspace.
// Example workflow action
const config = {
type: 'action',
id: 'get_users',
actionId: 'slack.list_users',
inputMapping: [
{
limit: 100
}
]
};
Upload a file to Slack.
// Example workflow action
const config = {
type: 'action',
id: 'upload_file',
actionId: 'slack.upload_file',
inputMapping: [
{
file: '$body.fileContent', // Base64 encoded file
filename: 'report.pdf',
title: 'Monthly Report',
channels: 'general,reports'
}
]
};
import type { BackendConfig } from '@weweb/backend-core';
import { serve } from '@weweb/backend-core';
import Slack from '@weweb/backend-slack';
const config: BackendConfig = {
workflows: [
{
path: '/notify',
methods: ['POST'],
security: {
accessRule: 'public',
},
inputsValidation: {
body: {
type: 'object',
properties: {
channel: { type: 'string' },
title: { type: 'string' },
message: { type: 'string' },
importance: { type: 'string', enum: ['low', 'medium', 'high'] }
},
required: ['channel', 'title', 'message'],
},
},
workflow: [
{
type: 'action',
id: 'send_notification',
actionId: 'slack.post_message',
inputMapping: [
{
channel: '$body.channel',
blocks: [
{
type: 'header',
text: {
type: 'plain_text',
text: '$body.title'
}
},
{
type: 'section',
text: {
type: 'mrkdwn',
text: '$body.message'
}
},
{
type: 'context',
elements: [
{
type: 'mrkdwn',
text: '*Importance:* $body.importance'
}
]
}
]
},
],
},
],
},
],
integrations: [Slack],
production: false,
};
console.log('Starting Slack notification server on http://localhost:8000/notify');
serve(config);
This integration uses the official Slack Web API client and requires Slack API tokens to function:
Bot Token (xoxb-...): Used for most API calls. This token is obtained by creating a Slack App, adding Bot Token Scopes, and installing the app to your workspace.
User Token (xoxp-...): Required for some user-level actions like search_messages. This token is obtained by adding User Token Scopes to your Slack App.
For full details on obtaining these tokens, see Slack's API documentation.
Depending on which methods you use, your Slack app will need different OAuth scopes:
chat:write - For posting messageschannels:read - For listing channelschannels:write - For creating channelsusers:read - For listing usersreactions:write - For adding reactionsfiles:write - For uploading filessearch:read - For searching messagesMake sure to add the required scopes to your Slack app based on the functionality you need.
FAQs
Slack integration for WeWeb backend services
We found that @weweb/backend-slack demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

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.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.

Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.

Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.