Menu

1 / 5

Pause workflows for approval with Chat SDK - Vercel

Vercel News·Ben Sabic·8 days ago
#HXIS3lBb
#vercel#workflow#chat#thread#card
Reading 0:00
15s threshold

You can build human-in-the-loop approvals with Chat SDK through the new chat/workflow subpath. One requestApproval call posts a card with Approve and Deny buttons and suspends a Workflow SDK workflow until someone decides.

The wait can last seconds or days and survives deploys and restarts. You don't need an approvals table, an onAction handler, or a polling loop:

import { requestApproval } from "chat/workflow" ;

import type { Thread } from "chat" ;

export async function deployApproval ( opts : { thread : Thread ; version : string } ) {

"use workflow" ;

const { approved , user , timedOut } = await requestApproval ( opts . thread , {

title : ` Deploy Website? ` ,

fields : { Version : opts . version } ,

timeout : "24h" ,

} ) ;

if ( approved ) {

await deploy ( opts . version ) ;

}

}

Send a card to request approval for a deployment

Start the workflow from any handler, and Thread instances serialize across the workflow boundary automatically.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.