Skip to content

[QUERY] Is there a way to stop a workflow in an early step without throwing error to an admin via Slackbot? #276

Description

@spoike

Question

The main question is if it is allowed to NOT call client.function.completeError/Success in a ViewClosedHandler callback in order to stop a Slack workflow early?

Context

Normally a SlackFunction is completed successfully or fails. But what about stopping the workflow early? The use case in mind is handling a modal view that the user closes early. You can do the following:

Call functions.completeSuccess

export default SlackFunction(..., ...)
  .addViewClosedHandler("myview", () => ({ client, body }) {
    /* clean up stuff */
    
    return await client.functions.completeSuccess({
      function_execution_id: body.function_data.execution_id,
      outputs: {}
    })
  })

The drawback with this is that the rest of the workflow needs to handle undefined or null outputs, and add some kind of a short circuit logic for all other slack functions.

Call functions.completeError

export default SlackFunction(..., ...)
  .addViewClosedHandler("myview", () => ({ client, body }) {
    /* clean up stuff */
    
    return await client.functions.completeError({
      function_execution_id: body.function_data.execution_id,
      error: "User closed the dialog early"
    })
  })

The drawback with this approach is that whenever the user legitimately closes the modal window (e.g. they don't have the time to complete the modal inputs) then the admins are all pinged by SlackBot with this error.

Do nothing at all

export default SlackFunction(..., ...)
  .addViewClosedHandler("myview", () => ({ client, body }) {
    /* clean up stuff */

   console.log('user closed the modal view early');
   // do nothing
  })

The modal view closes, an entry in activity log is made (when console.log is used) and the workflow doesn't continue (which is desired effect). However this possibility is not documented anywhere and I'm not sure if this will create some memory leak on Slack's end. Is this an allowed way of exiting the workflow early?

Environment

Not really applicable but:

  • Paste the output of cat import_map.json | grep deno-slack
    "deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@2.5.0/",
    "deno-slack-api/": "https://deno.land/x/deno_slack_api@2.1.2/",
  • Paste the output of deno --version
deno 1.39.4 (release, x86_64-apple-darwin)
v8 12.0.267.8
typescript 5.3.3
  • Paste the output of sw_vers && uname -v on macOS/Linux or ver on Windows OS
ProductName:            macOS
ProductVersion:         14.2.1
BuildVersion:           23C71
Darwin Kernel Version 23.2.0: Wed Nov 15 21:54:10 PST 2023; root:xnu-10002.61.3~2/RELEASE_X86_64

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.

Cool beans 🤘

Metadata

Metadata

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions