• Adil Shaikh
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies

Here is sample code:  chat gets initiated by not creating or updating new contact in salesforce.

 

<html>
    <head><title> Live Agent Chat</title></head>
    <body>
        <div id="chat-icon">
            <form>
              <!-- Detail inputs -->
              <p>First Name:</p><input type="text" id="firstName" /><br />
              <p>Last Name:</p><input type="text"  id="lastName" /><br />
              <p>Email:</p><input type="text" id="email" /><br />
              <p>Mvelopes User Name:</p><input type="text" id="mvusrname" /><br />
              <input type="button" value="Submit" onClick="startChat();return false;">
            </form>         
        </div>
        <script type='text/javascript' src='https://c.la4-c1cs-was.salesforceliveagent.com/content/g/js/38.0/deployment.js'></script>
        
        <script type="text/javascript">
            function setName() {
                 document.getElementById("prechat_field").value = "Hellloooo";
                 return true;
            }
            function startChat(){
               liveagent.init('https://d.la4-c1cs-was.salesforceliveagent.com/chat', '572550000004CNP', '00D550000006VyM');
                if (!window._laq) { window._laq = []; }
                window._laq.push(function(){
                    liveagent.enableLogging();
                    liveagent.setChatWindowHeight('720');
                    liveagent.showWhenOnline('573550000004CiS', document.getElementById('liveagent_button_online_573550000004CiS'));
                    liveagent.showWhenOffline('573550000004CiS', document.getElementById('liveagent_button_offline_573550000004CiS'));
                  
                    liveagent.addCustomDetail('First Name', document.getElementById('firstName').value);
                    liveagent.addCustomDetail('Last Name', document.getElementById('lastName').value);
                    liveagent.addCustomDetail('Email', document.getElementById('email').value);

 <input type="hidden" name="liveagent.prechat.findorcreate.map:Contact" value="FirstName,firstName;LastName,lastName;Email,email" />
                    <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Contact" value="true" />
                    <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true" />
                    <input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Contact" value="Email,true" />
                    <input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Contact" value="Email,true" />
                    <input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Contact"                      value="FirstName,true;LastName,true;Email,true;Phone,true" />
                    liveagent.addButtonEventHandler('573550000004CiS',function (e){
                    if(e == liveagent.BUTTON_EVENT.BUTTON_AVAILABLE){              
                            liveagent.startChat('573550000004CiS');
                        }       
                    });
                });

            }
        </script>
    </body>
</html>

<apex:page showheader="false" doctype="html-5.0">
<script src="https://ap1.salesforce.com/soap/ajax/28.0/connection.js"></script>
<script src="https://ap1.salesforce.com/soap/ajax/28.0/apex.js"></script>
<apex:includeScript value="/support/console/34.0/integration.js"/>

  
<script type="text/javascript">
      
    
    function Stopfunc(){
        logic.....
    }
    
    function Startfunc(){

    }
    
    function test(){
        alert('hiii');
    }
    $(document).ready(function(){
        test();
    });   
    
</script>

 
<button onclick="Stopfunc();" id="stop_id"> Stop  </button>
<button onclick="Startfunc();" id="start_id"> Resume start </button>
</apex:page>

 

I want to call Stopfunc() and Startfunc() functions from javascript buttons.

<apex:page showheader="false" doctype="html-5.0">
<script src="https://ap1.salesforce.com/soap/ajax/28.0/connection.js"></script>
<script src="https://ap1.salesforce.com/soap/ajax/28.0/apex.js"></script>
<apex:includeScript value="/support/console/34.0/integration.js"/>

  
<script type="text/javascript">
      
    
    function Stopfunc(){
        logic.....
    }
    
    function Startfunc(){

    }
    
    function test(){
        alert('hiii');
    }
    $(document).ready(function(){
        test();
    });   
    
</script>

 
<button onclick="Stopfunc();" id="stop_id"> Stop  </button>
<button onclick="Startfunc();" id="start_id"> Resume start </button>
</apex:page>

 

I want to call Stopfunc() and Startfunc() functions from javascript buttons.