<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alexander Smirnoff</title>
    <description>The latest articles on DEV Community by Alexander Smirnoff (@dobeerman).</description>
    <link>https://dev.to/dobeerman</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F502914%2F5c2b9b15-6d26-42e3-8e72-d621989f827a.jpeg</url>
      <title>DEV Community: Alexander Smirnoff</title>
      <link>https://dev.to/dobeerman</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dobeerman"/>
    <language>en</language>
    <item>
      <title>Pause your Lambda: Building a Slack approval workflow with AWS Durable functions</title>
      <dc:creator>Alexander Smirnoff</dc:creator>
      <pubDate>Sun, 18 Jan 2026 15:53:57 +0000</pubDate>
      <link>https://dev.to/dobeerman/pause-your-lambda-building-a-slack-approval-workflow-with-aws-durable-functions-17jo</link>
      <guid>https://dev.to/dobeerman/pause-your-lambda-building-a-slack-approval-workflow-with-aws-durable-functions-17jo</guid>
      <description>&lt;h2&gt;
  
  
  1. The "Stateful" problem in serverless
&lt;/h2&gt;

&lt;p&gt;We all love AWS Lambda. It scales to zero, handles massive traffic spikes without breaking a sweat, and best of all, you only pay for the milliseconds your code runs. It is the perfect tool for event-driven tasks: "When &lt;em&gt;this&lt;/em&gt; happens, do &lt;em&gt;that&lt;/em&gt;."&lt;/p&gt;

&lt;p&gt;But there is one scenario where standard Lambda functions struggle: &lt;strong&gt;Waiting.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you are building an approval workflow. A user asks for permission to deploy to production. You send a message to a Slack channel asking an admin to click "Approve" or "Deny."&lt;/p&gt;

&lt;p&gt;Now, what does your code do?&lt;/p&gt;

&lt;p&gt;In the traditional serverless world, you had two main options:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;The "Bad" Way:&lt;/strong&gt; You keep the Lambda running with a &lt;code&gt;while&lt;/code&gt; loop, checking a database every few seconds to see if the admin clicked the button.

&lt;ul&gt;
&lt;li&gt;  &lt;em&gt;Result:&lt;/em&gt; You are paying for a server to sit idle. If the admin takes an hour (or goes to lunch), your Lambda times out.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;The "Hard" Way:&lt;/strong&gt; You use AWS Step Functions. You create a state machine (in JSON or YAML) that handles the wait and triggers a different Lambda when the task is done.

&lt;ul&gt;
&lt;li&gt;  &lt;em&gt;Result:&lt;/em&gt; It works well, but your logic is split. Half is in your TypeScript code, and half is in infrastructure configuration. It adds cognitive load and makes testing harder.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Enter AWS Lambda Durable functions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AWS now allows us to write "Durable" execution logic directly in our code. We can tell a Lambda function to &lt;strong&gt;pause execution&lt;/strong&gt;, save its state, and go to sleep. When an event happens (like a button click) hours or days later, it wakes up exactly where it left off.&lt;/p&gt;

&lt;p&gt;No idle server costs. No complex JSON state machines. Just clean, readable TypeScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The project: A Slack approval bot
&lt;/h2&gt;

&lt;p&gt;To demonstrate this power, I built a simple &lt;strong&gt;Email Approval Bot&lt;/strong&gt; for Slack.&lt;/p&gt;

&lt;p&gt;It’s a classic "Human-in-the-Loop" workflow that usually requires complex infrastructure. With Durable Functions, it becomes a single, readable story.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Flow
&lt;/h3&gt;

&lt;p&gt;Here is exactly what happens when you run the demo:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Initiation&lt;/strong&gt;: A user types a slash command in Slack: &lt;code&gt;/approve user@example.com&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Validation&lt;/strong&gt;: A generic Lambda (&lt;code&gt;Slack proxy&lt;/code&gt;) verifies the request came from Slack and kicks off our Durable Function.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;The Durable logic&lt;/strong&gt;: Our core function (&lt;code&gt;Approval processor&lt;/code&gt;) starts running:

&lt;ul&gt;
&lt;li&gt;  It validates the email format.&lt;/li&gt;
&lt;li&gt;  It generates a unique correlation ID.&lt;/li&gt;
&lt;li&gt;  It sends a message to a secure Slack channel using the Slack API, adding "Approve" and "Deny" buttons.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;The "Magic" pause&lt;/strong&gt;: The function hits a line of code that says &lt;code&gt;waitForCallback&lt;/code&gt;. It stops running. &lt;strong&gt;It costs $0 while waiting.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;The interaction&lt;/strong&gt;: An admin sees the message in Slack and clicks "Approve."&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;The resume&lt;/strong&gt;: Slack sends the click event to our API. A tiny helper Lambda receives the click and signals our paused function.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Completion&lt;/strong&gt;: The Durable Function "wakes up", remembers the original email and correlation ID, handles the approval, and sends a final confirmation message to Slack.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The beauty of this is that steps 3 through 7 are defined in &lt;strong&gt;one single file&lt;/strong&gt;, reading from top to bottom.&lt;/p&gt;

&lt;p&gt;Let’s look at how we build it.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Crucial concept 1: The "Durable" wrapper
&lt;/h2&gt;

&lt;p&gt;The first thing you'll notice is that this isn't a complex framework with a dozen configuration files. It looks like standard TypeScript.&lt;/p&gt;

