Skip to content

User ID metrics is not easy to implement #479

@epetecof

Description

@epetecof

Now that Watson Assistant Plus and Premium are charged based on unique users per month it would be nice to have a msg.params.user_id property for the AssistantV2 node, in order to specify your unique identifier.

I was trying to do it using the msg.additional_context property for including context.global.system.user_id in my messages (as recommended in this link of the documentation), but after a few tries I saw that the analytics tab showed no data for unique users.

Looking at the code, I discovered that the msg.additional_context property is only suitable for adding variables in the user defined context (context.skills.main skill.user_defined). As a work around (for you that, like me, spent some time banging your head against the wall) I discovered that you can change the root context using msg.params.context, but you need to maintain the same pattern used in the original code (or it will break the msg.additional_context logic), like this:

msg.params = {
        context: {
            global: {
                system: {
                    user_id: msg.twilio.From
                }
            },
            skills: {
                'main skill': {
                    user_defined: {}
                }
            }
        }
    }

Please let me know if there is already a better way to do this, I didn't find it. Thanks!

OBS: If you are using Twilio, like me, it is a good idea to use the Body.From property as your identifier

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions