Hyperchat Integration

Hyperchat escalation and integration

This example uses buildWithDomainCredentials to build the Chatbot SDK as explained in main page.

This example shows how to:

  • The configuration needed to use the nl-escalation-adapter.
  • The configuration needed for the hyperchat-adapter.
  • How to use the internal adapters.

For more information in each adapter:

Important note about the order of elements in the array

Make sure that you respect the order of the elements in the adapters array: because of the callback adapter system, to avoid any conflict, the first element of the adapter array must be the escalation adapter, and the next one the external chat adapter. Do not alter the order, or the subscriptions may not execute the callback as expected. This can cause the chatbot to malfunction or show unexpected behavior.

nl-escalation-adapter configuration

  • Perform the escalation after 2 responses with no results.
  • Display the following chatbotMessage "what else can I do for you?" when the user rejects the escalation.
  • Send to the API "NoAgentsAvailable" and display the intent content as a chatbotMessage when there are no agents available.

Hyperchat-adapter configuration

We will be using all the default configuration, and will only set the needed parameters:

  • appId: The ID of the HyperChat app.
  • region: The geographical region where the HyperChat app lives.
  • room: The room where the chat will be open, in this case will depend on the value of q in the url

In this examples we will be using both adapters from the internal code.

Integration code

<!DOCTYPE html>
<html>
    <head>
        <title>HyperChatBot Demo</title>
        <meta charset="utf-8">
    </head>
    <body>
        <script>
            window.buildUI = function () {
                var authorization = {
                    domainKey:'<example_domain_key>',
                    inbentaKey:'<example_api_key>'
                };

                var rejectedEscalation = {
                    action: 'displayChatbotMessage',
                    value: 'What else can I do for you?'
                };
                var noAgentsAvailable = {
                    action: 'intentMatch',
                    value: 'NoAgentsAvailable'
                };

                SDKHCAdapter.configure({
                    appId: '<chat_app_id>',
                    region: '<chat_app_region>',
                    room: function () {
                        return SDKHCAdapter.helpers.getQueryParameterValue('q');
                    },
                });

                var config = {
                    launcher: {
                        title: 'HyperChatBot Demo'
                    },
                    adapters: [
                        SDKlaunchNLEsclationForm(SDKHCAdapter.checkEscalationConditions,'ChatWithLiveAgentContactForm',rejectedEscalation, noAgentsAvailable, 3),
                        SDKHCAdapter.build(),
                    ],
                };

                InbentaChatbotSDK.buildWithDomainCredentials(authorization, config);
            };
        </script>
        <script src="https://sdk.inbenta.io/chatbot/1/inbenta-chatbot-sdk.js" onload="buildUI()"></script>
    </body>
</html>