Skip to content

Commit

Permalink
fix(docs): flow example, removed demo token, node-red scorecard
Browse files Browse the repository at this point in the history
  • Loading branch information
fishme committed Dec 21, 2023
1 parent f81abc5 commit e85562d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ copy paste into your
see `/examples/example.json`

<details><summary><b>Example</b></summary>
`[{"id":"1fd29692524d1ecb","type":"tab","label":"Gateway","disabled":false,"info":"","env":[]},{"id":"9abaac9bbddc9bce","type":"group","z":"1fd29692524d1ecb","name":"","style":{"fill":"#bfc7d7","label":true},"nodes":["66d82a9b2adba28f","a1af82db52869929","2c5427b594cdc27d","b4ccc9f550d6192e","96f668735a340977","0be1a3a745d4345b","a8f863a194453f25","3701e2672d1605c0","ada60a61dc4363ca","abd1fa9196265fd6","e1bae9dec89865d5","222f70122d1d13d3","85f483cbc0729943","9326c16c34564ce9","509fc660e5a7454f","b9b5a6a13cde4552"],"x":134,"y":199,"w":1372,"h":682},{"id":"a1af82db52869929","type":"function","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"Events","func":"msg.SlackBolt = {\n actions: [],\n commands: [],\n events: [],\n shortcuts: [],\n options: [],\n messages: []\n};\nmsg.SlackBolt.actions.push(\n {\n 'id': 'button_click',\n 'callback':\n async ({ body, ack, say }) => {\n // Acknowledge the action\n await ack();\n return await say(`<@${body.user.id}> clicked the button2x`);\n\n }\n }\n);\n\n\n\nmsg.SlackBolt.commands.push(\n {\n 'id': '/node-red',\n 'callback':\n async ({ command, ack, respond }) => {\n // Acknowledge command request\n await ack();\n\n await respond(`${command.text}`);\n }\n }\n);\n\n\n\nmsg.SlackBolt.shortcuts.push({\n 'id': 'need_drink',\n 'callback':\n async ({ shortcut, ack, client, logger }) => {\n // Acknowledge shortcut request\n await ack();\n\n // Call the views.open method using one of the built-in WebClients\n const result = await client.views.open({\n trigger_id: shortcut.trigger_id,\n view: {\n type: \"modal\",\n title: {\n type: \"plain_text\",\n text: \"My Node-Red Demo App\"\n },\n blocks: [\n {\n \"type\": \"section\",\n \"text\": {\n \"type\": \"mrkdwn\",\n \"text\": \"You have a new request:\\n*<fakeLink.toEmployeeProfile.com|Fred Enriquez - New device request>*\"\n }\n },\n {\n \"type\": \"section\",\n \"fields\": [\n {\n \"type\": \"mrkdwn\",\n \"text\": \"*Type:*\\nComputer (laptop)\"\n },\n {\n \"type\": \"mrkdwn\",\n \"text\": \"*When:*\\nSubmitted Aut 10\"\n },\n {\n \"type\": \"mrkdwn\",\n \"text\": \"*Last Update:*\\nMar 10, 2015 (3 years, 5 months)\"\n },\n {\n \"type\": \"mrkdwn\",\n \"text\": \"*Reason:*\\nAll vowel keys aren't working.\"\n },\n {\n \"type\": \"mrkdwn\",\n \"text\": \"*Specs:*\\n\\\"Cheetah Pro 15\\\" - Fast, really fast\\\"\"\n }\n ]\n },\n {\n \"type\": \"actions\",\n \"elements\": [\n {\n \"type\": \"button\",\n \"text\": {\n \"type\": \"plain_text\",\n \"emoji\": true,\n \"text\": \"Approve\"\n },\n \"style\": \"primary\",\n \"value\": \"drink_approve\"\n },\n {\n \"type\": \"button\",\n \"text\": {\n \"type\": \"plain_text\",\n \"emoji\": true,\n \"text\": \"Deny\"\n },\n \"style\": \"danger\",\n \"value\": \"drink_deny\"\n }\n ]\n }\n ]\n }\n });\n\n }\n\n})\n\nmsg.SlackBolt.shortcuts.push({\n 'id': 'open_modal',\n 'callback':\n async ({ shortcut, ack, client, logger }) => {\n // Acknowledge shortcut request\n await ack();\n\n // Call the views.open method using one of the built-in WebClients\n const result = await client.views.open({\n trigger_id: shortcut.trigger_id,\n view: {\n type: \"modal\",\n title: {\n type: \"plain_text\",\n text: \"My Node-Red Demo App\"\n },\n close: {\n type: \"plain_text\",\n text: \"Close\"\n },\n blocks: [\n {\n type: \"section\",\n text: {\n type: \"mrkdwn\",\n text: \"About the simplest modal you could conceive of :smile:\\n\\nMaybe <https://api.slack.com/reference/block-kit/interactive-components|*make the modal interactive*> or <https://api.slack.com/surfaces/modals/using#modifying|*learn more advanced modal use cases*>.\"\n }\n },\n {\n type: \"context\",\n elements: [\n {\n type: \"mrkdwn\",\n text: \"Psssst this modal was designed using <https://api.slack.com/tools/block-kit-builder|*Block Kit Builder*>\"\n }\n ]\n }\n ]\n }\n });\n\n }\n\n})\n\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":620,"wires":[["a8f863a194453f25"]]},{"id":"66d82a9b2adba28f","type":"inject","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"Register Slack Actions and Events (once)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":620,"wires":[["a1af82db52869929"]]},{"id":"2c5427b594cdc27d","type":"debug","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1400,"y":600,"wires":[]},{"id":"b4ccc9f550d6192e","type":"switch","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"listener","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"button_click","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1160,"y":700,"wires":[["2c5427b594cdc27d"],["96f668735a340977"]]},{"id":"96f668735a340977","type":"debug","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"debug 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1400,"y":780,"wires":[]},{"id":"0be1a3a745d4345b","type":"slack-bolt-registry","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"Slack Registration","client":"a2eb2e51b1167936","x":810,"y":700,"wires":[["b4ccc9f550d6192e"]]},{"id":"a8f863a194453f25","type":"function","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"Events","func":"\n\nmsg.SlackBolt.events.push(\n {\n 'id': 'app_mention',\n 'callback':\n async ({ event, context, client, say }) => {\n try {\n const response = await say({\n blocks: [\n {\n type: 'section',\n text: {\n type: 'mrkdwn',\n text: `Thanks for the mention <@${event.user}>! Here's a button`,\n },\n accessory: {\n type: 'button',\n text: {\n type: 'plain_text',\n text: 'Approve me',\n emoji: true,\n },\n value: 'button_click',\n action_id: 'button_click',\n },\n },\n ],\n });\n } catch (error) {\n console.error(error);\n }\n }\n }\n);\n\n\n\nmsg.SlackBolt.actions.push(\n {\n 'id': 'button_click',\n 'callback':\n async ({ body, ack, say }) => {\n // Acknowledge the action\n await ack();\n return await say(`<@${body.user.id}> clicked the button`);\n\n }\n }\n);\n\n\n\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":700,"wires":[["0be1a3a745d4345b"]]},{"id":"3701e2672d1605c0","type":"inject","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"Text via payload","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"xxxx","v":" test23","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello World!12","payloadType":"str","x":340,"y":400,"wires":[["9326c16c34564ce9"]]},{"id":"ada60a61dc4363ca","type":"debug","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1160,"y":440,"wires":[]},{"id":"abd1fa9196265fd6","type":"inject","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"Block Message","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"blocks","payload":"[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"Pick a date for me to remind you\"},\"accessory\":{\"type\":\"datepicker\",\"action_id\":\"datepicker_remind\",\"initial_date\":\"2019-04-28\",\"placeholder\":{\"type\":\"plain_text\",\"text\":\"Select a date\"}}}]","payloadType":"json","x":340,"y":500,"wires":[["9326c16c34564ce9"]]},{"id":"e1bae9dec89865d5","type":"inject","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"load via context","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":340,"y":300,"wires":[["222f70122d1d13d3"]]},{"id":"222f70122d1d13d3","type":"change","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"","rules":[{"t":"set","p":"slackFlowMessage","pt":"flow","to":"send a good flow message","tot":"str"},{"t":"set","p":"slackGlobalMessage","pt":"global","to":"send a good global message","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":300,"wires":[["9326c16c34564ce9"]]},{"id":"85f483cbc0729943","type":"comment","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"flow.slackFlowMessage and global.slackGlobalMessage","info":"","x":830,"y":240,"wires":[]},{"id":"9326c16c34564ce9","type":"slack-bolt-message","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"","client":"a2eb2e51b1167936","channel":"#main","blocks":"","property":"payload","propertyType":"msg","propertySendType":"text","text":"","attachments":"","x":840,"y":460,"wires":[["ada60a61dc4363ca"]]},{"id":"509fc660e5a7454f","type":"catch","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"","scope":"group","uncaught":false,"x":270,"y":840,"wires":[["b9b5a6a13cde4552"]]},{"id":"b9b5a6a13cde4552","type":"debug","z":"1fd29692524d1ecb","g":"9abaac9bbddc9bce","name":"Group Error - Slack Bolt","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":840,"wires":[]},{"id":"a2eb2e51b1167936","type":"slack-bolt-app","name":"Demo-app","token":"xoxb-6273178474546-6296269126880-ECspr3jlq6Hk6QdxtvuvJBsy","signingSecret":"799dfcf596754ed8a6692c5dc1e7e7d4","socketMode":true,"port":"3000","appToken":"xapp-1-A06814CKD51-6366200613638-e1cf3e87beb6956b5c5e9d8ed9e8421da4b42e4fbe5a6ab9493e6c553b26052a"}]
```
[Slack Bolt Integration](https://flows.nodered.org/flow/368f36cbacfeba00b253086438f9a74d)
</details>
<br /><br />

Expand All @@ -269,7 +268,7 @@ see `/examples/example.json`

## Dependencies

Node version > 18
Node version >= 18.0.0

## Developing Nodes

Expand Down
16 changes: 3 additions & 13 deletions examples/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"id": "1fd29692524d1ecb",
"type": "tab",
"label": "Gateway",
"label": "Slack Bolt",
"disabled": false,
"info": "",
"env": []
Expand Down Expand Up @@ -129,7 +129,7 @@
"z": "1fd29692524d1ecb",
"g": "9abaac9bbddc9bce",
"name": "Slack Registration",
"client": "a2eb2e51b1167936",
"client": "",
"x": 810,
"y": 700,
"wires": [["b4ccc9f550d6192e"]]
Expand Down Expand Up @@ -272,7 +272,7 @@
"z": "1fd29692524d1ecb",
"g": "9abaac9bbddc9bce",
"name": "",
"client": "a2eb2e51b1167936",
"client": "",
"channel": "#main",
"blocks": "",
"property": "payload",
Expand Down Expand Up @@ -313,15 +313,5 @@
"x": 530,
"y": 840,
"wires": []
},
{
"id": "a2eb2e51b1167936",
"type": "slack-bolt-app",
"name": "Demo-app",
"token": "xoxb-6273178474546-6296269126880-ECspr3jlq6Hk6QdxtvuvJBsy",
"signingSecret": "799dfcf596754ed8a6692c5dc1e7e7d4",
"socketMode": true,
"port": "3000",
"appToken": "xapp-1-A06814CKD51-6366200613638-e1cf3e87beb6956b5c5e9d8ed9e8421da4b42e4fbe5a6ab9493e6c553b26052a"
}
]
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@headless-architecture/node-red-contrib-slack-bolt",
"version": "1.1.1",
"version": "1.1.2",
"description": "Control your Slack App via Node-Red! Slack Bolt integration.",
"keywords": [
"Slack",
Expand Down Expand Up @@ -28,7 +28,12 @@
"type": "git",
"url": "git+https://github.com/fishme/node-red-contrib-slack-bolt.git"
},
"engines": {
"node": ">=18.0.0",
"npm": ">=8.19.4"
},
"node-red": {
"version": ">=3.0.0",
"nodes": {
"slack-bolt-registry": "./dist/nodes/slack-bolt-registry/slack-bolt-registry.js",
"slack-bolt-message": "./dist/nodes/slack-bolt-message/slack-bolt-message.js",
Expand Down

0 comments on commit e85562d

Please sign in to comment.