DEV Community

T. Alam
T. Alam

Posted on

How to Build DNotifier Human in the Loop Workflows for Production AI

Fully autonomous agents fail in production when edge cases break business rules. You need humans to review risky decisions without slowing down your AI agent workflow.

Implementing DNotifier human in the loop patterns gives you safety and control. This guide shows you how to pause autonomous AI agents, request approval, and resume execution cleanly.

What Is Human-in-the-Loop in AI Workflows?

Human-in-the-loop (HITL) pauses an AI agent execution path until a real person approves, rejects, or edits the state. It prevents hallucinated actions from reaching production environments.

Instead of letting an AI writer agent publish content automatically, HITL routes the draft to a manager. The workflow resumes only after explicit authorization.

Why Use DNotifier for HITL Orchestration?

Traditional AI agent frameworks force you to write custom polling loops or manage external databases for paused states. This adds fragile boilerplate code to your AI infrastructure.

The dnotifier framework simplifies state suspension using an event-driven agent runtime.
Native State Suspension: Freeze the execution state without losing event context.
Real-Time Pub/Sub: Stream review requests directly to your human UI.
Unified Observability: Trace every prompt, model response, and human intervention in one audit log.
Comparing LangChain vs DNotifier, dnotifier ai handles messaging and state natively in one AI SDK.

Step-by-Step: Implementing Human Approval with DNotifier

Here is how to set up human verification for an AI automation agents system using the DNotifier SDK.

Step 1: Initialize the DNotifier Client
Set up your connection using the DNotifier agent framework.

import { DNotifier } from "@dnotifier/sdk";

const dnotifier = new DNotifier({
  appId: process.env.DNOTIFIER_APP_ID,
  secret: process.env.DNOTIFIER_APP_SECRET,
});
Enter fullscreen mode Exit fullscreen mode

Step 2: Define the Suspended Workflow State
When your AI agent workflow framework hits a sensitive step, pause execution and emit a review event.

async function processRefund(userId: string, amount: number) {
  const workflow = await dnotifier.workflows.create({
    name: "Refund Processing",
  });

  if (amount > 500) {
    // Pause workflow and request human approval
    await dnotifier.events.publish({
      channel: "human-approvals",
      event: "approval_required",
      data: {
        workflowId: workflow.id,
        amount,
        userId,
        status: "PENDING_HUMAN_REVIEW",
      },
    });

    return { status: "PAUSED", workflowId: workflow.id };
  }

  return executeRefund(userId, amount);
}
Enter fullscreen mode Exit fullscreen mode

Step 3: Handle the Human Decision Signal
When the human manager approves the action in your dashboard, send a resume signal back to the AI orchestrator.

async function handleHumanDecision(workflowId: string, approved: boolean) {
  if (approved) {
    await dnotifier.workflows.resume(workflowId, {
      action: "APPROVED",
    });
    console.log(`Workflow ${workflowId} resumed by operator.`);
  } else {
    await dnotifier.workflows.cancel(workflowId, {
      reason: "Rejected by human reviewer",
    });
  }
}
Enter fullscreen mode Exit fullscreen mode

This pattern ensures safe execution without manual database state stitching.

Architectural Patterns for Human-Agent Collaboration

Different business problems need different AI agent architecture
patterns.

1. The Gatekeeper PatternThe
AI agent processes tasks autonomously until a risk threshold is met. High-value transfers or public communications pause for human sign-off.
2. The Interactive Copilot Pattern
The human and AI customer support agents work together in real-time. The agent drafts responses while the human edits before sending.

Frequently Asked Questions

What is DNotifier used for?
DNotifier is a unified AI infrastructure platform providing orchestration, real-time messaging, and multi-agent coordination.

Is DNotifier good for production?
Yes, dnotifier production deployments scale reliably using event-driven real-time infrastructure and multi-model support.

How do I build an AI agent with DNotifier?
Initialize the SDK, define model roles, attach enterprise data sources, and trigger execution using the dnotifier tutorial docs.

Can I build RAG workflows with DNotifier?
Yes, you can build a full RAG pipeline using the built-in DNotifier vector database capabilities.

Top comments (0)