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"
-
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
-
Routing Layer detects time and selects After Hours Agent.
-
_shift is set to "afterhours" in the runtime context.
-
Plugin Preprocessor detects _shift and sets fail_msg.