---
title: Using _shift Variable for Business Hour vs After-Hour Handling inside of Taalk Plugin
description: Learn how to use the _shift variable to distinguish between business hours, after-hours, and break time in AI Agent scripts and plugins. Includes implementation steps, JS Preprocessor example, and best practices for seamless off-hour handling.
---

[Skip to content](https://knowledge.taalk.ai/using-shift-variable-for-business-hour-vs-after-hour-handling#main-content)

Open main navigation

Close main navigation

 How can we help you today?

- There are no suggestions because the search field is empty.

1. [Taalk Academy](https://knowledge.taalk.ai/?hsLang=en)
2. [AI Force](https://knowledge.taalk.ai/ai-force?hsLang=en)
3. [Objective and Scripts](https://knowledge.taalk.ai/ai-force?hsLang=en#objective-and-scripts)

November 12, 2025

# Using \_shift Variable for Business Hour vs After-Hour Handling inside of Taalk Plugin

## The \_shift variable allows your AI Agent and Plugin to detect whether the current interaction is during Business Hours, After Hours, or Break Time. This feature update is important because it reduces maintenance requirements on ai agents. Instead of need multiple agents that need to be synchronized, only have one ai agent

#### **Overview**

The \_shift variable allows your AI Agent and Plugin to detect whether the current interaction is during **Business Hours**, **After Hours**, or **Break Time**.

By passing \_shift into both the AI Agent Plugin, you can create conditional logic to handle after-hours or break-time messages differently from standard in-hours interactions.

---

#### **Use Case**

- During **Business Hours**, the AI Agent proceeds with the normal conversation flow.
- During **After Hours** or **Break Time**, the system automatically switches to an alternate response or workflow.
- This ensures consistent handling of off-hour interactions without manual intervention.

---

#### **How \_shift Works**

- \_shift is injected into the **runtime context** at the start of the interaction.
- Values can be:
  
    - "businesshours" (default)
    - "afterhours"
    - "breaktime"
   When an **afterhours** or **breaktime** AI Agent is triggered, \_shift is set accordingly.

---

#### **Implementation Steps**

### **1. Setting \_shift in the Plugin Context**

When routing to an after-hours or break-time agent:

```
params._shift = "afterhours"; // or "breaktime"
```

> ⚠️ **Important:**

> \_shift must be set in the runtime context **before** calling the AI Agent or Plugin.

> Role-play/testing modes **do not** automatically add the \_shift flag — set it manually.

---

### **2. Using \_shift in Plugins**

You can check the \_shift value inside your Plugin’s **JS Preprocessor** to adjust responses dynamically.

**Example Plugin JS Preprocessor:**

```
(params) => {    let afterhour_msg;  if (params.shift == "afterhours") {    afterhour_msg = "Afterhour Message";  } else if (params.shift == "breaktime") {    afterhour_msg = "We’re currently on a short break — please hold or leave a message.";  }  return {    afterhour_msg: afterhour_msg  }}
```

---

### **3. Calling \_shift Directly**

When testing or triggering manually:

- **Plugin context:** params.\_shift

Do not rely on role-play simulation to set \_shift.

Manually set it in the runtime context for accurate results.

---

#### **Best Practices**

- Keep the after-hours and break-time messages concise and informative.
- Centralize \_shift logic in one place (routing layer) to avoid inconsistencies.
- This feature update is important because it reduces maintenance requirements on ai agents. Instead of need multiple agents that need to be syncronized, only have one ai agent

---

#### **Example Flow**

1. **Routing Layer** detects time and selects After Hours Agent.
2. \_shift is set to "afterhours" in the runtime context.
3. **Plugin Preprocessor** detects \_shift and sets fail\_msg.

- [Getting Started](https://knowledge.taalk.ai/getting-started?hsLang=en#main-content)
  
  
  
  
  
    - [Platform 101](https://knowledge.taalk.ai/getting-started?hsLang=en#platform-101)
    - [Campaign 101](https://knowledge.taalk.ai/getting-started?hsLang=en#campaign-101)
    - [AI Workforce](https://knowledge.taalk.ai/getting-started?hsLang=en#ai-workforce)
    - [Operator Force](https://knowledge.taalk.ai/getting-started?hsLang=en#operator-force)
    - [Billing 101](https://knowledge.taalk.ai/getting-started?hsLang=en#billing-101)
    - [Compliance 101](https://knowledge.taalk.ai/getting-started?hsLang=en#compliance-101)
- [AI Force](https://knowledge.taalk.ai/ai-force?hsLang=en#main-content)
  
  
  
  
  
    - [Agent Behavior](https://knowledge.taalk.ai/ai-force?hsLang=en#agent-behavior)
    - [Objective and Scripts](https://knowledge.taalk.ai/ai-force?hsLang=en#objective-and-scripts)
    - [Agent Call Flow and Transfers](https://knowledge.taalk.ai/ai-force?hsLang=en#agent-call-flow-and-transfers)
    - [Agent Knowledge](https://knowledge.taalk.ai/ai-force?hsLang=en#agent-knowledge)
    - [Agent Multichannel Playbooks](https://knowledge.taalk.ai/ai-force?hsLang=en#agent-multichannel-playbooks)
    - [Agent Plugins](https://knowledge.taalk.ai/ai-force?hsLang=en#agent-plugins)
    - [Best Practices](https://knowledge.taalk.ai/ai-force?hsLang=en#best-practices)
    - [Templates](https://knowledge.taalk.ai/ai-force?hsLang=en#templates)
- [Operator Force](https://knowledge.taalk.ai/operator-force?hsLang=en#main-content)
  
  
  
  
  
    - [Operator](https://knowledge.taalk.ai/operator-force?hsLang=en#operator)
    - [Admin](https://knowledge.taalk.ai/operator-force?hsLang=en#admin)
- [Contact Center](https://knowledge.taalk.ai/contact-center?hsLang=en#main-content)
  
  
  
  
  
    - [Campaign](https://knowledge.taalk.ai/contact-center?hsLang=en#campaign)
    - [Taalk Dialer](https://knowledge.taalk.ai/contact-center?hsLang=en#taalk-dialer)
    - [Metrics & Reporting](https://knowledge.taalk.ai/contact-center?hsLang=en#metrics-reporting)
    - [Templates](https://knowledge.taalk.ai/contact-center?hsLang=en#templates)
    - [Best Practices](https://knowledge.taalk.ai/contact-center?hsLang=en#best-practices)
- [Automation](https://knowledge.taalk.ai/automation?hsLang=en#main-content)
  
  
  
  
  
    - [OpenAPI](https://knowledge.taalk.ai/automation?hsLang=en#openapi)
    - [Native Integration](https://knowledge.taalk.ai/automation?hsLang=en#native-integration)
- [Compliances](https://knowledge.taalk.ai/compliances?hsLang=en#main-content)
  
  
  
  
  
    - [Company DNC](https://knowledge.taalk.ai/compliances?hsLang=en#company-dnc)
    - [TCPA](https://knowledge.taalk.ai/compliances?hsLang=en#tcpa)
    - [Best Practices](https://knowledge.taalk.ai/compliances?hsLang=en#best-practices)
    - [Teleco Trust](https://knowledge.taalk.ai/compliances?hsLang=en#teleco-trust)
- [Product Updates](https://knowledge.taalk.ai/product-updates?hsLang=en#main-content)
  
  
  
  
  
    - [W9-2025](https://knowledge.taalk.ai/product-updates?hsLang=en#w9-2025)
    - [W8-2025](https://knowledge.taalk.ai/product-updates?hsLang=en#w8-2025)
    - [W10-2025](https://knowledge.taalk.ai/product-updates?hsLang=en#w10-2025)
    - [W11-2025](https://knowledge.taalk.ai/product-updates?hsLang=en#w11-2025)
    - [W12-2025](https://knowledge.taalk.ai/product-updates?hsLang=en#w12-2025)
    - [W13-2025](https://knowledge.taalk.ai/product-updates?hsLang=en#w13-2025)
    - [W14-2025](https://knowledge.taalk.ai/product-updates?hsLang=en#w14-2025)
    - [W15-2025](https://knowledge.taalk.ai/product-updates?hsLang=en#w15-2025)
    - [W16-2025](https://knowledge.taalk.ai/product-updates?hsLang=en#w16-2025)

[![Taalk](https://knowledge.taalk.ai/hs-fs/hubfs/logo%20taalk.png?width=60&height=60&name=logo%20taalk.png "Taalk")](https://knowledge.taalk.ai/?hsLang=en)

[mailto:success@taalk.ai](mailto:success@taalk.ai) <https://www.linkedin.com/company/taalkai>

Copyright © 2025 Taalk LLC