Skip to content

Commit

Permalink
feat(Slack Node): Add support for getting the profile of a user (#7829)
Browse files Browse the repository at this point in the history
Github issue / Community forum post (link here to close automatically):
#7825

This adds support for getting a users profile which returns different
data to the existing user info (Get) operation we have.

Test Workflow
```
{
  "meta": {
    "instanceId": "8c8c5237b8e37b006a7adce87f4369350c58e41f3ca9de16196d3197f69eabcd"
  },
  "nodes": [
    {
      "parameters": {},
      "id": "69f437fb-9962-4d51-91bb-0ef4b3827e49",
      "name": "When clicking \"Execute Workflow\"",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        880,
        380
      ]
    },
    {
      "parameters": {
        "resource": "user",
        "user": {
          "__rl": true,
          "value": "U035F563JSW",
          "mode": "list",
          "cachedResultName": "jonathan"
        }
      },
      "id": "826828db-598b-40c7-b085-5b01f2c10d73",
      "name": "Get Info",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.1,
      "position": [
        1120,
        260
      ],
      "credentials": {
        "slackApi": {
          "id": "E4DnXIyNuRxi5GSz",
          "name": "Slack account"
        }
      }
    },
    {
      "parameters": {
        "resource": "user",
        "operation": "getProfile",
        "user": {
          "__rl": true,
          "value": "U035F563JSW",
          "mode": "list",
          "cachedResultName": "jonathan"
        }
      },
      "id": "9de02c3f-e17c-4a32-a64e-11aaa0b36120",
      "name": "Get Profile",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.1,
      "position": [
        1120,
        440
      ],
      "credentials": {
        "slackApi": {
          "id": "E4DnXIyNuRxi5GSz",
          "name": "Slack account"
        }
      }
    }
  ],
  "connections": {
    "When clicking \"Execute Workflow\"": {
      "main": [
        [
          {
            "node": "Get Info",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Profile",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {}
}
```
  • Loading branch information
Joffcom authored Nov 29, 2023
1 parent 72852a6 commit 90bb6ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/nodes-base/nodes/Slack/V2/SlackV2.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,11 @@ export class SlackV2 implements INodeType {
qs.user = this.getNodeParameter('user', i, undefined, { extractValue: true }) as string;
responseData = await slackApiRequest.call(this, 'GET', '/users.getPresence', {}, qs);
}
if (operation === 'getProfile') {
qs.user = this.getNodeParameter('user', i, undefined, { extractValue: true }) as string;
responseData = await slackApiRequest.call(this, 'GET', '/users.profile.get', {}, qs);
responseData = responseData.profile;
}
if (operation === 'updateProfile') {
const options = this.getNodeParameter('options', i);
const timezone = this.getTimezone();
Expand Down
8 changes: 7 additions & 1 deletion packages/nodes-base/nodes/Slack/V2/UserDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export const userOperations: INodeProperties[] = [
description: 'Get a list of many users',
action: 'Get many users',
},
{
name: "Get User's Profile",
value: 'getProfile',
description: "Get a user's",
action: "Get a user's profile",
},
{
name: "Get User's Status",
value: 'getPresence',
Expand Down Expand Up @@ -54,7 +60,7 @@ export const userFields: INodeProperties[] = [
description: 'The ID of the user to get information about',
displayOptions: {
show: {
operation: ['info'],
operation: ['info', 'getProfile'],
resource: ['user'],
},
},
Expand Down

0 comments on commit 90bb6ba

Please sign in to comment.