Agent-Led Sessions
In some scenarios, you may want to prevent the visitor from clicking or navigating while you're presenting. This is useful for guided demos or presentations where you want full control of the experience.
How It Works
Listen for session events and block visitor interactions that aren't coming from the agent. Events triggered by the agent have the isUpscopeRemoteInstruction property set to true.
let sessionActive = false;
Upscope("on", "sessionStart", "sessionContinue", function() {
sessionActive = true;
});
Upscope("on", "sessionEnd", function() {
sessionActive = false;
});
document.addEventListener("click", function(e) {
if (sessionActive && !e.isUpscopeRemoteInstruction) {
e.preventDefault();
e.stopPropagation();
}
}, true);
Blocking Other Event Types
You can extend this pattern to block other interactions like scrolling or keyboard input:
["click", "keydown", "keyup", "scroll"].forEach(function(eventType) {
document.addEventListener(eventType, function(e) {
if (sessionActive && !e.isUpscopeRemoteInstruction) {
e.preventDefault();
e.stopPropagation();
}
}, true);
});
This ensures only agent-initiated actions are allowed during the session, while the visitor can watch but not interfere.