turbot / flowpipe-mod-slack

Slack pipeline library for the Flowpipe cloud scripting engine. Automation and workflows to connect Slack to the people, systems and data that matters.
https://hub.flowpipe.io/mods/turbot/slack
Apache License 2.0
2 stars 1 forks source link

Add Remove Members from Channel #29

Open oaulicino opened 3 weeks ago

oaulicino commented 3 weeks ago

Is your feature request related to a problem? Please describe. Currently there is no method of removing users invited to channels. I am able to invite members, but I would like to be able to remove some of them that are no longer necessary. Right now, I am manually removing the ones I know, but with larger numbers of members, it is really hard to keep up.

Describe the solution you'd like Use the https://api.slack.com/methods/conversations.kick API endpoint to create a similar pipeline we currently have to invite members.

Describe alternatives you've considered Right now, I have no alternatives other than manually removing individuals I know of.

Additional context No additional context at the moment.

khushboo9024 commented 4 days ago

Hi @oaulicino,

Apologies for the delayed response. We have raised a PR for the kick_users_from_channel pipeline. Could you please test it on your end and let us know if it works for you?

Thank you!

oaulicino commented 1 day ago

Hey @khushboo9024 for some reason I am getting an authentication error. This does not happen when I use other pipelines:

Outputs: errors = [ { "error": { "detail": "not_authed", "instance": "fperr_ct4bdh0jgibkjg4fccrg", "status": 461, "title": "User Defined", "type": "error_user_defined" }, "pipeline": "slack.pipeline.kick_users_from_channel", "pipeline_execution_id": "pexec_ct4bdgojgibkjg4fccig", "step": "http.remove_user_from_channel", "step_execution_id": "sexec_ct4bdgojgibkjg4fccpg" } ]

Error: User Defined not_authed

oaulicino commented 18 hours ago

OK, looks like I was able to fix the authentication issue, but I am now getting this error when trying to use the pipeline:

`Outputs: errors = [ { "error": { "detail": "missing_scope", "instance": "fperr_ct4u588jgibkcsvep9rg", "status": 461, "title": "User Defined", "type": "error_user_defined" }, "pipeline": "slack.pipeline.kick_users_from_channel", "pipeline_execution_id": "pexec_ct4u588jgibkcsvep9ig", "step": "http.remove_user_from_channel", "step_execution_id": "sexec_ct4u588jgibkcsvep9pg" } ]

Error: User Defined missing_scope`

I am using a query to retrieve a simple list of ids to remove from the channel:

` pipeline "my_pipeline_remove_users_from_monitoring_compliance_channel" {

step "query" "users_in_monitoring_compliance_channel" {
  database    = "postgres://steampipe@localhost:9193/steampipe"
  sql = <<-EOQ
    select 
      member_id 
    from 
      slack_conversation_member 
    where 
      conversation_id = 'C07PZ062VJR' and
      member_id = 'U02V0P4TXEG'
      -- member_id != 'U032TBXDPU6'
  EOQ
}

step "pipeline" "remove_users_from_channel" {
  pipeline = slack.pipeline.kick_users_from_channel  
  depends_on = [step.query.users_in_monitoring_compliance_channel]
  for_each   = { for row in step.query.users_in_monitoring_compliance_channel.rows : row.member_id => row }
  args = {
    #cred = "my_slack"
    #is_private = false
    channel = "C07PZ062VJR"      
    users = [
              "${each.key}",
            ]
  }
}

}`

What am I missing here?