File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,27 @@ <h2>godwin@sdb3.org</h2>
7171 isWithinBusinessHours = true ;
7272 console . log ( 'onEmbeddedMessagingWithinBusinessHours: ' + isWithinBusinessHours ) ;
7373 } ) ;
74+ window . addEventListener ( 'onEmbeddedMessagingButtonCreated' , function ( ) {
75+ console . log ( 'onEmbeddedMessagingButtonCreated: fired, isWithinBusinessHours = ' + isWithinBusinessHours ) ;
76+ try {
77+ var launchChat = ( ) => {
78+ console . log ( 'pointerdown: isWithinBusinessHours = ' + isWithinBusinessHours ) ;
79+ if ( isWithinBusinessHours ) {
80+ window ? . embeddedservice_bootstrap ? . utilAPI ? . launchChat ( ) ;
81+ }
82+ } ;
83+ document . getElementById ( "embeddedMessagingConversationButton" ) . addEventListener ( "pointerdown" , launchChat , true ) ;
84+ if ( ! window ? . embeddedservice_bootstrap ? . prechatAPI || isLaunched )
85+ return ;
86+ if ( isWithinBusinessHours ) {
87+ console . log ( 'onEmbeddedMessagingButtonCreated: auto-launching chat' ) ;
88+ window ? . embeddedservice_bootstrap ? . utilAPI ? . launchChat ( ) ;
89+ isLaunched = true ;
90+ }
91+ } catch ( err ) {
92+ console . error ( 'Error launching chat: ' , err ) ;
93+ }
94+ } ) ;
7495 </ script >
7596 < script type ='text/javascript '>
7697 function initEmbeddedMessaging ( ) {
You can’t perform that action at this time.
0 commit comments