Add campaigns
Zoom Virtual Agent provides methods such as open(), close(), hide(), or show() to give better control of a chatbot's behavior, which results in a more adaptable experience on a website. For example, you might want to use Javascript or specific user interactions with the site to trigger the visibility of the bot.
This documentation shows specific ways you can use the Zoom Virtual Agent web SDK.
Zoom Virtual Agent SDK for web
You can use the Zoom Virtual Agent web SDK to manage your chatbot.
This SDK script loads when the page loads. However, the SDK won't fully load until the allocation of resources. As a result, before we execute any SDK functions, Zoom provides the zoomCampaignSdk:ready check.
We strongly recommend you include this check to avoid an undefined error in the console, and ensure the proper execution of the bot.
window.addEventListener("zoomCampaignSdk:ready", () => {
// customer can do something here:
// ...
// eg. using it to open campaign
zoomCampaignSdk.open();
});
SDK capabilities
Use Zoom Virtual Agent web SDK to perform specific tasks, such as open, close, or send a message.
enum Events{
OPEN:"open";
CLOSE:"close";
SHOW:"show";
HIDE:"hide";
SEND_MESSAGE:"send_message";
}
zoomCampaignSdk:{
open(): void;
close(): void;
show(): void;
hide(): void;
endChat(): void;
on(eventName:"string",handler:any): void;
off(eventName:"string",handler?:any): void;
}
After window.zoomCampaignSdk:ready completes, developers can write code to refer to events or SDK methods mentioned above.
window.addEventListener("zoomCampaignSdk:ready", () => {
window.zoomCampaignSdk.open();
});
Explicit interactions with Zoom Virtual Agent
Use the Zoom Virtual Agent web SDK to explicitly interact with Zoom Virtual Agent to perform such actions as open, close, or hide a Zoom Virtual Agent modal.
if (window.zoomCampaignSdk) {
// To open the Zoom Virtual Agent modal and start a new conversation if one has not started
window.zoomCampaignSdk.open();
//To hide the Zoom Virtual Agent modal, including the invitation
window.zoomCampaignSdk.hide();
//To show the Zoom Virtual Agent modal, including the launcher widget
window.zoomCampaignSdk.show();
// To close or collapse the modal so that only the launcher widget is visible
window.zoomCampaignSdk.close();
// To end engagement, keep the Zoom Virtual Agent modal as it is
window.zoomCampaignSdk.endChat();
}
Handling events
Use the Zoom Virtual Agentweb SDK to handle events, such as how to unsubscribe from one or all callbacks from an event.
if (window.zoomCampaignSdk) {
//To add a callback function to execute after a specific event is emitted
window.zoomCampaignSdk.on(event, callback);
//To unsubscribe a callback from an event
window.zoomCampaignSdk.off(event, callback);
//To unsubscribe all callbacks from an event
window.zoomCampaignSdk.off(event);
}
Event examples
Zoom Virtual Agent web SDK performs actions, such as open, close, or send messages.
if (window.zoomCampaignSdk) {
window.zoomCampaignSdk.on("open", () => {
alert("open event");
});
}
if (window.zoomCampaignSdk) {
window.zoomCampaignSdk.on("close", () => {
alert("close event");
});
}
if (window.zoomCampaignSdk) {
window.zoomCampaignSdk.on("show", () => {
alert("show event");
});
}
if (window.zoomCampaignSdk) {
window.zoomCampaignSdk.on("hide", () => {
alert("hide event");
});
}
if (window.zoomCampaignSdk) {
window.zoomCampaignSdk.on("send_message", () => {
alert("send_message event");
});
}