33 releases

0.3.4 Jul 10, 2023
0.3.3 Jul 9, 2023
0.3.1 Jun 14, 2023
0.2.6 Mar 3, 2023
0.1.7 Dec 30, 2022

#1893 in Network programming

MIT/Apache

14KB
243 lines

This is a library for integrating Slack in your flow function for flows.network.

Usage example

use slack_flows::{listen_to_channel, send_message_to_channel};

#[no_mangle]
pub fn run() {
    listen_to_channel("myworkspace", "mychannel", |sm| {
        send_message_to_channel("myworkspace", "mychannel", format!("Hello, {}", sm.text))
    }).await;
}

In run() the listen_to_channel will create a listener for new message from channel mychannel in workspace myworkspace.

When a new message is sent to mychannel, the callback closure will be called with the SlackMessage then send_message_to_channel.

The whole document is here.


lib.rs:

Slack integration for Flows.network

Quick Start

To get started, the easist way is to write a flow function that acts as a Hello World Slack bot.

use slack_flows::{listen_to_channel, send_message_to_channel};

#[no_mangle]
pub fn run() {
    listen_to_channel("myworkspace", "mychannel", |sm| {
        send_message_to_channel("myworkspace", "mychannel", format!("Hello, {}",
        sm.text))
    }).await;
}

[listen_to_channel()] is responsible for registering a listener for channel mychannel of workspace myworkspace. Whenever a new message is sent to the channel, the callback closure is called with received message then [send_message_to_channel()] is used to send a response message to the same channel.

Dependencies

~5MB
~87K SLoC