Menu

When Should Your Shopify Chat Bot Hand Off to a Human? A Small Rules Engine
📰

When Should Your Shopify Chat Bot Hand Off to a Human? A Small Rules Engine

DEV Community: ai·Aylelite·4 days ago
#bsowJoxd
#devtoai#devto#dev#return#chat
Long article (307 words) — no AI summary yet.
Reading 0:00
15s threshold

When Should Your Shopify Chat Bot Hand Off to a Human? A Small Rules Engine

A live chat AI app is only as good as its handoff. Here's a small, testable function that decides when to pass a chat to your team, and what to do if nobody is online.

Define the rules javascript const ESCALATE_WORDS = /refund|damaged|broken|wrong item|not received|complaint|cancel/i; const ASKS_HUMAN = /human|agent|person|talk to (someone|team)/i;

function shouldHandOff({ message, failedAnswers, botConfident }) {

if (ASKS_HUMAN.test(message)) return 'customer asked';

if (ESCALATE_WORDS.test(message)) return 'sensitive topic';

if (failedAnswers >= 2) return 'bot failed twice';

if (!botConfident) return 'low confidence';

return null;

}

Returning a reason instead of true means you can log why each chat escalated.

Check business hours javascript function isOnline(now = new Date()) { const ist = new Date(now.toLocaleString('en-US', { timeZone: 'Asia/Kolkata' })); const day = ist.getDay(); // 0 = Sunday const hour =…

Continue reading — create a free account

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