n8n-nodes-no-pain-no-gain-package
v1.1.6
Published
No Pain No Gain node for n8n
Downloads
21
Keywords
Readme
About this package
This package containes 2 nodes for n8n.
Discord Node
The Discord node gets all unique users and messages from a discord channel. The node requires a bot token and a channel ID. The node has a limit field that limits the number of messages that are returned. The node has a bolean field that returns all unique users.
Cosmos DB node
The Cosmos DB node inserts data into the Cosmos DB database. The node requires a connection string, a partition key, a database id and a container id. The node has a Json field that needs to be filled with the input from a node.
For users that want to use the package in n8n
Install n8n with:
npm install n8n -g
Start n8n with:
n8n start
Open n8n in browser with:
http://localhost:5678/
Login with your credentials
Import the package with:
Settings -> Community nodes -> Install -> Paste the following link: n8n-nodes-no-pain-no-gain-package
Use the Discord node in your workflow:
Click on add node -> search for "Discord Messages and unique users" -> drag and drop the node to the workflow
Use the Cosmos DB node in your workflow:
Click on add node -> search for "Azure Cosmos DB" -> drag and drop the node to the workflow
To update the package
Start n8n with:
n8n start
Open n8n in browser with:
http://localhost:5678/
Login with your credentials.
Update the package with:
Settings -> Community nodes -> Update
To configure the Discord node
Create a discord server.
Create a discord bot.
Add the bot to the server.
Copy the bot token.
Paste the bot token in the node configuration.
right click on the server channel -> copy id (dev mode needs to be turned on in settings->advanced->developer mode).
Paste the channel id in the node configuration.
Place a number inside the limit field (the number of messages you want to get)
Select if you want to get all unique users.
Execute the node.
Discord node output
- The ouput of the Discord node is inside the JSONOuput/DiscordNode.json file.
- The first output is the unique users and the second output is the messages.
- For the messages type 7 is a welcome message, type 0 is a normal message and type 19 is a reply.
- If the message has an image it will add the attachments property to the message.
To configure the Azure Cosmos DB node
Create a cosmos db account (NoSQL API).
In the sidebar on the left go to Container -> Settings.
Create a database (if you don't have one) by clicking on new Database or launch quick start.
Create a container (if you don't have one) by clicking on new Container.
In the sidebar on the left go to Settings -> Keys and copy one of the 2 connection strings and paste the connection string in the node configuration.
- In the sidebar on the left go to Container -> browse -> go to your container inside your database and click on settings. Paste the partition key in the node configuration.
- In the sidebar on the left go to Container -> browse.
- From Container -> browse paste the database id in the node configuration.
- From Container -> browse paste the container id in the node configuration.
- The Json from the input needs to be inside Curly Brackets as shown in example 1, otherwise it will not work. Make sure to delete any other type of brackets inside as shown in example 2.
- Example 1:
- Example 2:
- Results in Cosmos DB:
- Execute the node.
CosmosDB node output
- The ouput of the Cosmos node is inside the JSONOuput/CosmosdbMessage and JSONOuput/Cosmosdbusers files.
- The CosmosdbMessage file shows the output when adding a message to the database when using the input from the discord node.
- The Cosmosdbusers file shows the output when adding all unique users to the database when using the input from the discord node.
JSON workflow with the Discord node as input and the Cosmos DB node execute as output
For developers to test the node locally
npm run build in the root directory of the project.
npm run build
npm link in the root directory of the project.
npm link
go to the custom folder where .n8n is installed.
cd C:\Users\<name>\.n8n\custom
npm link the package.
npm link n8n-nodes-no-pain-no-gain-package
Start n8n with:
n8n start
Open n8n in browser with:
http://localhost:5678/
Login with your credentials.
Use the nodes in your workflow:
Click on add node -> search for "Discord Messages and unique users" or "Azure Cosmos DB" -> drag and drop the node to the workflow
For developers to update the package
For every new commit add new package version. For every package update change the version in the package.json file and run the following commands:
npm i
npm login
npm publish
Flowcharts
Discord node
Cosmos DB node
Limitations, bugs or issues
- The Discord node only works for one channel at a time.
- The Cosmos DB node only works for one database and one container at a time.
- It is not possible in the Cosmos DB node to drag items from the schema to the node configuration.
- In the Cosmos DB node it is not (yet) possible to create a new database or container with the node.
- In the Discord node it is not (yet) possible to remove messages that are welcome messages.
- int value should be less than or equal to 100 (Discord node) when the limit is higher than 100 you get an error.
For the Discord node:
- An empty channel ID gives the error: "Channel ID" is required.
- An unvalid channel ID gives the error: ERROR: 404 - {"message":"Unknown Channel","code":10003}
- An empty bot token gives the error: "Authorization Bot Token" is required.
- An unvalid bot token gives the error: ERROR: 401 - {"message":"401: Unauthorized","code":0}
- An empty limit gives the error: value " " is not int.
For the Cosmos DB node:
- An empty connection string gives the error: "Connection String" is required.
- An empty partition key gives the error: "Partition Key" is required.
- An empty database id gives the error: "Database ID" is required.
- An empty container id gives the error: "Container ID" is required.
- An unvalid connection string gives the error: Could not parse the provided connection string.
- An unvalid Database id gives the error: The resource you are requesting could not be found.
- An unvalid Container id gives the error: The resource you are requesting could not be found.
- An item needs to be inside Curly Brackets.
Tests
The test that were done for the Discord node:
- A limit higher than 100 gives the error: int value should be less than or equal to 100.
- For the Discord node a discord server was made with a channel and a bot. The bot was added to the channel and the bot token and channel ID were used in the node configuration. The node was executed and the output was checked. The output was correct.
- For the Discord node multiple test users were created and messages were sent in the channel. The node was executed and the output was checked. The output was correct.
The test that were done for the Cosmos node:
- Multiple databases and containers were created and the node was executed. The output was checked. The output was correct.
- For securty reasons the connection string was changed with the url. An error occured.
Sources
- Github Copilot (for code completion)
- https://www.npmjs.com/package/@azure/cosmos (for Cosmos DB)
- https://docs.n8n.io/integrations/creating-nodes/build/declarative-style-node/ (for creating the node)
- https://github.com/n8n-io/n8n-nodes-starter (for starter example)
- Link to package: https://www.npmjs.com/package/n8n-nodes-no-pain-no-gain-package?activeTab=readme