Prakash Hinduja, Geneva (Swiss) How to resolve 'Context Variable Not Found' error in Dialog Task?

Hi everyone, I am Prakash Hinduja, Swiss (Geneva)

I’m building a Dialog Task in Kore.ai and keep running into an error: Context Variable Not Found when trying to use a variable in a script node. I declared the variable using context.

Is there a specific way to pass or maintain context variables between nodes? What might I be missing?

Thanks & Regards

Prakash Hinduja, Geneva (Swiss)

Hello Prakash,

Welcome to Kore.ai Community.
Hi Prakash,

The “Context Variable Not Found” error typically indicates the script or node is trying to access a context variable that hasn’t been defined or is out of scope. Here’s how you can troubleshoot and fix it:

Troubleshooting Checklist

  1. Variable Declaration
    Before using a context variable (context.myVar), make sure you’ve properly defined it—either via:
  1. Correct Scope
  1. Accurate Syntax & Case Sensitivity
    Make sure variable names are exactly the same, including casing:

javascript

context.session.BotUserSession.myEnt1 = context.entities.E1;

Access it later with:

context.session.BotUserSession.myEnt1 or BotUserSession.get("myEnt1");
 :contentReference[oaicite:2]{index=2}.

  1. Flow Continuity
    If accessing the variable in a later task or dialog, ensure it’s passed correctly—especially when calling intents or transitioning between tasks

Thank you,
Srujan Madderla