How to write console logs and callbacks in Chat Functions

Is it possible to write console.log and callbacks in (ChatKitty | Dashboard - User Received Notification)?
if it is so, Anyone can please tell me how to achieve that?

Here is a snap for a reference

Hey @saravanan, welcome to ChatKitty Community!

The general pattern for logging your chat function invocations looks like this:

At the beginning of your chat function, declare a variable logs that is initialized to an empty array. When you want to log something, push a string to the logs array. Finally, return logs in the result of the function so it’s visible on the console.

async function handleEvent(event: UserReceivedNotificationEvent, context: Context) {
    const logs = []; // Declare log statement holder

    logs.push('Event was: ' + JSON.stringify(event)); // Log data of interest

    return {
        logs
    };
}

With this, you can view the logs by hovering over “Show result” in your Chat Functions Logs.

Screenshot 2021-06-30 055023

1 Like

@aerovulpe Thanks for letting me know the syntax for writing logs in ChatKitty | Dashboard.

1 Like