A Bolt WorkflowStep deployed to AWS Lambda (following Slack's bolt-js serverless deployment docs) has its execute function invoked multiple times per workflow run. In Socket Mode the same code worked perfectly. The duplicate invocations come from multiple Events API calls visible in the logs, not from the workflow itself.
Bolt WorkflowStep executes multiple times when deployed to Lambda / serverless
- Boltframework
- Slackplatform
- WorkflowSteplibrary
- bolt-jslibrary
- AWS Lambdaplatform
- Events APIservice
- +2 more
Slack retries the Events API request if your function does not acknowledge within 3 seconds, so a slow execute handler gets invoked again. Fix: acknowledge immediately and do the long work asynchronously. Split the logic across two functions: Function A holds the Workflow Step execute handler and only acks (then asynchronously invokes Function B, e.g. via Lambda async invoke or a Step Functions state machine); Function B does the report generation and posts to Slack. The reporter confirmed this pattern stops the duplicate executions. Note that if you never await complete, the workflow activity will show 'In Progress' in Slack's UI. Source: https://github.com/slackapi/bolt-js/issues/1156