slackapi / deno-slack-sdk

SDK for building Run on Slack apps using Deno

Home Page:https://api.slack.com/automation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Modals] return outputs in addViewSubmissionHandler

RachadAbiChahine opened this issue · comments

Question

I am trying to use multi step workflow to create an github issue,
In my case i want to use modal to make a primary choice if the client want to create an issue or just post a question
image

Then another modal will be opened with the correct inputs using addBlockSuggestionHandler then user will submit the form

then with addViewSubmissionHandler I want to be able to collect the inputs and send it to the next workflow step

but I can't find a way to do this

const product = view.state.values?.[BLOCK_PRODUCT_SELECT_ID]?.[BLOCK_PRODUCT_SELECT_ACTION_ID].selected_option?.value; ... return { output:{product:product}, response_action: "clear", view: {} };

But when I add outpt I get an error
image

what is the right way to pass the result of the submited value to the next workflow step ?

@RachadAbiChahine it looks to me like you are trying to return function outputs in your code (based on return { output: {} ... }) from within an interactivity handler such as a View Submission Handler.

I do not think that is possible to do directly using return from an interactivity handler. Any direct returns from an interactivity handler only affect the specific interactivity element/event using the response_action object property. More details on this are available in our Interactivity docs.

I have an example interactivity app on GitHub, and from the interactivity handlers in this app (see this code), to set the outputs on the housing function from one of its interactivity handlers, you must use the asynchronous API client and call functions.completeSuccess (if the function execution completed successfully) or functions.completeError (if the function execution failed).

I realize that the Interactivity docs imply that you may return function outputs directly from the interactivity handlers, but that is a mistake. I will follow up with the documentation team to ensure this is removed.

Thank you for your answer,
In this case when we use modal there is no way to use steps like

step 1: we open modal to collect information from client,
step 2: we use these info to create api call ( issue github...)
step3: we post the message to a channel

and this forced us to put these three steps in one place and make our code less easy to read

It would be really nice to be able to return outputs to be able to use it as inputs in a separate step

Yes that is most definitely possible. I am confused why you say it forces you to organize your code in a specific, less-readable way. Can you post an example of what you mean to help me understand?