Database ready event is not working

Hi everyone,

I'm trying to do a web messaging sending custom attributes with Database events, everything is fine with the first conversation (database ready event is published and custom attributes added). The problem is when the first conversation is ended (I use the MessagingService.clearConversation to clear the conversation and in this form the end user can't see the previous conversation) and begin a new conversation, this conversation doesn't publish the database ready event so in this way I can't send the custom attributes,

Is there a way to reactivate the database ready event?

Any help really appreciate it

Hi @despinoza,

The custom attributes are cleared from the Database plugin after the conversation is cleared. You need to set the custom attributes again using Database.set command. By default Database.ready event is published only once when it is initialized during a page load, so ideally you can't depend on that at this point of time since Database plugin is already available for you.

What you can do is subscribe to MessagingService.conversationCleared event and call Database.set command with new custom attributes here, in this way you are setting the custom attributes ready in the Database plugin and they will get sent along when ever new conversation begins.

Or you can do the same thing even by subscribing to MessagingService.started event, but note that it may be sent in the next subsequent text message after the conversation has started (depending on how you start the conversation).

Let me know if this helps.

1 Like

Thanks Ranjith, what worked for me was call Database.set inmediatly after MessagingService.conversationCleared event, so in this way in the next conversations after the first one we can receive participant data and validate in the flow. The other option is how you said, it needs two or three messages after the conversation has started to send the attributes and for me is not a validate solution because what we need is receive this attributes to validate in the flow at the start of conversation,

here is my final solution:

Genesys("subscribe", "MessagingService.conversationDisconnected", function({data}){
console.log("conversation Disconnected");
sessionStorage.setItem("Nombre", $("#primerNombreChat").val());
sessionStorage.setItem("Apellido", $("#apePaternoChat").val());
sessionStorage.setItem("Rut", $("#rutDvChat").val());
Genesys("command", "MessagingService.clearConversation");
Genesys("command", "Database.set", {
messaging: {
customAttributes: {
name: sessionStorage.getItem("Nombre") + " " + sessionStorage.getItem("Apellido"),
Nombre: sessionStorage.getItem("Nombre"),
Apellido: sessionStorage.getItem("Apellido"),
Rut: sessionStorage.getItem("Rut"),
}
}
});
});

Thank you for your assistance

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.