Identifying a Unique Endpoint via analytics

Challenge

In my project I have multiple webchat endpoints for different bots that all reference the same flow. How do I uniquely flag an endpoint so I know which analytics records belong to each?

Solution

The analytics data already contains the endpointType e.g. "webchat", "Dialogflow", "adminconsole" etc.. However, if you have multiple endpoints of the same type and want to differentiate between them, you need to provide a small customization to your agent.

Key concept: Every message sent to Cognigy includes both a "text" value and a JSON "data payload". Sometimes the data payload is empty, sometimes it contains channel specific information.

Each endpoint has a unique transformer that can be used to adjust the messages and data going between the channel and Cognigy. As this function is unique to every endpoint, you can insert a data variable to the data payload of each message that contains a customized endpoint name.

By doing this, the Cognigy flow receives the unique name under {{input.data.endpointName}} and you can use the "Overwrite Analytics" node to add this to the Analytics Data records.

Here is an example input transformer for the Webchat Endpoint. (Please note the code required will vary depending on the endpoint but the concept is the same). This input transformer adds the "endpointName" variable to the data payload of every message sent to the Cognigy flow.

    handleInput: async ({ payload, endpoint }) => {
        const data = payload.data ?? {};
        data.endpointName= 'webchat-endpoint-one';
        return {
            userId: payload.userId,
            sessionId: payload.sessionId,
            text: payload.text,
            data: data
        };
    }
Once you have confirmed this data value is being received by the Cognigy flow, add an Overwrite Analytics node to the locations in your flow that you want this value to provided to the analytics records. If you simply want to track the number of sessions, add this node inside a once node at the start of your first flow.
uniqueEndpointName.PNG
In this example, the "custom1" analytics value is being overwritten with the unique endpoint name.
With this setup, you will be able to track the number of sessions per unique endpoint via your custom endpoint name that has been added to the analytics records.

   Watch Cognigy Sessions Episode "Endpoint Transformers" and "Analytics & OData" for a technical deep dive

Webchat Widget Client Customization

A feature unique to the Cognigy Webchat widget is that you can customize the channel name.
This is achieved by adjusting the "channel" parameter in the html script that initiates the webchat on the website it is embedded in. This value is carried forward to the analytics to be used as the name for the channel.
analytics.PNG
You can find documentation for this at the following link:
Additionally, here is an example of the JSON object used in the "initWebchat" command:
 {
userId: "documentation-reader",
channel: "custom-name-webchat",
forceWebsockets: true
}
code.PNG

Comments

0 comments

Please sign in to leave a comment.

Was this article helpful?
1 out of 1 found this helpful