Examples

tog_minusSimple Example

In this example, the JavaScript code agentapp.js is included, and a new AgentApp instance is created by calling the AgentApp constructor. The parent element in which the AgentApp component will be shown is passed.

<!DOCTYPE html>

<html>

<head>

    <title>Host Application</title>

    <script src="agentapp.js"></script>

</head>

<body>

    <script>

    $(function() {

       var agentapp = new AgentApp(document.getElementById('main-container'));

    });

    </script>

    <div id="main-container" 

 style="width:100%; margin-right: auto; margin-left: auto;height: 600px;"/>

</body>

</html>

tog_minusComplex Example

In this example, a specific Interaction is started, in which the search bar and the tabs are hidden. The loaded event is registered to get the page loaded.

A connection to the Interaction Server is established on port 9090 (which is not the same as the location of the AgentApp), using the specified applicationKey. A callback function, to be run when the Agent Application completes initializations, is also supplied. The function shown here checks whether a direct link to an interaction ID (intId) or a history instance ID (uniqueId) were supplied in the URL, and then calls the appropriate function from the AgentApp API.

<script>

 

    $(function() {            

       var agentOptions = {

                layout: {

                        showSearch:false,

                  showTabs:false,

                  showInteractionsList:false

                },

             connection: {

                 accountId :‘myaccount’,

                 port:9090

             },

                authentication: {                 

                  applicationKey : “myKey”

             }        

       };

       var agentapp = new AgentApp(document.getElementById('main-container'),

                                   options, function() {

                // For Direct link - start interaction

                if (intId) {

                    agentapp.startInteraction(intId, $.url().param('int-name'));

                }

                else if(uniqueId) {

                    agentapp.loadHistory(uniqueId);

                }

       });

   });

</script>