The code included in this section is a basic example of the code you would use to display a button which launches a call between an agent and a visitor when it is clicked.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script type="text/javascript" src="https://api.atgsvcs.com/call/clicktocall-1.0.js"></script>
<script type="text/javascript">
var mycallobj = new livehelp.Call({
target: "18001234567", // This is the website visitor's phone number
contactId: "123456" // This is the ID of the link from Webcare
});
</script>
</head>
<body>
<input type="button" value="Phone me" onclick="mycallobj.start();">
</body>
</html>
There are a number of points to note from this example;
The contactId field must identify a link that has been created in Webcare.
A livehelp.Call object is instantiated. This is done by calling the constructor with an options object as an argument.
This in turn contains two properties:
The target, or phone number of the website visitor. This is likely to have been captured by a form field and passed to the constructor function
The contactId (a.k.a. link ID), created in Webcare, which points to an agent.
When clicked, the button on the page calls the function mycallobj.start() to initiate the call.