Developers

Agent Chat Integration

Agent Chat escalation and integration

This example uses buildWithDomainCredentials to build the Chat SDK, as explained on the main page.

It also uses the NL (Natural Language) escalation 2 adapter included in the SDK from version 1.31.0.

This example shows:

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

For more information about each adapter, see:

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 Chat app to malfunction or show unexpected behavior.

NL (Natural Language) escalation 2 configuration

This adapter requires certain intents and the escalation dialog. For more information, see Default contents for Agent Chat escalation(This link redirects you to the Help Center).

Agent Chat-adapter configuration

This example uses the default configuration. You only need to set the required parameters:

  • apiKey: The key of the Agent Chat API (former "appId"). This defines the instance in which the chat opens.
  • region: The geographical region where the Agent Chat app lives.
  • room: The room where the chat will be open, in this case will depend on the value of q in the url

This example uses both adapters from the internal code.

Integration code

<!DOCTYPE html>
<html>
    <head>
        <title>Agent Chat Demo</title>
        <meta charset="utf-8">
    </head>
    <body>
        <script>
            window.buildUI = function () {
                var authorization = {
                    domainKey:'<example_domain_key>',
                    inbentaKey:'<example_api_key>'
                };
                SDKHCAdapter.configure({
                    apiKey: '<chat_api_key>', // former "appId"
                    region: '<chat_app_region>',
                    room: function () {
                        return SDKHCAdapter.helpers.getQueryParameterValue('q');
                    },
                });

                var config = {
                    launcher: {
                        title: 'Agent Chat Demo'
                    },
                    adapters: [
                        SDKNLEscalation2(SDKHCAdapter.checkEscalationConditions),
                        SDKHCAdapter.build(),
                    ],
                };

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

The appId parameter is DEPRECATED in favor of apiKey, for consistency with Inbenta terminology. If you use appId, Inbenta recommends that you update your configuration.