{"slug": "when-should-your-shopify-chat-bot-hand-off-to-a-human-a-small-rules-engine", "title": "When Should Your Shopify Chat Bot Hand Off to a Human? A Small Rules Engine", "summary": "A developer published a small, testable JavaScript rules engine for deciding when a Shopify live-chat bot should hand a conversation off to a human agent. The function returns a reason string rather than a boolean — triggered by a customer asking for a person, sensitive-topic keywords, two failed answers, or low bot confidence — so each escalation can be logged, and it falls back to collecting contact details when the team is offline. The writeup recommends sending the chat transcript with every transfer and reviewing the top handoff reasons weekly.", "body_md": "When Should Your Shopify Chat Bot Hand Off to a Human? A Small Rules Engine\n\nA 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.\n\nfunction shouldHandOff({ message, failedAnswers, botConfident }) {\n\n  if (ASKS_HUMAN.test(message)) return 'customer asked';\n\n  if (ESCALATE_WORDS.test(message)) return 'sensitive topic';\n\n  if (failedAnswers >= 2) return 'bot failed twice';\n\n  if (!botConfident) return 'low confidence';\n\n  return null;\n\n}\n\nReturning a reason instead of true means you can log why each chat escalated.\n\nAdjust the days and hours to your team's schedule.\n\nif (isOnline()) {\n\n    return { action: 'transfer', reason, transcript: chat.history };\n\n  }\n\n  return {\n\n    action: 'collect_contact',\n\n    reason,\n\n    reply: 'Our team is offline right now. Leave your email or phone and we will reply by 11 AM tomorrow.',\n\n  };\n\n}\n\nAlways send the transcript with the transfer so shoppers don't repeat themselves.\n\nQuick tests\n\njavascript\n\nconsole.log(shouldHandOff({ message: 'My order arrived damaged', failedAnswers: 0, botConfident: true }));\n\n// 'sensitive topic'\n\nconsole.log(shouldHandOff({ message: 'What is the delivery time?', failedAnswers: 0, botConfident: true }));\n\n// null\n\nTips\n\nLog every handoff reason and review the top ones weekly.\n\nDon't promise a reply time your team can't keep.\n\nKeep the \"talk to a person\" option visible, not only automatic.\n\nIf the shopper writes in an angry tone, escalate early.", "url": "https://wpnews.pro/news/when-should-your-shopify-chat-bot-hand-off-to-a-human-a-small-rules-engine", "canonical_source": "https://dev.to/aylelite_fdb8fce6a0f4ce96/when-should-your-shopify-chat-bot-hand-off-to-a-human-a-small-rules-engine-3j9k", "published_at": "2026-11-27 06:39:39+00:00", "updated_at": "2026-11-27 06:44:00.343965+00:00", "lang": "en", "topics": ["ai-agents", "ai-products", "developer-tools"], "entities": ["Shopify"], "also_reported_by": [], "takeaway": "Return a reason string instead of a boolean from the handoff check so every escalation is logged and reviewable, and attach the chat transcript to each transfer so shoppers don't repeat themselves.", "recommendation": {"advice": "Trigger handoff on an explicit human request, sensitive-topic keywords, two failed answers or low confidence, return the reason for logging, and send the transcript with the transfer.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/when-should-your-shopify-chat-bot-hand-off-to-a-human-a-small-rules-engine", "markdown": "https://wpnews.pro/news/when-should-your-shopify-chat-bot-hand-off-to-a-human-a-small-rules-engine.md", "text": "https://wpnews.pro/news/when-should-your-shopify-chat-bot-hand-off-to-a-human-a-small-rules-engine.txt", "jsonld": "https://wpnews.pro/news/when-should-your-shopify-chat-bot-hand-off-to-a-human-a-small-rules-engine.jsonld"}}