Hello,
Your code is requesting the chat to be opened and submitted as soon as the page load.
In "window._genesys.widgets.onReady = function(QuickBus)" [called when the widget core & plugins have finished to load], you are subscribing to the "WebChatService.ready" event [triggered when WebChatService plugin has been loaded] but on that event, you are calling a function which does nothing "function(e){}".
Then immediately after, you request the WebChat to be opened and submitted with your command "oMyPlugin.command('WebChat.open', ..."
I don't know if you mean clicking a button for chat in the Widget Sidebar plugin/UI, clicking the native Widget WebChat button (on right hand-side of the page).
But yes, there are several ways to auto-submit the chat form when the user clicks the sidebar button.
If you meant the Widget Sidebar plugin, you have a channel defined for your chat button.
A first approach with Widget Sidebar would be to have the clickCommand set to "WebChat.open", and clickOptions set to:
{
userData: {},
form: {
autoSubmit: true,
firstname: "abcd",
lastname: "efgh",
email: "ijkl",
subject: "mnop"
}
}
A second approach with Widget Sidebar would be to implement the onClick function (in the Sidebar channel configuration) and request the WebChat from there.
onClick: function($, CXBus, Common) {
CXBus.command('WebChat.open', {
userData: {},
form: {
autoSubmit: true,
firstname: "abcd",
lastname: "efgh",
email: "ijkl",
subject: "mnop"
}
});
}
A third approach could consist in "intercepting" the "WebChat.open" command, using the before method(), and in modifying the input object to force the autoSubmit: true.
As soon as the WebChat is requested from anywhere (Sidebar WebChat.open, native WebChat button, custom buttons), the function would be triggered, and you could update the autoSubmit attribute to true so that the registration form is skipped.
Regards,