![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
クラウドリソースをプロビジョニングする前に、機械学習モデルの生産に促進する、または顧客のクレジットカードの請求前に承認が必要な場合があります。
Have you ever wanted to pause an automated workflow to wait for a human decision? Maybe you need approval before provisioning cloud resources, promoting a machine learning model to production, or charging a customer’s credit card.
人間の決定を待つために自動化されたワークフローを一時停止したいと思ったことはありませんか?クラウドリソースをプロビジョニングする前に、機械学習モデルの生産に促進する、または顧客のクレジットカードの請求前に承認が必要な場合があります。
In many data science and machine learning workflows, automation gets you 90% of the way — but that critical last step often needs human judgment. Especially in production environments, model retraining, anomaly overrides, or large data movements require careful human review to avoid expensive mistakes.
多くのデータサイエンスおよび機械学習ワークフローでは、自動化は90%の方法で得られますが、その重要な最後のステップでは人間の判断が必要です。特に、生産環境では、モデル再訓練、異常のオーバーライド、または大規模なデータの動きでは、高価な間違いを避けるために慎重に人間のレビューが必要です。
In my case, I needed to manually review situations where my system flagged more than 6% of customer data for anomalies — often due to accidental pushes by customers. Before I implemented a proper workflow, this was handled informally: developers would directly update production databases (!) — risky, error-prone, and unscalable.
私の場合、私のシステムが異常のために顧客データの6%以上がフラグを立てた状況を手動で確認する必要がありました。多くの場合、顧客による偶発的なプッシュのためです。適切なワークフローを実装する前に、これは非公式に処理されました。開発者は、生産データベース(!)を直接更新します。リスク、エラーが発生しやすく、無視できません。
To solve this, I built a scalable manual approval system using AWS Step Functions, Slack, Lambda, and SNS — a cloud-native, low-cost architecture that cleanly paused workflows for human approvals without spinning up idle compute.
これを解決するために、AWSステップ機能、Slack、Lambda、およびSNSを使用してスケーラブルな手動承認システムを構築しました。
In this post, I’ll walk you through the full design, the AWS resources involved, and how you can apply it to your critical workflows.
この投稿では、完全なデザイン、関連するAWSリソース、そしてそれを重要なワークフローに適用する方法について説明します。
Let’s get into it 👇
入りましょう
The Solution
解決策
My application is deployed in the AWS ecosystem, so we’ll use Aws Step Functions to build a state machine that:
私のアプリケーションはAWSエコシステムに展開されているため、AWSステップ関数を使用して、次のような状態マシンを構築します。
Here is a youtube video showing the demo and actual application in action:
デモと実際のアプリケーションを示すYouTubeビデオです。
I have also hosted the live demo app here →👉 https://v0-manual-review-app-fwtjca.vercel.app
ライブデモアプリもここにホストしました→👉https://v0-manual-review-fwtjca.vercel.app
All code is hosted here with the right set of IAM permissions.
すべてのコードは、正しいIAM許可セットでここでホストされています。
Step-by-Step Implementation
ステップバイステップの実装
The flow above generates a dataset, uploads it to AWS S3 and if a review is required, then invokes the Manual Review lambda. On the manual review step, we’ll use a Task lambda with an invoke on WaitForTaskToken, which pauses execution until resumed. The lambda reads the token this way:
上記のフローはデータセットを生成し、AWS S3にアップロードし、レビューが必要な場合は、マニュアルレビューLambdaを呼び出します。マニュアルレビューステップでは、WaitfortaskTokenのInvokeでタスクLambdaを使用して、再開するまで実行を一時停止します。ラムダはトークンをこのように読みます:
This Lambda sends a Slack message that includes the task token so the function knows what execution to resume.
このラムダは、タスクトークンを含むスラックメッセージを送信し、関数が再開する実行を把握します。
2. Before the we send out the slack notification, we need to
2。スラック通知を送信する前に、
I followed the youtube video here for my setup.
私はここでYouTubeのビデオをフォローしてセットアップを行いました。
3. Once the above is setup, setup the variables into the web-hook step of the slack workflow:
3.上記が設定されたら、変数をSlackワークフローのWebフックステップにセットアップします。
And use the variables with a helpful note in the following step:
そして、次のステップで役立つメモで変数を使用します。
The final workflow will look like this:
最終的なワークフローは次のようになります:
4. Send a Slack Notification published to an SNS topic (you can alternately use slack-sdk as well) with job parameters. Here is what the message will look like:
4.ジョブパラメーターを使用して、SNSトピックに公開されたSLACK通知を送信します(Slack-SDKも交互に使用できます)。メッセージがどのように見えるかは次のとおりです。
This Lambda sends a Slack message that includes the task token so the function knows what execution to resume.
このラムダは、タスクトークンを含むスラックメッセージを送信し、関数が再開する実行を把握します。
5. Once a review notification is received in slack, the user can approve or reject it. The step function goes into a wait state until it receives a user response; however the task part is set to expire in 24 hours, so inactivity will timeout the step function.
5.レビュー通知がSlackで受信されると、ユーザーはそれを承認または拒否できます。ステップ関数は、ユーザーの応答を受信するまで待機状態になります。ただし、タスク部分は24時間で期限切れに設定されているため、不活動はステップ機能をタイムアウトします。
Based on whether the user approves or rejects the review request, the rawPath gets set and can be parsed here: code
ユーザーがレビューリクエストを承認または拒否するかどうかに基づいて、RawPathが設定され、ここで解析できます:コード
The receiving API Gateway + Lambda combo:
受信APIゲートウェイ +ラムダコンボ:
Example:
例:
Note: Lambda configured with WaitForTaskToken must wait. If you don’t send the token, your workflow just stalls.
注:waitfortasktokenで構成されたLambdaは待つ必要があります。トークンを送信しない場合、ワークフローは停止します。
Bonus: If you need email or SMS alerts, use SNS to notify a broader group.Just sns.publish() from within your Lambda or Step Function.
ボーナス:電子メールまたはSMSアラートが必要な場合は、snsを使用して、より広いgroup.just sns.publish()にラムダまたはステップ関数内から通知します。
Testing
テスト
Once the manual approval system was wired up, it was time to kick the tires. Here’s how I tested it:
手動承認システムが配線されたら、タイヤを蹴る時が来ました。これが私がそれをテストした方法です:
I tested all major paths:
すべての主要なパスをテストしました。
Behind the scenes, I also verified that :
舞台裏では、私もそれを確認しました:
I highly recommend testing not just happy paths, but also “what if nobody clicks?” and “what if Slack glitches?” — catching these edge cases early saved me headaches later.
幸せなパスだけでなく、「誰もクリックしない場合はどうでしょう?」そして、「もしスラックが不具合したら?」 - これらのエッジケースを早期にキャッチすると、後で頭痛がしました。
Lessons Learned
学んだ教訓
Wrapping Up
まとめます
Adding human-in-the-loop logic doesn’t have to mean duct tape and cron jobs. With Step Functions + Slack, you can build reviewable, traceable, and production-safe approval flows.
Human-in-the-Loopロジックを追加することは、ダクトテープやCronの仕事を意味する必要はありません。 Step機能 + Slackを使用すると、レビュー可能、トレース可能な、および生産に安全な承認フローを構築できます。
If this helped, or you’re trying something similar, drop a note in the comments! Let’s build better workflows.
これが役立った場合、または同様のことを試みている場合は、コメントにメモをドロップしてください!より良いワークフローを構築しましょう。
Note: All images in this article were created by the author
注:この記事のすべての画像は著者によって作成されました
免責事項:info@kdj.com
提供される情報は取引に関するアドバイスではありません。 kdj.com は、この記事で提供される情報に基づいて行われた投資に対して一切の責任を負いません。暗号通貨は変動性が高いため、十分な調査を行った上で慎重に投資することを強くお勧めします。
このウェブサイトで使用されているコンテンツが著作権を侵害していると思われる場合は、直ちに当社 (info@kdj.com) までご連絡ください。速やかに削除させていただきます。