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

[QUERY] How can I accomplish interactivity fan-out?

malbertSC opened this issue Β· comments

Question

How can I handle more than 1 Interactivity chain in a single workflow?

Context

I'm working on a workflow triggered by a github webhook. When a PR is closed, the webhook triggers a workflow that calls a custom function that reads all the review comments in the PR and looks for πŸš€ emojis. If it finds any, I'd like to trigger an interactivity flow for each rocket in the PR:

  • we postMessage to the user that added the rocket emoji with an interactive block that allows them to comment on why they wanted to highlight this review comment
  • a blockActionHandler picks up the response and posts a message to the team channel highlighting the review comment with a message from the emoji-reactor

This works great for a single πŸš€ but I don't know how to pull all the πŸš€ comments, loop over them, and handle interactivity flows. You can't write a blockActionHandler from within the custom function handler, so it's not really possible to loop over these and trigger interactivity blocks if I actually want to see the responses to them. It also doesn't seem like you can nest Custom Functions / invoke a Custom Function from another Custom Function. I saw this issue but it doesn't seem to solve my problem: #238.

I could work around this by running another server to handle receiving the "PR Closed" webhook from GH and invoking a per-πŸš€ workflow by having my other server hit the slack app webhook, but I was wondering if there's a better / preferred option here.

Hey @malbertSC thanks for asking the question.

Just riffing off the top of my head: it should be possible to post a message to each user and have the button or interactive element in the user-specific message be the entrypoint to a different, second workflow. This second workflow could collect responses from users and post to the relevant channel.

You may need to do some state management for tracking/coordinating the users and PRs. One option is using the datastore APIs available to you. Possibly another option would be to embed relevant state into the messages themselves via message metadata.

Let me know what you think, happy to workshop more ideas or talk through the design.

Hey @malbertSC thanks for asking the question.

Just riffing off the top of my head: it should be possible to post a message to each user and have the button or interactive element in the user-specific message be the entrypoint to a different, second workflow. This second workflow could collect responses from users and post to the relevant channel.

You may need to do some state management for tracking/coordinating the users and PRs. One option is using the datastore APIs available to you. Possibly another option would be to embed relevant state into the messages themselves via message metadata.

Let me know what you think, happy to workshop more ideas or talk through the design.

Hey thanks for the quick reply! My totally non-expert impression is that adding state via the datastore APIs or tunneling through message metadata would work, but seems more complex than the separate fanout service in front of the workflow. If there's no option to call a custom function from another custom function, or to otherwise (relatively trivially) encapsulate an interactivity flow, I think that's what I'll end up going with.