How to use 3rd Party Reporting System

In this document, you will learn how to use a third-party reporting system.

The 3rd party reporting system could be used by giving the following inputs to the 3rd party system in the desired message format.

  • The user input to the chatbot

  • The response of the chatbot to the given user input

Prerequisite:

To utilize the 3rd party reporting system, the following details of the reporting system are required. These details could be obtained from the 3rd party provider.

  1. 3rd party reporting systemā€™s account

  2. Url

  3. Key

  4. Message format (JSON)

With the above details, the required data are sent to the 3rd party in JSON format in a payload.

Example:

The below example is of Dashbot reporting:

  • ā€œInput to Dashbotā€ Node: Through this node, the user input to the chatbot is fed to the 3rd party reporting system.

  • ā€œOutput for Dashbotā€ Node: Through this node, the chatbotā€™s response to the user input is fed to the 3rd party reporting system.

Dashbot requires a different JSON structure for Google & Alexa. So the structure is constructed based on that. The Below code of Dashbot will give you an idea of how the message is constructed.

Code inside ā€œInput to Dashbotā€œ node:

var apiKeyAlexa = msg.apiKeyAlexa; var apiKeyGeneric = msg.apiKeyGeneric; var analytics = msg.analytics; if (analytics.dialog.surface == 'Alexa') { var dashbot = { "event": { "version": "1.0", "session": { "new": analytics.dialog.sessionNew, "sessionId": analytics.sessionId, "application": { "applicationId": analytics.applicationId }, "attributes": {}, "user": { "userId": analytics.user.userId } }, "request": { "type": analytics.dialog.type, "requestId": analytics.requestId, "timestamp": analytics.timeStampStart, "intent": { "name": analytics.intent, "slots": analytics.slots } } } }; msg.dashbot = dashbot; msg.url = 'https://tracker.dashbot.io/track?platform=alexa&v=9.4.0-rest&type=incoming&apiKey=' + apiKeyAlexa; msg.payload = dashbot; return msg; } else { analytics.user.currentUserId = null; // we don't want to store that in analytics var dashbot = { "text": analytics.dialog.utterance, "userId": analytics.user.userId, "platformJson": analytics }; msg.dashbot = dashbot; msg.url = 'https://tracker.dashbot.io/track?platform=generic&v=9.4.0-rest&type=incoming&apiKey=' + apiKeyGeneric; msg.payload = dashbot; return msg; }

Ā 

Code inside ā€œOutput for Dashbotā€ node:

var apiKeyAlexa = msg.apiKeyAlexa; var apiKeyGeneric = msg.apiKeyGeneric; var analytics = msg.analytics; if (analytics.dialog.surface == 'Alexa') { var dashbot = { "event": { "version": "1.0", "session": { "new": analytics.dialog.sessionNew, "sessionId": analytics.sessionId, "application": { "applicationId": analytics.applicationId }, "attributes": {}, "user": { "userId": analytics.user.userId } }, "request": { "type": analytics.dialog.type, "requestId": analytics.requestId, "timestamp": analytics.timeStampEnd, "intent": { "name": analytics.intent, "slots": analytics.slots } } }, "response": { "version": "1.0", "sessionAttributes": {}, "response": { "shouldEndSession": analytics.shouldEndSession, "outputSpeech": { "type": "SSML", "ssml": "<speak>" + analytics.responseText + "</speak>" } } } }; msg.dashbot = dashbot; msg.url = 'https://tracker.dashbot.io/track?platform=alexa&v=9.4.0-rest&type=outgoing&apiKey=' + apiKeyAlexa; msg.payload = dashbot; return msg; } else { analytics.user.currentUserId = null; // we don't want to store that in analytics var dashbot = { "text": analytics.responseText, "userId": analytics.user.userId, "platformJson": analytics }; msg.dashbot = dashbot; msg.url = 'https://tracker.dashbot.io/track?platform=generic&v=9.4.0-rest&type=outgoing&apiKey=' + apiKeyGeneric; msg.payload = dashbot; return msg; }

Ā