n8n

Knwler can easily be integrated into n8n but you need to ensure the following:

The workflow (see image) would typically entail:

{
  "statements": [
    {
      "statement": "UNWIND $entities AS e MERGE (n:Entity {id: e.id}) SET n.name = e.name, n.type = e.type, n.description = e.description, n.community_id = e.community_id",
      "parameters": {
        "entities": {{ JSON.stringify($json.data.entities) }}
      }
    },
    {
      "statement": "UNWIND $relations AS r MERGE (a:Entity {name: r.source}) MERGE (b:Entity {name: r.target}) MERGE (a)-[rel:RELATION {id: r.id}]->(b) SET rel.type = r.type, rel.description = r.description, rel.strength = r.strength, rel.source_type = r.source_type, rel.target_type = r.target_type",
      "parameters": {
        "relations": {{ JSON.stringify($json.data.relations) }}
      }
    }
  ]
}

n8n MacOS Service

On Mac OS you need to add /Users/<user>/.local/bin to the path. For example, to run n8n as a service you would put the plist below into ~/Library/LaunchAgents/com.<user>.n8n.plist and load/start the service with

launchctl load ~/Library/LaunchAgents/com.<user>.n8n.plist

To stop/unload the service:

launchctl unload ~/Library/LaunchAgents/com.<user>.n8n.plist

Checking the status with launchctl list | grep n8n and view logs with tail -f ~/n8n/logs/n8n.log or tail -f ~/n8n/logs/n8n.error.log

The import part is the path /Users/<user>/.local/bin where the pipx knwler command resides:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.<user>.n8n</string>

        <key>ProgramArguments</key>
        <array>
            <string>/Users/<user>/.nvm/versions/node/v22.16.0/bin/node</string>
            <string>/Users/<user>/.nvm/versions/node/v22.16.0/bin/n8n</string>
        </array>

        <key>EnvironmentVariables</key>
        <dict>
            <key>PATH</key>
            <string>
                /Users/<user>/.nvm/versions/node/v22.16.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/<user>/conda/bin:/Users/<user>/.local/bin</string>
            <key>DB_TYPE</key>
            <string>postgresdb</string>
            <key>DB_POSTGRESDB_HOST</key>
            <string>localhost</string>
            <key>DB_POSTGRESDB_PORT</key>
            <string>5432</string>
            <key>DB_POSTGRESDB_DATABASE</key>
            <string>n8n</string>
            <key>DB_POSTGRESDB_USER</key>
            <string><user></string>
            <key>DB_POSTGRESDB_PASSWORD</key>
            <string>som3-passw0rd</string>
            <key>N8N_PORT</key>
            <string>13000</string>
            <key>N8N_USER_FOLDER</key>
            <string>/Users/<user>/n8n</string>
            <key>N8N_CUSTOM_EXTENSIONS</key>
            <string>/Users/<user>/n8n/custom</string>
            <key>N8N_RESTRICT_FILE_ACCESS_TO</key>
            <string></string>
            <key>N8N_ALLOW_EXECUTE_COMMAND</key>
            <string>true</string>
            <key>NODES_EXCLUDE</key>
            <string>[]</string>
            <key>N8N_ENABLE_NODE_DEV</key>
            <string>true</string>
            <key>N8N_DIAGNOSTICS_ENABLED</key>
            <string>false</string>
            <key>EXECUTIONS_DATA_PRUNE</key>
            <string>true</string>
            <key>EXECUTIONS_DATA_MAX_AGE</key>
            <string>1</string>
            <key>EXECUTIONS_DATA_MAX_COUNT</key>
            <string>1</string>
        </dict>

        <key>RunAtLoad</key>
        <true />

        <key>KeepAlive</key>
        <true />

        <key>StandardOutPath</key>
        <string>/Users/<user>/n8n/logs/n8n.log</string>

        <key>StandardErrorPath</key>
        <string>/Users/<user>/n8n/logs/n8n.error.log</string>

        <key>WorkingDirectory</key>
        <string>/Users/<user>/n8n</string>
    </dict>
</plist>