Skip to content

Commit

Permalink
Merge pull request #6 from fishme/develop
Browse files Browse the repository at this point in the history
docs(node-red): examples
  • Loading branch information
fishme authored Dec 26, 2023
2 parents 13501db + 690cad7 commit 4cb4ee1
Show file tree
Hide file tree
Showing 15 changed files with 228 additions and 29 deletions.
57 changes: 52 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ After the installation of `@headless-architecture/node-red-contrib-slack-bolt` s

| Name | Description |
| --- | --- |
| Bot Token *required* | Active Communciation Token OAuth/Permissions -> Bot User OAuth Token [your Slack App](https://api.slack.com/apps/) |
| Bot Token *required* | communciation token (starts with xoxb-) see [Slack App](https://api.slack.com/apps/) "OAuth/Permissions" -> "Bot User OAuth Token" |
| Log Level | Slack log levels [more info](https://slack.dev/bolt-js/concepts#logging) |
| Socket | activate the socket mode, if you want to listen for changes in your channel. It is required for the registry nodes. |
| Socket | activate the socket mode, if you want to listen for changes in your channel. It is required for the registry nodes. see [Slack App](https://api.slack.com/apps/) "Socked Mode" |
| Port | default is 3000 [more info](https://slack.dev/bolt-js/concepts#socket-mode) |
| App Token | Basic information -> App-level-Token -> create new -> choose connections:write [slack app](https://api.slack.com/apps/) |
| App Token | Slack App Token (starts with xapp-) see [slack app](https://api.slack.com/apps/) "Basic information" -> "App-level-Token" -> create new -> choose connections:write |

#### Message

Expand All @@ -133,7 +133,7 @@ With this node, Node-RED is able to send direct messages into a channel. Private
| Property | variable of the content for a message |
| Topic | text or block message |
| Text | direct message (overwrite input stream) |
| Blocks | JSON format, complext messages with interactions |
| Blocks | JSON format, complex messages with interactions (overwrite input stream) |
<br />
<details><summary><b>Block Example</b></summary>
Simple Block for choosing a date
Expand Down Expand Up @@ -166,7 +166,7 @@ Simple Block for choosing a date

#### Registry

This node enalbe the following Slack functions.
This node enable the following Slack functions.

- Actions
- Events
Expand All @@ -176,6 +176,9 @@ This node enalbe the following Slack functions.
- Shortcuts
- Commands

Below of the node, you can verify the registrations of your events.
A, E, V, M, O, S, C; Starting letter of the liste above.

![Node Registry Node-RED example](https://raw.githubusercontent.com/fishme/node-red-contrib-slack-bolt/main/docs/img/node-registry-example.png)
<br /><br />
All listener needs to add once. Therefor create a Infection with:
Expand Down Expand Up @@ -308,6 +311,50 @@ Create a production build:
yarn build
```

### Roadmap

Not or not full implementented

#### Knowing not critical Bugs

- Slack App: Fix Logging selection (not working)

#### Slack Features

##### Basic concepts

- Workflow [](https://slack.dev/bolt-js/concepts#creating-steps)

##### Advanced concepts

- Slack Error Handling [](https://slack.dev/bolt-js/concepts#error-handling)
- Global Middleware [](https://slack.dev/bolt-js/concepts#global-middleware)
- Authorization [](https://slack.dev/bolt-js/concepts#authorization)
- Storage [](https://slack.dev/bolt-js/concepts#conversation-store)
- Middleware [](https://slack.dev/bolt-js/concepts#global-middleware)
- Customizing a receiver [](https://slack.dev/bolt-js/concepts#receiver)
- Custom HTTP routes: [](https://slack.dev/bolt-js/concepts#custom-routes)

##### Node Features

- automatic Jest tests
- typescript typings (remove any and unknown)
- add listener node (selection of listener mode and code block)

##### Documentation

- documentation page
- node documentation (improvment)
- code documentation
- Youtube tutorials (create slack app, configuration of slack bot by each listener)
- flow examples

##### Build

- replace rollup with webpack
- github action build (bring tests back)


### Testing Node Set in Node-RED

[Read Node-RED docs](https://nodered.org/docs/creating-nodes/first-node#testing-your-node-in-node-red) on how to install the node set into your Node-RED runtime.
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "@headless-architecture/node-red-contrib-slack-bolt",
"version": "1.1.4",
"version": "1.1.5",
"description": "Control your Slack App via Node-Red! Slack Bolt integration.",
"keywords": [
"Slack",
"Slack-bolt",
"node-red",
"microservice"
"microservice",
"notification"
],
"scripts": {
"add-node": "node ./utils/add-node.js",
Expand Down
15 changes: 11 additions & 4 deletions src/nodes/shared/client.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { App, LogLevel } from '@slack/bolt';

import {
SlackBoltAppNode,
SlackBoltAppNodeDef,
} from '../slack-bolt-app/modules/types';
import { SlackBoltAppNode, SlackBoltAppNodeDef } from '../slack-bolt-app/modules/types';

//import { ConversationStorage } from './storage';

const DefaultPort: string = '3000';

/**
* todos for next versions
* Authorization https://slack.dev/bolt-js/concepts#authorization
* Storage https://slack.dev/bolt-js/concepts#conversation-store
* Middleware https://slack.dev/bolt-js/concepts#global-middleware
* Custom HTTP routes: https://slack.dev/bolt-js/concepts#custom-routes
*/
const connect = (config: SlackBoltAppNodeDef): App => {
// signingSecret needed for Auth0
const configuration = {
Expand All @@ -15,6 +21,7 @@ const connect = (config: SlackBoltAppNodeDef): App => {
appToken: config.appToken,
socketMode: config.socketMode,
logLevel: LogLevel.ERROR,
//convoStore: new ConversationStorage(),
};

return new App(configuration);
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/shared/registry/methods/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const messages = (
configuration: IConfiguration[],
send: any,
done: any
) => {
): number => {
configuration.forEach((item: IConfiguration) => {
SlackApp.message(item.id, async (params) => {
// Acknowledge the action
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/shared/registry/methods/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const shortcuts = (
configuration: IConfiguration[],
send: any,
done: any
) => {
): number => {
configuration.forEach((item: IConfiguration) => {
SlackApp.shortcut(item.id, async (params) => {
// Acknowledge the action
Expand Down
12 changes: 12 additions & 0 deletions src/nodes/shared/storage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
export class ConversationStorage {
set(conversationId: string, value: any, expiresAt?: number) {
return new Promise((resolve, reject) => {});
}
get(conversationId: string) {
// Returns a Promise
return new Promise((resolve, reject) => {});
}
}
*/
14 changes: 9 additions & 5 deletions src/nodes/slack-bolt-app/slack-bolt-app.html/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
</div>

<div class="form-row">
<label for="node-config-input-token">Bot Token</label>
<input type="text" id="node-config-input-token" />
<label for="node-config-input-token"
><i class="fa fa-lock" aria-hidden="true"></i> Bot Token</label
>
<input type="text" id="node-config-input-token" /> e.g. xoxb-XYZEG
</div>
<!--
<div class="form-row">
Expand All @@ -25,7 +27,7 @@ <h3 class="red-ui-help-title">Listener</h3>
required!
</div>
<div class="form-row">
<label for="node-config-input-socketMode">Socket</label>
<label for="node-config-input-socketMode"> Socket</label>
<input type="checkbox" id="node-config-input-socketMode" />
</div>
<div class="form-row">
Expand All @@ -40,7 +42,9 @@ <h3 class="red-ui-help-title">Listener</h3>
/>
</div>
<div class="form-row">
<label for="node-config-input-appToken">App Token</label>
<input type="text" id="node-config-input-appToken" />
<label for="node-config-input-appToken"
><i class="fa fa-lock" aria-hidden="true"></i> App Token</label
>
<input type="text" id="node-config-input-appToken" /> e.g. xapp-XYZEG
</div>
</script>
7 changes: 4 additions & 3 deletions src/nodes/slack-bolt-app/slack-bolt-app.html/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

### Getting Started
I needs a installed and published Slack App into your channels. Follow this [Instructions]().
For of the configuration look into your [your Slack App](https://api.slack.com/apps/)

### Configuration
: Name : slack instance name
for the next configuration open your

: Bot Token: OAuth/Permissions -> Bot User OAuth Token [slack app](https://api.slack.com/apps/)
: Bot Token: communciation token (starts with xoxb-) see [Slack App](https://api.slack.com/apps/) "OAuth/Permissions" -> "Bot User OAuth Token"
: Log Level: Slack log levels [more info](https://slack.dev/bolt-js/concepts#logging)
: Socket: turn the socket mode on, if you want to listen for changes in your channel. It is required for the registry nodes
: Socket: activate the socket mode, if you want to listen for changes in your channel. It is required for the registry nodes. see [Slack App](https://api.slack.com/apps/) "Socked Mode"
: Port: default is 3000 [more info](https://slack.dev/bolt-js/concepts#socket-mode)
: App Token: Basic information -> App-level-Token -> create new -> choose connections:write [slack app](https://api.slack.com/apps/)
: App Token: Slack App Token (starts with xapp-) see [slack app](https://api.slack.com/apps/) "Basic information" -> "App-level-Token" -> create new -> choose connections:write
</script>
2 changes: 1 addition & 1 deletion src/nodes/slack-bolt-app/slack-bolt-app.html/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RED.nodes.registerType<SlackBoltAppEditorNodeProperties>('slack-bolt-app', {
appToken: { value: '' },
},
label: function () {
return this.name || 'slack bolt app';
return this.name || 'Slack Bolt app';
},
oneditprepare: function () {
$('#node-input-logLevel').typedInput({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface SlackBoltAppEditorNodeProperties
token: string;
signingSecret: string;
socketMode: boolean;

port: number;
appToken: string;
logLevel: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

<div class="form-row">
<label for="node-input-property"
><i class="fa fa-commenting-o"></i> Property</label
><i class="fa fa-ellipsis-h"></i> Property</label
>
<input type="text" id="node-input-property" placeholder="payload" />
<input type="hidden" id="node-input-propertyType" />
</div>
<div class="form-row">
<label for="node-input-propertySendType"
><i class="fa fa-commenting-o"></i> Topic</label
><i class="fa fa-envelope" aria-hidden="true"></i> Topic</label
>
<input type="text" id="node-input-propertySendType" />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Choose correct property type before your send the message. (msg, flow, global)

1. Property
: payload (string) : the payload variable of the message or context variable to publish.
: payload (string) : variable of the content for a message
2. Topic
Define the message type.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ declare const RED: EditorRED;
RED.nodes.registerType<SlackBoltMessageEditorNodeProperties>(
'slack-bolt-message',
{
category: 'slack',
category: 'Slack',
color: '#5BB381',
defaults: {
name: { value: '' },
Expand Down
Loading

0 comments on commit 4cb4ee1

Please sign in to comment.