Database.set attributes using MessagingService.sendMessage

This is a follow on from MessagingService Plugin - Start Web Messaging - #3 by Darren_Sawyer

If I use the "Database.set" command followed by the "MessagingService.sendMessage" command should the attributes set be written to participant data?

What I have observed is that attributes that are set via the "Database.set" command are only written to participant data in Genesys Cloud if the customer sends a message on the chat.

For example the attributes get set when I as the customer send "Yes" but I want the attribute to be set when the JS sends "Survey Opt In: Yes"

The reason I these attributes set is I want to be able to make a routing decision based on the flag set. But it isn't being set when I use "sendMessage". I am missing something from the "sendMessage" command?

Here is an example of my code:

(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.mypurecloud.ie/genesys-bootstrap/genesys.min.js', {
    environment: 'euw1',
    deploymentId: 'XXXXXXX-XXXXXXXXXX-XXXXXXXX-XXXXX'
});
// Initialise Database
Genesys("subscribe", "Database.ready", function () {
    console.log("Database plugin is ready.")
});
// Listen for conversationDisconnected event to initiate re-initate the message.
Genesys("subscribe", "MessagingService.conversationDisconnected", function ({ data }) {
    console.log(data);
	// Set customer attribute for surveyOptIn
    Genesys("command", "Database.set", { messaging: { customAttributes: { surveyOptIn: 'true' } } },
        function (data) {
            console.log("Survey Opt In: Success");
        }, function () { console.log("Survey Opt In: Failed"); });
	// Set participant data at this point
    Genesys("command", "MessagingService.sendMessage", {
        message: "Survey Opt In: Yes"
    },
        function () {
            /*fulfilled callback*/
        },
        function () {
            /*rejected callback*/
        }
    );
});

Thanks,
Darren

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