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 }; }
Watch Cognigy Sessions Episode "Endpoint Transformers" and "Analytics & OData" for a technical deep dive
Webchat Widget Client Customization
{
userId: "documentation-reader",
channel: "custom-name-webchat",
forceWebsockets: true
}
Comments
0 comments