Send a slack message to specific channel.
### How this function works
The function will be triggered by a Pub/Sub event published with the specific topic SEND_MESSAGE_TO_SLACK_CHANNEL. The message should contain the channelId and the text.
### Prerequisites
* You must have previous knowledge of **Slack APP**.
* You must have previous knowledge of **Pub/Sub**.
### Function details
First, you need to create a specific Slack app from which the message will be sent. This application must meet the following requirements:
* You need to obtain the `Bot User OAuth Token` from `OAuth & Permissions` section on the App Management page.
* Grant access to your app to write a message. In `OAuth & Permissions` section of the App Management page, make sure your app is scoped with this permission, for example, the `chat:write` scope.
* You need to integrate your app to the channel to which you want to send a message.
* You need to obtain the `Channel ID` from the `About` tab in `Channel Details` in Slack.
Then, install this function passing as a parameter:
- **SLACK_API_TOKEN**: The Slack `Bot User OAuth Token`.
### Call the function
Here is an example of how to use the function when it is installed:
```js
const dataBuffer = Buffer.from(JSON.stringify({
channelId: 'C12345678',
text: 'Hello from my slack app.',
}));
await pubsub.topic('SEND_MESSAGE_TO_SLACK_CHANNEL').publish(dataBuffer);
```
So, the message will be sent according to the channel specify by the `channelId`.
### Resources
For more information about creating a Slack App and meet the requirements, see:
+ [Sending Slack messages](https://api.slack.com/messaging/sending)