Skip to content

biliboss/my-n8n-utils-scripts

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

n8n Utility Scripts

A personal collection of useful JavaScript code snippets that I use within my n8n workflows.

🌟 What's Inside

This repository contains JavaScript code snippets that can be added to Code nodes in n8n workflows.

πŸš€ How to Use These Scripts

  1. Copy the script you need
  2. In your n8n workflow, add a "Code" node and update the script with your relevant data
  3. Connect the node to your workflow

πŸ“š Script Collection

LangFuse Integration

Track LLM interactions in your workflows with proper trace flushing.

This utility script integrates Langfuse observability into n8n workflows, enabling comprehensive tracking of LLM interactions. The script provides:

  • Automatic session and trace ID generation using UUID
  • Chat session tracking with timestamps and user identifiers
  • Detailed LLM interaction logging with input/output capture
  • Generation event recording with model metadata
  • Explicit flush mechanism to ensure data transmission

The script is designed to work within n8n Code nodes and integrates with chat workflows, capturing conversation context from preceding nodes. It leverages the langfuse-langchain library for standardized observability while maintaining a lightweight implementation.

Use this script to monitor LLM performance, track user interactions, and gather analytics for improving conversational AI applications built in n8n. It's not the best solution, but it works for me.

Requirements

  • A LangFuse instance (either cloud-hosted or self-hosted)
  • Install the langfuse-langchain package in your n8n instance:
    npm install langfuse-langchain

Setup

  1. Create a LangFuse account/project or set up a self-hosted instance
  2. Obtain your LangFuse API keys (public and secret)
  3. In your n8n Code node, configure the LangFuse client with:
    • Your public key
    • Your secret key
    • LangFuse host URL (defaults to cloud instance if not specified)

Usage

Add the script to a Code node in your workflow, particularly after LLM interaction nodes. Configure the client with your API keys and customize session identifiers as needed. The script will automatically capture conversation context and log interactions to your LangFuse dashboard.

πŸ“‹ Notes

  • These scripts are provided as-is and may need adjustments for your specific workflows
  • Always test scripts in a safe environment before using in production
  • Feel free to modify them to fit your needs

πŸ”§ Contributing

If you have improvements or additional scripts to share, pull requests are welcome!

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


⭐ If you find these scripts helpful, please star this repository!

About

scripts that I use to automate workflows and connect systems.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%