In our application, we use the Database plugin from the Messenger JavaSript SDK to set a custom attribute on conversation start. Through out the conversation we could retrieve the same attribute using Database.get command successfully.
However, if the page is refreshed and we try to get the attribute again after the MessengingService.restored event is published, we get an empty object from the response of Database.get command.
We would like to ask if this is the expected behavior?
Code snippet is shown below:
function startConversation() {
Genesys("command", "Database.update", { messaging: { customAttributes: { Custom_Attribute_A: "abc" } } });
Genesys("command", "MessagingService.startConversation",
{},
() => {
Genesys("command", "Database.get", {}, (data) => {
// This logs {"messaging":{"customAttributes":{"Custom_Attribute_A":"abc"}}}
console.log(data);
});
},
() => {}
);
}
// Called after MessagingService is ready on page load
function subscribeToRestore() {
Genesys("subscribe", "MessagingService.restored", () => {
Genesys("command", "Database.get", {}, (data) => {
// This logs an empty object {}
console.log(data);
});
}
}