Lookig for a efficient method to determine if a user is a returning or first-time user of VA

Drothery
Giga Guru

I'm looking to implement a greeting in virtual agent that will display a different message the first time someone uses it, and then ashorter more succent message on subsequent visits.

 

I'm thinking the best method is simply to do a GlideAggregate count on the sys_cs_conversation table to see if the user has > 1 conversation records.

 

Just thought i'd check to see if there is a better approach, any thoughts?

 

1 ACCEPTED SOLUTION

Chris D
Kilo Sage
Kilo Sage

Not sure if it's because the sys_cs_conversation table has much more data than the interaction table or it's just not indexed (as well) ootb, but I'd limit querying the conversation table unless needed. 

In this case, I don't think it's needed - I think you may be better off querying the interaction table where Type = Chat and Virtual Agent = true. Feel free to experiment yourself - I'm just basing this off my past experiences querying the two tables manually.

View solution in original post

5 REPLIES 5

Paul Curwen
Giga Sage

You could take a look at the table 'provider_user_map' if there is no entry in their for the user they have no linked account yet. 

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0941256

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul

Isn't that just for users that use - and link their accounts for - VA integrations (Teams, Slack, etc.)?

Chris D
Kilo Sage
Kilo Sage

Not sure if it's because the sys_cs_conversation table has much more data than the interaction table or it's just not indexed (as well) ootb, but I'd limit querying the conversation table unless needed. 

In this case, I don't think it's needed - I think you may be better off querying the interaction table where Type = Chat and Virtual Agent = true. Feel free to experiment yourself - I'm just basing this off my past experiences querying the two tables manually.

Thanks, I'll go with this approach. I did look into querying the conversations table, not realising that a users servicenow profile is not stored against the records. There's an intermediate "consumer" table that maps from sys_user to conversation, which means i would have had to make multiple queries.

 

Querying the interaction table is much simpler, i'll do that. Cheers!

For completness, this is what I ended up doing (before taking your advice on board) - don't do this!

    var conversations = 0;

    var consumer = new GlideRecord('sys_cs_consumer');
    consumer.addQuery('user_id', vaInputs.user);
    consumer.query();

    if (consumer.next()) {

        var count = new GlideAggregate('sys_cs_conversation');

        count.addQuery('consumer', consumer.getUniqueValue());
        count.addAggregate('COUNT');
        count.query();

        if (count.next())
            conversations = count.getAggregate('COUNT');
    }
    vaVars.conversation_count = conversations;