1.1.6 • Published 6 months ago

n8n-nodes-no-pain-no-gain-package v1.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

About this package

Alt text

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

  1. Install n8n with:
    npm install n8n -g
  2. Start n8n with:
    n8n start 
  3. Open n8n in browser with:
    http://localhost:5678/
  4. Login with your credentials

  5. Import the package with:

    Settings -> Community nodes -> Install -> Paste the following link: n8n-nodes-no-pain-no-gain-package

  6. 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

  7. 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

  1. Start n8n with:
    n8n start 
  2. Open n8n in browser with:
    http://localhost:5678/
  3. Login with your credentials.

  4. Update the package with:

    Settings -> Community nodes -> Update

To configure the Discord node

  1. Create a discord server.

  2. Create a discord bot.

  3. Add the bot to the server.

  4. Copy the bot token.

Alt text

  1. Paste the bot token in the node configuration.

  2. right click on the server channel -> copy id (dev mode needs to be turned on in settings->advanced->developer mode).

Alt text

  1. Paste the channel id in the node configuration.

  2. Place a number inside the limit field (the number of messages you want to get)

  3. Select if you want to get all unique users.

  4. Execute the node.

Discord node output

  1. The ouput of the Discord node is inside the JSONOuput/DiscordNode.json file.
  2. The first output is the unique users and the second output is the messages.
  3. For the messages type 7 is a welcome message, type 0 is a normal message and type 19 is a reply.
  4. If the message has an image it will add the attachments property to the message.

To configure the Azure Cosmos DB node

  1. Create a cosmos db account (NoSQL API).

  2. In the sidebar on the left go to Container -> Settings.

Alt text

  1. Create a database (if you don't have one) by clicking on new Database or launch quick start.

  2. Create a container (if you don't have one) by clicking on new Container.

  3. 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.

Alt text

  1. 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.

Alt text

  1. In the sidebar on the left go to Container -> browse.

Alt text

  1. From Container -> browse paste the database id in the node configuration.

Alt text

  1. From Container -> browse paste the container id in the node configuration.

Alt text

  1. 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:

Alt text Alt text

  • Example 2:

Alt text

  • Results in Cosmos DB:

Alt text

  1. Execute the node.

CosmosDB node output

  1. The ouput of the Cosmos node is inside the JSONOuput/CosmosdbMessage and JSONOuput/Cosmosdbusers files.
  2. The CosmosdbMessage file shows the output when adding a message to the database when using the input from the discord node.
  3. 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

Alt text

For developers to test the node locally

  1. npm run build in the root directory of the project.
    npm run build
  2. npm link in the root directory of the project.
    npm link 
  3. go to the custom folder where .n8n is installed.
    cd C:\Users\<name>\.n8n\custom
  4. npm link the package.
    npm link n8n-nodes-no-pain-no-gain-package
  5. Start n8n with:
    n8n start 
  6. Open n8n in browser with:
    http://localhost:5678/
  7. Login with your credentials.

  8. 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:

  1. npm i

  2. npm login

  3. npm publish

Flowcharts

Discord node

Alt text

Cosmos DB node

Alt text

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

1.1.6

6 months ago

1.1.5

6 months ago

1.1.4

6 months ago

1.1.3

7 months ago

1.1.2

7 months ago

1.1.1

7 months ago

1.1.0

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago