The following built-in functions, can be used to debug or log events in your bot.

Please see the Scripting Functions Introduction for more information on Conversation Builder's built-in functions.

The Print Debug Message is used to log what user said in the debug console of the bot. For instance, the response variable stores the most recent messages from the user, which we print to the debugger using printDebugMessage.

Function Name Arguments Returns
printDebugMessage(message) message (string) – A message to print to the debug logs. None

Example

// get what the user just said
var response = botContext.getCurrentUserMessage();
botContext.printDebugMessage('User said ' + response);

Log Custom Event

Used for tracking specific bot events for the purposes of analytics. This function requires some type of user message and event name. The event detail is optional. In the example, we are setting the user message to the currentUserMessage and naming the event “Invoice API”.

Function Name Arguments Returns
logCustomEvent(user_message, event_name[, event_detail]) user_message - the user's message text

event_name - string
Void

Example

botContext.logCustomEvent(botContext.getCurrentUserMessage(), 'Invoice API','');

Log Escalation Event

Used to count the number of times the user called a particular escalation type. The function requries a user input and the string 'LivePerson' for the type of escalation.

Function Name Arguments Returns
logEscalationEvent(user_message, escalation_type) user_message - the user's message text

escalation_type - 'LivePerson'
void

Example

botContext.logEscalationEvent(botContext.getCurrentUserMessage(), 'LivePerson');