slackapi / deno-slack-sdk

SDK for building Run on Slack apps using Deno
https://api.slack.com/automation
MIT License
162 stars 27 forks source link

[QUERY] Creating 'user select' field in workflow form #310

Closed mirianbatista closed 5 months ago

mirianbatista commented 5 months ago

Question

Hello, I am trying to create a user select field in a workflow form, but I am having difficulties. I tried to make it similar to this one (ref):

manager_ids: {
  type: SchemaTypes.array,
  description: "Search all people",
  title: "Select Channel Manager(s)",
  items: { type: SlackTypes.user_id },
},

But it didn't work out. I tried to make it similar to this one as well (ref, ref), but once again, no success:

Blocks.Input({ label: 'Assign user', blockId: 'taskAssignUser' }).element(
  Elements.UserSelect({
    actionId: 'taskAssignUser',
  }).initialUser(currentUser),
),

I also tried searching for examples/references by looking up user_select/userSelect/user select in this repository and in deno-slack-api, but I really can't figure it out, can someone help me with an example?

Context

What I am trying to do is this field that shows the users from slack: image I am following the readme to create the function, workflow and trigger, and for the simpler fields the documentation works perfectly, but for this type of field, I couldn't find anything.

Environment

    "deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@2.9.0/",
    "deno-slack-api/": "https://deno.land/x/deno_slack_api@2.3.2/"

    deno 1.42.3 (release, x86_64-unknown-linux-gnu)
    v8 12.3.219.9
    typescript 5.4.3

    #29~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

WilliamBergamin commented 5 months ago

Hi @mirianbatista thanks for writing in 💯

Have you taken a look at our deno-issue-submission sample project, it is a good example of using the open form slack function

The following should open a form with a user dropdown

const inputForm = SubmitIssueWorkflow.addStep(
  Schema.slack.functions.OpenForm,
  {
    title: "Submit a user",
    interactivity: SubmitIssueWorkflow.inputs.interactivity,
    submit_label: "Submit",
    fields: {
      elements: [{
        name: "user_id",
        title: "Select a user",
        type: Schema.slack.types.user_id,
      }],
      required: ["user_id"],
    },
  },
);

Let me know if this helps

mirianbatista commented 5 months ago

amazing!!!!! @WilliamBergamin, thank you so much for sharing this example, it was exactly what I needed!!