Reading BotUserSession in SmartAssist

Hi all,

I’m calling a bot from SmartAssist. The bot sets some values in BotUserSession.

Now I want SmartAssist to branch conditionally based on the values the bot set. Is there a way to read them in SmartAssist?

Hi @eeskildsen,

You can read BotUserSession values in SmartAssist Experience Flow. Here’s some sample code showing this:

setCallFlowVariable('caller', context.BotUserSession.channels[0].handle.Caller);
var caller = getCallFlowVariable('caller');

Thanks,
Ashish

1 Like

Thanks @ashish.sankhala!

Is this documented anywhere? There are 0 search results for BotUserSession at https://docs.kore.ai/smartassist/. Want to make sure I’m looking in the right place…

You are looking at the right place. We are working on getting this and other related documentation uploaded

@ashish.sankhala, this isn’t working for me…What am I doing wrong?

Steps To Reproduce

  1. In a BotBuilder:
    1. In a dialog task, add a Script node. Definition: BotUserSession.put('favoriteKoreEmployee', 'Ashish Sankhala');
  2. In SmartAssist:
    1. Add a Run Automation node. Have it call the dialog task.
    2. Add a Script Task node. Definition: context.favoriteKoreEmployee = context.BotUserSession.get('favoriteKoreEmployee');

Expected Behavior

context.favoriteKoreEmployee is set to Ashish Sankhala in SmartAssist.

Actual Behavior

SmartAssist says:

We’re having trouble processing your request. Please call us after some time.

Then the call ends.

Hi Erik,

I believe you should go through this link to get a high level understanding of how SmartAssist integrates with the XO platform - Introduction to SmartAssist – SmartAssist. This might help as a starting point.

Coming to your exact use case, it appears you are trying to pass a value from your BotUserSession to use within the Experience Flow.

You will need to

  1. Retrieve the automation (or the child) bot’s context using getChildBotContextById()

Sample Usage cbCtx = getChildBotContextById("st-123bd11e-247e-58ec-bfe4-81e0f8b3e0fc”)

You can get your bot’s ID by navigating to Bot → Build → Configuration → General Settings

  1. You can then refer to favoriteKoreEmployee using the following fully qualified name cbCtx.session.BotUserSession.favoriteKoreEmployee

Hope this helps (and works!)

Thanks,
FavoriteKoreEmployee

1 Like

@ashish.sankhala Very cool! I feel like I’m learning the secrets of the sages here. Thanks, I’ll give it a try.

Hello @ashish.sankhala
how can i use context in smartAssist i want to try to use split condition if i use (session.BotUserSession.LanguageP) how can i get the value of this context in smart Assist

Best Regards

from where you find it i want dialed number