npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

n8n-nodes-no-pain-no-gain-package

v1.1.6

Published

No Pain No Gain node for n8n

Downloads

21

Readme

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

  • 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