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

[FEATURE REQUEST] Workflowbuilder support for `Schema.slack.types.blocks` #301

Closed mcsescott closed 5 months ago

mcsescott commented 6 months ago

Good afternoon! I am building a custom function, and trying to return some blocks. When trying to use Schema.slack.types.blocks as an output property, I am not seeing that as an output available in subsequent steps in the workflow.

Steps to reproduce:

  1. Build custom function (using the code below)
  2. Add the custom function to a workflow in Workflow Builder
  3. In a subsequent step (such as "Send a message to channel"), attempt to use that output variable

In this scenario, the output (variable) is not being shown as a variable to select in workflow steps.

Function definition:

import { DefineFunction, Schema, SlackFunction } from "deno-slack-sdk/mod.ts";

export const MyFunctionDef = DefineFunction({
  callback_id: "my_function_callback",
  source_file: "functions/my_function.ts",
  title: "Testing Custom Function",

  input_parameters: {
    properties: {
      theblocks: {
        type: Schema.types.string,
        title: "Block Kit blocks",
        description: "Insert your blocks here",
      },
    },

    required: ["theblocks"],
  },

  output_parameters: {
    properties: {
      out_blocks: {
        type: Schema.slack.types.blocks,
        description: "Output blocks",
      },
    },
    required: ["out_blocks"],
  },
});

export default SlackFunction(
  MyFunctionDef,
  async ({ inputs }) => {
    console.log("------------");
    console.log("Inputs:");
    console.log(inputs);

    const var_data = inputs.theblocks;

    return {
      outputs: {
        out_blocks: var_data,
      },
    };
  },
);
zimeg commented 6 months ago

Hey @mcsescott 👋 I can confirm that the Schema.slack.types.blocks type doesn't appear in Workflow Builder outputs even though other types still do. This seems unexpected but might be the correct behavior, I'll check with the team now!

I'm thinking this might be treated similarly to the Schema.types.object type in regards to Workflow Builder behavior, meaning it's not yet supported. If it is, we'll make sure this is noted in documentation soon and I'll let you know.

Thanks as always for writing in! I hope your afternoon is going well too! 🌚

mcsescott commented 6 months ago

Thanks @zimeg !

According to the documentation it appears possible, as per the example provided for that type. That's why I'm confused!

filmaj commented 5 months ago

Going to close this as a duplicate of #233