From https://developer.mypurecloud.com.au/developer-tools/#/webchat
<script src="https://apps.mypurecloud.com.au/widgets/9.0/cxbus.min.js" onload="javascript:CXBus.configure({debug:false,pluginsPath:'https://apps.mypurecloud.com.au/widgets/9.0/plugins/'}); CXBus.loadPlugin('widgets-core');"></script>
<script>
window._genesys = {
"widgets": {
"webchat": {
"transport": {
"type": "purecloud-v2-sockets",
"dataURL": "https://api.mypurecloud.com.au",
"deploymentKey": "1234",
"orgGuid": "abcdef",
"interactionData": {
"routing": {
"targetType": "QUEUE",
"targetAddress": "General Queue",
"priority": 2
}
}
},
"userData": {
"addressStreet": "",
"addressCity": "",
"addressPostalCode": "",
"addressState": "",
"phoneNumber": "",
"customField1Label": "Test 1",
"customField1": "123",
"customField2Label": "Test 2",
"customField2": "123",
"customField3Label": "Test 4",
"customField3": "123456789"
}
}
}
};
function getAdvancedConfig() {
return {
"form": {
"autoSubmit": false,
"firstname": "",
"lastname": "",
"email": "",
"subject": ""
},
"formJSON": {
"wrapper": "<table></table>",
"inputs": [
{
"id": "cx_webchat_form_firstname",
"name": "firstname",
"maxlength": "100",
"placeholder": "Required",
"label": "First Name"
},
{
"id": "cx_webchat_form_lastname",
"name": "lastname",
"maxlength": "100",
"placeholder": "Required",
"label": "Last Name"
},
{
"id": "cx_webchat_form_email",
"name": "email",
"maxlength": "100",
"placeholder": "Optional",
"label": "Email"
},
{
"id": "cx_webchat_form_subject",
"name": "subject",
"maxlength": "100",
"placeholder": "Optional",
"label": "Subject"
}
]
}
};
}
const customPlugin = CXBus.registerPlugin('Custom');
</script>
<button type="button" id="chat-button" onclick="customPlugin.command('WebChat.open', getAdvancedConfig());">Start Chat</button>