Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Add users to Cloudron - N8N

    N8N
    3
    6
    169
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Sam_uk
      Sam_uk last edited by

      So I made a N8N flow that takes user-submitted email addresses from a form.io form.

      I can create users and generate the signup emails, however, I'm stuck at adding them to groups

      My flow is below, can anyone shed any light?

      {
        "name": "Add to groups",
        "nodes": [
          {
            "parameters": {},
            "name": "Start",
            "type": "n8n-nodes-base.start",
            "typeVersion": 1,
            "position": [
              250,
              300
            ]
          },
          {
            "parameters": {
              "projectId": "6168084eb35ff178dd907fd7",
              "formId": "61680a64e1092633bce1b86c",
              "events": [
                "create"
              ],
              "simple": false
            },
            "name": "Form.io Trigger",
            "type": "n8n-nodes-base.formIoTrigger",
            "typeVersion": 1,
            "position": [
              450,
              450
            ],
            "webhookId": "c923b1b2-2794-44b3-9dce-a3c3936b06d1",
            "credentials": {
              "formIoApi": {
                "id": "3",
                "name": "Form.io account 2"
              }
            }
          },
          {
            "parameters": {
              "requestMethod": "POST",
              "url": "=https://my.cloudron-url.org/api/v1/users/{{$node[\"create user\"].json[\"email\"][\"id\"]}}/create_invite?access_token=xxxxkeyfromcloudronxxxxxxx&_method=post",
              "options": {}
            },
            "name": "Create invite",
            "type": "n8n-nodes-base.httpRequest",
            "typeVersion": 1,
            "position": [
              870,
              420
            ]
          },
          {
            "parameters": {
              "requestMethod": "POST",
              "url": "=https://my.cloudron-url.org/api/v1/users/{{$node[\"create user\"].json[\"email\"][\"id\"]}}/send_invite?access_token=xxxxkeyfromcloudronxxxxxxx&_method=post",
              "options": {}
            },
            "name": "send invite",
            "type": "n8n-nodes-base.httpRequest",
            "typeVersion": 1,
            "position": [
              1070,
              420
            ]
          },
          {
            "parameters": {
              "requestMethod": "POST",
              "url": "=https://my.cloudron-url.org/api/v1/users/?access_token=xxxxkeyfromcloudronxxxxxxx&_method=post",
              "responseFormat": "string",
              "dataPropertyName": "email",
              "options": {},
              "bodyParametersUi": {
                "parameter": [
                  {
                    "name": "=email",
                    "value": "={{$node[\"Form.io Trigger\"].json[\"data\"][\"email\"]}}"
                  }
                ]
              }
            },
            "name": "create user",
            "type": "n8n-nodes-base.httpRequest",
            "typeVersion": 1,
            "position": [
              650,
              450
            ]
          },
          {
            "parameters": {
              "requestMethod": "PUT",
              "url": "=https://my.cloudron-url.org/api/v1/users/{{$node[\"create user\"].json[\"email\"][\"id\"]}}/groups?access_token=xxxxkeyfromcloudronxxxxxxx",
              "responseFormat": "string",
              "dataPropertyName": "=groups",
              "jsonParameters": true,
              "options": {},
              "bodyParametersJson": "={\n\"groupIds\": [ ]\n}",
              "queryParametersJson": "=users"
            },
            "name": "add to /users",
            "type": "n8n-nodes-base.httpRequest",
            "typeVersion": 1,
            "position": [
              1250,
              410
            ]
          }
        ],
        "connections": {
          "Form.io Trigger": {
            "main": [
              [
                {
                  "node": "create user",
                  "type": "main",
                  "index": 0
                }
              ]
            ]
          },
          "Create invite": {
            "main": [
              [
                {
                  "node": "send invite",
                  "type": "main",
                  "index": 0
                }
              ]
            ]
          },
          "send invite": {
            "main": [
              [
                {
                  "node": "add to /users",
                  "type": "main",
                  "index": 0
                }
              ]
            ]
          },
          "create user": {
            "main": [
              [
                {
                  "node": "Create invite",
                  "type": "main",
                  "index": 0
                }
              ]
            ]
          }
        },
        "active": true,
        "settings": {},
        "id": 7
      }
      
      Sam_uk andreasdueren 2 Replies Last reply Reply Quote 2
      • Sam_uk
        Sam_uk @Sam_uk last edited by

        Just making sure groupIds= groupname in Cloudron?

        The default 'user' group ID would be 'user' for example?

        girish 1 Reply Last reply Reply Quote 0
        • girish
          girish Staff @Sam_uk last edited by girish

          @sam_uk I guess you are looking for the API call to add a user to a group ?

          So, you make a PUT request on /api/v1/users/:userId/groups with groupIds in the body. groupIds is an array of group ids.

          Group ids are not the same as group name. You have to get the ids via the GET /api/v1/groups call. This is because group names can be changed.

          Sam_uk 1 Reply Last reply Reply Quote 2
          • Sam_uk
            Sam_uk @girish last edited by

            @girish said in Add users to Cloudron - N8N:

            /api/v1/groups

            Thanks, it hangs with

            {
              "groupIds": [
                "gid-2155eeef-b8bd-45f5-9473-xxx"
              ]
            }
            

            But that's progress! I'll investigate further tomorrow.

            1 Reply Last reply Reply Quote 1
            • girish
              girish Staff last edited by

              You should get something like this:

              $ curl 'https://my.domain.com/api/v1/groups?access_token=xxx'
              {
                "groups": [
                  {
                    "id": "gid-02fc23f0-c0df-4276-a54a-e3958b53ffd8",
                    "name": "people",
                    "source": "",
                    "userIds": [
                      "uid-0a7dc777-c010-459e-a8db-ab853ea4f742"
                    ]
                  }
                ]
              }
              
              1 Reply Last reply Reply Quote 1
              • andreasdueren
                andreasdueren @Sam_uk last edited by

                @Sam_uk Hi Sam I would like to build something similar. Did you get it to work properly?

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post
                Powered by NodeBB