Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation and Refactor code in automated summary example #163

Merged
merged 5 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,41 @@ For more information, go to the modules.

## Setup guide

To use the Slack Connector you need to be signed in to [Slack](https://slack.com/).
### Step 1: Sign in to Slack

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/sign-in.png alt="Sign-In Page" style="width: 70%;">
1. To use the Slack Connector you need to be signed in to [Slack](https://slack.com/). If you haven't created an account already, you can create it [here](https://slack.com/get-started#/createnew).

If you haven't created an account already, you can create it [here](https://slack.com/get-started#/createnew).
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/sign-in.png alt="Sign-In Page" style="width: 70%;">

### Step 1: Create a new Slack application
### Step 2: Create a new Slack application

1. Navigate to your apps in [Slack API](https://api.slack.com/) and create a new Slack app.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/create-slack-app.png alt="Create Slack App" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/create-slack-app.png alt="Create Slack App" style="width: 70%;">

2. Provide an app name and choose a workspace of your choice.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/create-slack-app-2.png alt="Create Slack App Popup" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/create-slack-app-2.png alt="Create Slack App Popup" style="width: 70%;">

3. Click on the "Create App" button.

### Step 2: Add scopes to the token
### Step 3: Add scopes to the token

1. Once the application is created, go to the "Add Features and Functionality" section and click on "Permissions" to set the token scopes.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/add-features.png alt="Add features and functionality" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/add-features.png alt="Add features and functionality" style="width: 70%;">

2. In the **User Token Scopes** section set the following token scopes.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/token-permissions.png alt="User Token Scopes" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/token-permissions.png alt="User Token Scopes" style="width: 70%;">

3. Install the application to workspace.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/install-workspace.jpg alt="Install to workspace" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/install-workspace.jpg alt="Install to workspace" style="width: 70%;">

4. Copy the OAuth token that is generated upon installation.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/copy-token.jpg alt="Copy token" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/copy-token.jpg alt="Copy token" style="width: 70%;">


## Quickstart
Expand Down Expand Up @@ -104,7 +104,7 @@ bal run

The `Slack` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-slack/tree/master/examples), covering the following use cases:

1. [Automated Survey Report](https://github.com/ballerina-platform/module-ballerinax-slack/tree/master/examples/automated-survey-report) - This use case demonstrates how the Slack API can be utilized to generate a summarized report of daily stand up chats in the general channel.
1. [Automated Summary Report](https://github.com/ballerina-platform/module-ballerinax-slack/tree/master/examples/automated-summary-report) - This use case demonstrates how the Slack API can be utilized to generate a summarized report of daily stand up chats in the general channel.

2. [Survey Feedback Analysis](https://github.com/ballerina-platform/module-ballerinax-slack/tree/master/examples/survey-feedback-analysis) - This use case demonstrates how the Slack API can be utilized to perform a company-wide survey by creating a dedicated channel to receive and track feedback replies.

Expand Down
24 changes: 12 additions & 12 deletions ballerina/Module.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@

## Setup guide

To use the Slack Connector you need to be signed in to [Slack](https://slack.com/).
### Step 1: Sign in to Slack

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/sign-in.png alt="Sign-In Page" style="width: 70%;">
1. To use the Slack Connector you need to be signed in to [Slack](https://slack.com/). If you haven't created an account already, you can create it [here](https://slack.com/get-started#/createnew).

If you haven't created an account already, you can create it [here](https://slack.com/get-started#/createnew).
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/sign-in.png alt="Sign-In Page" style="width: 70%;">

### Step 1: Create a new Slack application
### Step 2: Create a new Slack application

1. Navigate to your apps in [Slack API](https://api.slack.com/) and create a new Slack app.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/create-slack-app.png alt="Create Slack App" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/create-slack-app.png alt="Create Slack App" style="width: 70%;">

2. Provide an app name and choose a workspace of your choice.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/create-slack-app-2.png alt="Create Slack App Popup" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/create-slack-app-2.png alt="Create Slack App Popup" style="width: 70%;">

3. Click on the "Create App" button.

### Step 2: Add scopes to the token
### Step 3: Add scopes to the token

1. Once the application is created, go to the "Add Features and Functionality" section and click on "Permissions" to set the token scopes.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/add-features.png alt="Add features and functionality" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/add-features.png alt="Add features and functionality" style="width: 70%;">

2. In the **User Token Scopes** section set the following token scopes.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/token-permissions.png alt="User Token Scopes" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/token-permissions.png alt="User Token Scopes" style="width: 70%;">

3. Install the application to workspace.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/install-workspace.jpg alt="Install to workspace" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/install-workspace.jpg alt="Install to workspace" style="width: 70%;">

4. Copy the OAuth token that is generated upon installation.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/copy-token.jpg alt="Copy token" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/copy-token.jpg alt="Copy token" style="width: 70%;">


## Quickstart
Expand Down Expand Up @@ -87,6 +87,6 @@ bal run

The `Slack` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-slack/tree/master/examples), covering the following use cases:

1. [Automated Survey Report](https://github.com/ballerina-platform/module-ballerinax-slack/tree/master/examples/automated-survey-report) - This use case demonstrates how the Slack API can be utilized to generate a summarized report of daily stand up chats in the general channel.
1. [Automated Summary Report](https://github.com/ballerina-platform/module-ballerinax-slack/tree/master/examples/automated-summary-report) - This use case demonstrates how the Slack API can be utilized to generate a summarized report of daily stand up chats in the general channel.

2. [Survey Feedback Analysis](https://github.com/ballerina-platform/module-ballerinax-slack/tree/master/examples/survey-feedback-analysis) - This use case demonstrates how the Slack API can be utilized to perform a company-wide survey by creating a dedicated channel to receive and track feedback replies.
24 changes: 12 additions & 12 deletions ballerina/Package.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@

## Setup guide

To use the Slack Connector you need to be signed in to [Slack](https://slack.com/).
### Step 1: Sign in to Slack

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/sign-in.png alt="Sign-In Page" style="width: 70%;">
1. To use the Slack Connector you need to be signed in to [Slack](https://slack.com/). If you haven't created an account already, you can create it [here](https://slack.com/get-started#/createnew).

If you haven't created an account already, you can create it [here](https://slack.com/get-started#/createnew).
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/sign-in.png alt="Sign-In Page" style="width: 70%;">

### Step 1: Create a new Slack application
### Step 2: Create a new Slack application

1. Navigate to your apps in [Slack API](https://api.slack.com/) and create a new Slack app.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/create-slack-app.png alt="Create Slack App" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/create-slack-app.png alt="Create Slack App" style="width: 70%;">

2. Provide an app name and choose a workspace of your choice.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/create-slack-app-2.png alt="Create Slack App Popup" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/create-slack-app-2.png alt="Create Slack App Popup" style="width: 70%;">

3. Click on the "Create App" button.

### Step 2: Add scopes to the token
### Step 3: Add scopes to the token

1. Once the application is created, go to the "Add Features and Functionality" section and click on "Permissions" to set the token scopes.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/add-features.png alt="Add features and functionality" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/add-features.png alt="Add features and functionality" style="width: 70%;">

2. In the **User Token Scopes** section set the following token scopes.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/token-permissions.png alt="User Token Scopes" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/token-permissions.png alt="User Token Scopes" style="width: 70%;">

3. Install the application to workspace.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/install-workspace.jpg alt="Install to workspace" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/install-workspace.jpg alt="Install to workspace" style="width: 70%;">

4. Copy the OAuth token that is generated upon installation.

<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/copy-token.jpg alt="Copy token" style="width: 70%;">
<img src=https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-slack/master/docs/setup/resources/copy-token.jpg alt="Copy token" style="width: 70%;">


## Quickstart
Expand Down Expand Up @@ -87,6 +87,6 @@ bal run

The `Slack` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-slack/tree/master/examples), covering the following use cases:

1. [Automated Survey Report](https://github.com/ballerina-platform/module-ballerinax-slack/tree/master/examples/automated-survey-report) - This use case demonstrates how the Slack API can be utilized to generate a summarized report of daily stand up chats in the general channel.
1. [Automated Summary Report](https://github.com/ballerina-platform/module-ballerinax-slack/tree/master/examples/automated-summary-report) - This use case demonstrates how the Slack API can be utilized to generate a summarized report of daily stand up chats in the general channel.

2. [Survey Feedback Analysis](https://github.com/ballerina-platform/module-ballerinax-slack/tree/master/examples/survey-feedback-analysis) - This use case demonstrates how the Slack API can be utilized to perform a company-wide survey by creating a dedicated channel to receive and track feedback replies.
1 change: 0 additions & 1 deletion docs/spec/sanitations.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@@ -0,0 +1,24 @@
_Author_: @Chilliwiddit \
_Created_: 2024/06/25 \
_Edition_: Swan Lake
Expand Down
41 changes: 18 additions & 23 deletions examples/automated-summary-report/main.bal
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
// Copyright (c) 2024 WSO2 LLC. (http://www.wso2.org).
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/io;
import ballerina/http;
import ballerina/log;
import ballerinax/slack;

configurable string token = ?;

# Holds slack channel information.
type ChannelType record {
string id;
};

# Holds response struture of the channels list.
type Channels record {|
boolean ok;
ChannelType[] channels;
|};

# Holds information of each text
type TextType record {
string text;
};

# Holds the response structure of the conversation history.
type History record {
boolean ok;
TextType[] texts;
};

// Initialize the Slack client with the provided token.
final slack:Client slack = check new Client({
auth: {
token: value
token
}
});

Expand Down
37 changes: 37 additions & 0 deletions examples/automated-summary-report/types.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) 2024 WSO2 LLC. (http://www.wso2.org).
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

# Holds slack channel information.
type ChannelType record {
string id;
};

# Holds response struture of the channels list.
type Channels record {|
boolean ok;
ChannelType[] channels;
|};

# Holds information of each text
type TextType record {
string text;
};

# Holds the response structure of the conversation history.
type History record {
boolean ok;
TextType[] texts;
};
Loading