Skip to content

diegogurpegui/n8n-nodes-simplexity

Repository files navigation

SimpleXity (a SimpleX Chat n8n Node)

This project provides a n8n node for integrating with SimpleX Chat, allowing you to trigger workflows on incoming messages and send messages to contacts.

Features

  • SimpleXity Trigger Node: Listens for incoming SimpleX messages and triggers workflows
  • SimpleXity Action Node: Sends messages to SimpleX contacts
  • Credential Management: Secure storage of SimpleX connection settings

Requirements

A SimpleX Chat CLI should be running.

Option 1: Packaged Docker (recommended)

This repository contains a Dockerfile and docker-compose.yml ready to run the SimpleX Chat Cli.
Check the corresponding README.md file

Option 2: Manual

For more information: https://github.com/simplex-chat/simplex-chat/blob/stable/docs/CLI.md

Installation

You can follow the standard installation guide for n8n nodes.

Steps for installing locally:

  1. Clone this repository
  2. Install dependencies:
    npm install
  3. Build the project:
    npm run build
  4. Copy the dist folder to your n8n custom nodes directory

Configuration

Credentials

Create a SimpleX configuration credential to connect to the SimpleX CLI.
You can setup the following fields:

  • Host: SimpleX Client host (default: localhost)
  • Port: SimpleX Client port (default: 5225)
  • Bot Address: Optional SimpleX bot address (will be created if not provided)
  • File Server Port: Port for the HTTP file server (default 8090). When set, fetches received files over HTTP when not on local filesystem. Set to 0 to disable.

Node Operations

SimpleXity Trigger Node

The SimpleXity Trigger node listens for incoming SimpleX messages and can be configured to trigger on:

  • Text Messages (newChatItems): New chat items with text content. Only processes direct messages with text content.
  • Contact Connected (contactConnected): When a new contact connects (currently not implemented in code)
  • File Received (rcvFileComplete): When a file is received. The code handles rcvFileAccepted events and automatically accepts audio files (ogg, m4a, mp3, wav, opus, aac)

SimpleXity Action Node

The SimpleXity Action node allows you to send messages to SimpleX contacts:

  • Contact ID: The numeric ID of the contact to send the message to
  • Message: The text message to send

Data Structure

Trigger Output

The SimpleXity Trigger node outputs data based on the message type:

For newChatItems messages:

{
  "messageType": "newChatItems",
  "timestamp": "2024-01-01T12:00:00.000Z",
  "messages": [
    {
      "chatInfo": "<T.ChatInfo>",
      "chatItem": "<T.ChatItem>",
      "message": "string"
    }
  ]
}

For rcvFileAccepted messages:

{
  "messageType": "rcvFileAccepted",
  "timestamp": "2024-01-01T12:00:00.000Z",
  "files": [
    {
      "chatInfo": "<T.ChatInfo>",
      "chatItem": "<T.ChatItem>",
      "file": "<T.CIFile>"
    }
  ]
}

Types used: T.ChatInfo, T.ChatItem, T.CIFile, T.CIMeta from @simplex-chat/types

Action Output

The SimpleXity Action node returns:

{
  "success": true,
  "contactId": 123,
  "result": [
    {
      "infoType": "string",
      "itemChatDir": "string"
    }
  ],
  "timestamp": "2024-01-01T12:00:00.000Z"
}

Or on error:

{
  "success": false,
  "error": "string"
}

Development

Project Structure

├── credentials/
│   └── SimplexityApi.credentials.ts     # Credential definition
├── nodes/
│   └── Simplexity/
│       ├── Simplexity.node.ts           # Action node implementation
│       ├── Simplexity.node.json         # Action node configuration
│       ├── SimplexityTrigger.node.ts    # Trigger node implementation
│       ├── SimplexityTrigger.node.json  # Trigger node configuration
│       ├── simplexity.svg               # Node icon
│       └── simplexity.png               # Node icon (PNG)
├── utils/
│   └── simplex-chat-cli/                # Docker setup for SimpleX CLI
│       ├── Dockerfile
│       ├── docker-compose.yml
│       └── README.md
├── package.json                         # Project dependencies
├── package-lock.json                    # Dependency lock file
├── tsconfig.json                        # TypeScript configuration
├── tsconfig.bot-test.json              # TypeScript config for bot tests
├── gulpfile.js                          # Build configuration
├── eslint.config.mts                    # ESLint configuration
├── .prettierrc                          # Prettier configuration
├── logger.ts                            # Logging utility
├── bot-test.ts                          # Test file
└── index.js                             # Entry point

Building

npm run build

License

MIT

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Support

For issues and questions, please open an issue on GitHub.

About

n8n nodes for SimpleX Chat integration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors