Hello,
I'm having trouble getting to reflect the updated attributes to the participant data. When a new inbound message is received along with the custom attributes, the participant data doesn't get immediately updated. Instead, it will update when the next message is received.
Here's my code:
<script type="text/javascript" charset="utf-8">
(function (g, e, n, es, ys) {
g['_genesysJs'] = e;
g[e] = g[e] || function () {
(g[e].q = g[e].q || []).push(arguments)
};
g[e].t = 1 * new Date();
g[e].c = es;
ys = document.createElement('script'); ys.async = 1; ys.src = n; ys.charset = 'utf-8'; document.head.appendChild(ys);
})(window, 'Genesys', 'https://apps.cac1.pure.cloud/genesys-bootstrap/genesys.min.js', {
environment: 'xxx',
deploymentId: 'xxx'
});
let query
Genesys("subscribe", "MessagingService.messagesReceived", function ({ data }) {
if (data.messages[0].direction === "Inbound") {
query = data.messages[0].text;
console.log(query);
Genesys(
"command",
"Database.update",
{ messaging: { customAttributes: { "query": query } } },
function (data) {
/* fulfilled, returns data */
},
function () {
/* rejected */
}
);
}
});
</script>
Current behaviour:
User: "Hello" <-- Previous attributes.query = Hello -->
Agent: "How can I help you?"
User: "I have a question" <-- Current attributes.query = I have a question -->
Participant Data in Genesys Cloud:
query: "Hello"
Desired outcome:
User: "Hello" <-- Previous attributes.query = Hello -->
Agent: "How can I help you?"
User: "I have a question" <-- Current attributes.query = I have a question -->
Participant Data in Genesys Cloud:
query: "I have a question"
How can I achieve this?
Thank you!