Exploring the differences between koreDebugger.log() and console.log()

For those familiar with JavaScript, console.log () might seem like the natural choice for logging messages. However, within Kore.ai’s environment, koreDebugger.log() takes center stage.

Why koreDebugger.log()?

While you could technically define your own console object with a log() method, Kore.ai provides koreDebugger.log() for a specific reason. This function offers advantages within the Kore.ai development environment:

  • Integration with Debugging Tools: koreDebugger.log() messages are likely integrated with Kore.ai’s debugging tools, allowing you to view and Analyze them more effectively within the platform.
  • Potential Namespace Conflicts: Defining your own console object might lead to conflicts with other libraries or frameworks that might also use the same name.

The Workaround: Simulating console.log()

The provided workaround offers a solution for those who prefer the familiarity of console.log().

  1. Create a JavaScript file with the following contents:
console = { 
log: function (message) { 
koreDebugger.log(message); 
}
 };
  1. Add the file to Configurations => Bot Functions
  2. You can then use console.log() in your JavaScript code

Important Note:

The workaround highlights that the console object itself might be defined as null within the Kore.ai environment. This reinforces the importance of using koreDebugger.log() or the provided workaround for effective logging.

Content Credit @david.gwartney