Chatbutton start event

Hi,

I need to change the value of a customfield, when the start button is clicked, is it possible?

or something like, but i am using widget v2

window.ININ.webchat.create(chatConfig).then(function(webchat) {
var startChatButton = document.getElementById('start-purecloud-chat');
startChatButton.onclick = function onStartChatClick () {
return webchat.renderFrame({
containerEl: 'chat-container'
}).catch(function(error) {
console.error('Error starting chat');
console.error(error);
});
};

You can change the values for custom properties prior to initiating the chat by specifying customer userData and/or advanced configuration. https://developer.mypurecloud.com/api/webchat/widget-version2.html#custom__userdata_

Hi Tim,

I need to generate a protocol number and switch to purecloud, but I can only generate the number when the chat has actually started, is there any way to do this? can I know when the "start chat" button was clicked?

https://developer.mypurecloud.com/api/webchat/widget-version2.html#chat_start_and_end_events

Hi,

I managed to do it this way:

chatPlugin.command('WebChatService.startChat', {
nickname: ("#cx_webchat_form_firstname").val(), firstname: ("#cx_webchat_form_firstname").val(),
lastname: ("#cx_webchat_form_lastname").val(), email: ("#cx_webchat_form_email").val(),
subject: 'product questions',
userData: {
}
});

but the field values ​​are not being sent, can you help?
https://all.docs.genesys.com/WID/Current/SDK/WebChatService-combined#startChat

That doesn't look like valid JavaScript to me; it's just a string. I would expect trying to call a function named val() on a string will throw an error as that's not a function that exists on strings. If this is a special syntax of your frontend framework, check with the provider of that framework to troubleshoot why it's not providing values.

Aside from that, I would refer to the documentation I linked above for a sample of how to start a chat with pre-populated information. It has a full example showing how to accomplish that. You can also refer to the Developer Tools Web Chat tool to test custom data. https://developer.mypurecloud.com/developer-tools/#/webchat

Tim,
Even when I use the sample code from the documentation, it still doesn't work

oMyPlugin.command('WebChatService.startChat', {
nickname: 'Jonny',
firstname: 'Johnathan',
lastname: 'Smith',
email: 'jon.smith@mail.com',
subject: 'product questions',
userData: {}

}).done(function(e){
// WebChatService started a chat successfully
}).fail(function(e){
// WebChatService failed to start chat
});

Can you please try using the sample code from one of these sources?

Tim,
can you help me implement the example available at the link below? or does it not work?

https://all.docs.genesys.com/WID/Current/SDK/WebChatService-combined#startChat

Hello,

Few info/comments.

I think the description of startChat command parameters is inaccurate.
When using a standard Chat Registration form, I think the parameters will be inside a form structure:
CXBus.command('WebChatService.startChat', { form: {firstname: ..., lastname: ..., email: ..., subject: ...}, userData: {}}).

I don't know if it is supported to call the startChat command directly.
A former documentation here mentions that it should not be invoked manually, whereas the last doc here does not mention that constraint/limitation.

  1. before command

I think Product Management and Engineering prefer that customizations leverage the before command.
The same approach than what is described here, but with WebChatService.startChat instead of WebChat.open (what the example shows).
You would have to modify the function parameter - options in the example. I believe the same comment I made in 1) will apply - modifying options.form.firstname, options.form.lastname, ....

Regards,

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.