Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to access contextVariables in a VA topic flow?

Tomas Stravinsk
Kilo Contributor

Hi, 
I'm making a POST request to my VA API with the following payload:

{
      requestId: uuidv4(),
      enterpriseId: 'ServiceNow',
      clientSessionId: conversationId,
      message: {
        text: message,
        typed: true,
      },
      userId: context.activity.from.id,
      timestamp: dayjs().unix(),
      timezone: context.activity.localTimezone,
      token: this.config.API_TOKEN,
      contextVariables: {
        name: "John"
      }
};

The issue I'm facing is that I'm unsure how to extract the "name" context variable inside a topic flow.

I've tried creating a "name" context variable through the chat setup menu, added it to the topic flows active Live Agent Variables, but still get nothing.

Any help would be much appreciated.

1 ACCEPTED SOLUTION

Victor Chen
ServiceNow Employee

Have you tried accessing the context variable in a conversation script via vaContext.name? 

View solution in original post

4 REPLIES 4

Victor Chen
ServiceNow Employee

Have you tried accessing the context variable in a conversation script via vaContext.name? 

You are correct, I'm able to access the passed context variables through vaContext, but I'm only able to achieve this when starting a conversation, with the "action: START_CONVERSATION" variable in the payload. If i try to pass context variables to an ongoing conversation it doesn't seem to work.

Hi @Tomas Stravinsk, I'm having the same issue. Were you able to make it work for ongoing conversation?

Hi Victor,

Similarly if I am sending "clientVariables" in the JSON as:

{
      requestId: uuidv4(),
      enterpriseId: 'ServiceNow',
      clientSessionId: conversationId,
      message: {
        text: message,
        typed: true,
      },
      userId: context.activity.from.id,
      timestamp: dayjs().unix(),
      timezone: context.activity.localTimezone,
      token: this.config.API_TOKEN,
      clientVariables: {
        name: "John"
      }
};

 How do I access the "clientVariables" field in the topic flow?