Toaster Plugin
The Toaster plugin enables brands to display a notification or call-to-action (CTA) message, with title, body and configurable action buttons.
The Toaster’s CTA can be accepted by running the Toaster.accept command or clicking the primary action button and can be declined by running the Toaster.decline command or clicking the secondary action button. The Toaster can be closed by running the Toaster.close command or clicking the close icon. The Toaster will also remain on the screen until the user accepts, declines or closes the Toaster and will be visible across the app with only one Toaster displayed at a time.
Note: Please subscribe to ready event before calling any Toaster plugin commands.
When Toaster plugin is ready to accept commands, it will publish ready event. It's recommended to subscribe to this event before calling any commands in this plugin. If the ready event is already published before you subscribe to it, it will simply republish again ensuring your callback function gets executed. You can refer to this example below.
Genesys("subscribe", "Toaster.ready", () => {
Genesys(
"command",
"Toaster.open",
{
title: "Welcome to Genesys Cloud",
body: "Encountering issues? Our support team is ready to troubleshoot and assist you.",
buttons: {
type: "binary", // required when 'buttons' is present. Values: "unary" for one action button, "binary" for two action buttons
primary: "Get Support", // optional, default value is "Accept"
secondary: "Maybe Later", // optional, default value is "Decline"
},
},
function () {
/*fulfilled callback*/
console.log("Toaster is opened");
},
function (error) {
/*rejected callback*/
console.log("There was an error running the Toaster.open command:", error);
}
);
});
Toaster plugin user interface
Here are some examples of how the Toaster looks in the user interface with Messenger collapsed and expanded and Launcher on.
Toaster plugin commands
Toaster.open
Shows the Toaster.
Resolutions:
Name | Description | Events published | Return Message |
Genesys(
"command",
"Toaster.open",
{
title: "Welcome to Genesys Cloud",
body: "Encountering issues? Our support team is ready to troubleshoot and assist you.",
buttons: {
type: "binary", // required when 'buttons' is present. Values: "unary" for one action button, "binary" for two action buttons
primary: "Get Support", // optional, default value is "Accept"
secondary: "Maybe Later", // optional, default value is "Decline"
},
},
function () {
/*fulfilled callback*/
console.log("Toaster is opened");
},
function (error) {
/*rejected callback*/
console.log("There was an error running the Toaster.open command:", error);
}
);
Note: Either “title” or “body” is required for Toaster to appear.
Options:
Name | Data type | Description | Required | Notes |
Toaster.accept
Accepts the Toaster.
Resolutions:
Name | Description | Events published | Return Message |
Genesys(
"command",
"Toaster.accept",
{},
function () {
/*fulfilled callback*/
console.log("Toaster Accepted");
},
function (error) {
/*rejected callback*/
console.log("There was an error running the Toaster.accept command:", error);
}
);
Toaster.decline
Declines the Toaster.
Resolutions:
Name | Description | Events published | Return Message |
Genesys(
"command",
"Toaster.decline",
{},
function () {
/*fulfilled callback*/
console.log("Toaster declined");
},
function (error) {
/*rejected callback*/
console.log("There was an error running the Toaster.decline command:", error);
}
);
Toaster.close
Close the toaster.
Resolutions:
Name | Description | Events published | Return Message |
Genesys(
"command",
"Toaster.close",
{},
function () {
/*fulfilled callback*/
console.log("Toaster closed");
},
function (error) {
/*rejected callback*/
console.log("There was an error running the Toaster.close command:", error);
}
);
Note: This will simply close the toaster without accepting or declining. It can be used to perform any neutral operation.
Toaster plugin events
Toaster.ready
Published when the Toaster plugin is ready to accept commands.
Data: Not applicable.
Genesys(
"subscribe",
"Toaster.ready",
function (e) {
console.log("Toaster plugin is ready", e);
}
);
Toaster.opened
Published when the Toaster is opened.
Data: Not applicable.
Genesys(
"subscribe",
"Toaster.opened",
function (e) {
console.log("Toaster was opened", e);
}
);
Toaster.accepted
Published when the Toaster is accepted.
Data: Not applicable.
Genesys(
"subscribe",
"Toaster.accepted",
function (e) {
console.log("Toaster was accepted", e);
}
);
Toaster.declined
Published when the Toaster is declined.
Data: Not applicable.
Genesys(
"subscribe",
"Toaster.declined",
function (e) {
console.log("Toaster was declined", e);
}
);
Toaster.closed
Published when the Toaster is closed.
Data: Not applicable.
Genesys(
"subscribe",
"Toaster.closed",
function (e) {
console.log("Toaster was closed", e);
}
);
Toaster.error
Published when an error occurs upon rendering Toaster.
{
"data": <string>, //error message
}
Genesys(
"subscribe",
"Toaster.error",
function (e) {
console.log("Toaster error:", e.data);
}
);