&lt;p&gt;The only "magic" is a higher-order function that wraps your handler.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;src/approval-processor.ts&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;DurableContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;withDurableExecution&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@aws/durable-execution-sdk-js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;run&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;LambdaEvent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DurableContext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Your logic goes here&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// This is the key line!&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;withDurableExecution&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;run&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By wrapping your &lt;code&gt;run&lt;/code&gt; function with &lt;code&gt;withDurableExecution&lt;/code&gt;, you are telling the AWS SDK: &lt;em&gt;"Hey, handle the state for me. If I pause, save my spot. if I resume, load my variables."&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Crucial concept 2: The "Save points" (&lt;code&gt;ctx.step&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;In a normal Lambda, if the function stops, your variables die.  disappears into the void.&lt;/p&gt;

&lt;p&gt;In a Durable function, we use &lt;code&gt;ctx.step&lt;/code&gt;. Think of this as a &lt;strong&gt;"Save point"&lt;/strong&gt; in a video game.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Validation logic wrapped in a step&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;validationResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;validate-email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// ... validation logic ...&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;success&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;correlationId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;get-correlation-id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`corr-&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nf"&gt;randomUUID&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If this function runs, pauses for 3 days, and then wakes up:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; It &lt;strong&gt;skips&lt;/strong&gt; the code inside the &lt;code&gt;async () =&amp;gt; { ... }&lt;/code&gt; block because it already has the result saved.&lt;/li&gt;
&lt;li&gt; It re-assigns the saved &lt;code&gt;validationResult&lt;/code&gt; and &lt;code&gt;correlationId&lt;/code&gt; variables instantly.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This guarantees that your random IDs don't change and your heavy computations don't run twice.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Crucial concept 3: The magic pause (&lt;code&gt;ctx.waitForCallback&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;This is the superpower. We want to send a message to Slack and then &lt;strong&gt;stop existing&lt;/strong&gt; until someone clicks a button.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;slackActionResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;waitForCallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;approval&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callbackId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;_ctx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// This code runs JUST BEFORE pausing.&lt;/span&gt;
        &lt;span class="c1"&gt;// We attach the 'callbackId' to the Slack button.&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;slackModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;postMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;response_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;blocks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
                &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="na"&gt;action_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;approve_button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;callbackId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// &amp;lt;--- THE KEY!&lt;/span&gt;
                    &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;plain_text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Approve&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;minutes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="c1"&gt;// Auto-fail if no one clicks in 5 mins&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What happens here?&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;&lt;code&gt;callbackId&lt;/code&gt;&lt;/strong&gt;: The SDK generates a secret, unique ID for this specific pause.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Send&lt;/strong&gt;: We send that ID to Slack (hidden in the button's &lt;code&gt;value&lt;/code&gt; property).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Halt&lt;/strong&gt;: The function &lt;strong&gt;exits&lt;/strong&gt;. The Lambda stops billing. The state is saved to the backend storage.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  6. Crucial concept 4: Waking up (The action handler)
&lt;/h2&gt;

&lt;p&gt;So, the Lambda is asleep. How do we wake it up?&lt;/p&gt;

&lt;p&gt;When the admin clicks "Approve" in Slack, Slack calls our API Gateway. We need a tiny, standard Lambda to receive that webhook and forward the signal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;src/approval-action-handler.ts&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;LambdaClient&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;SendDurableExecutionCallbackSuccessCommand&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@aws-sdk/client-lambda&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// ... inside the handler receiving the Slack webhook ...&lt;/span&gt;

&lt;span class="c1"&gt;// 1. Extract the callback ID we sent earlier&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;actions&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;callbackId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 

&lt;span class="c1"&gt;// 2. Tell AWS Lambda: "Resume the function waiting for this ID!"&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SendDurableExecutionCallbackSuccessCommand&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;CallbackId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;callbackId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;Result&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;action_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;approve_button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
    &lt;span class="p"&gt;}),&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it! &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; The standard Lambda gets the click.&lt;/li&gt;
&lt;li&gt; It calls &lt;code&gt;SendDurableExecutionCallbackSuccessCommand&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt; Our "Durable" Lambda wakes up, the &lt;code&gt;await ctx.waitForCallback&lt;/code&gt; line finishes, and it returns the result we passed ().&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  7. Why this matters to you
&lt;/h2&gt;

&lt;p&gt;If you have ever built this workflow using &lt;strong&gt;Step Functions&lt;/strong&gt;, you know the pain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  You need a CDK/SAM definition for the State Machine.&lt;/li&gt;
&lt;li&gt;  You need one Lambda to start the task.&lt;/li&gt;
&lt;li&gt;  You need another Lambda to handle the logic.&lt;/li&gt;
&lt;li&gt;  You need another Lambda to receive the callback.&lt;/li&gt;
&lt;li&gt;  "Passing data" between them involves wrestling with JSON paths.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With &lt;strong&gt;Durable functions&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  It's &lt;strong&gt;one file&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;  It's &lt;strong&gt;standard TypeScript&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;  It handles state, retries, and waiting natively.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a massive leap forward for developer experience in the AWS ecosystem. It brings the power of "Workflow as Code" (popularized by tools like Temporal) directly into the native Lambda environment.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Ready to try it?&lt;/strong&gt;&lt;br&gt;
Clone the repo and deploy it to your own AWS account to see the magic in action.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/dobeerman/aws-lambda-durable-slack-approval-demo" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>lambda</category>
      <category>serverless</category>
      <category>eventdriven</category>
    </item>
  </channel>
</rss>
