Can we modify global variables in kore.ai bot

I would like to use global variable as normal variable that store values every time
like this <env.variable = context.somevalue>
But it is not working like variable, it is working like constant

Hi @srihari.posanapalli,

Ideally, global variables are static and can only be modified through UI.

You can use BotUserSession variables which will persist the value all over the bot for that specific user and session. These variables are dynamic.
Please refer the following document for more information on variables:
https://developer.kore.ai/docs/bots/bot-builder-tool/dialog-task/using-session-and-context-variables-in-tasks/

Let us know if you have any further issues/queries.

Regards,
Yoga Ramya.

In a Service Node, Web service, REST POST request body, How do I modify arrays of JSON body with varaiables

My full json body is this,

{ “startInfo”:
{ “ReleaseKey”: “{{context.entities.input_ReleaseKey}}”,
"Strategy": “{{context.entities.input_Strategy}}”,
"RobotIds": [ 123457 ],
"NoOfRobots": 0,
"Source": “Manual”,
"InputArguments": "{}"
}
}

I have tried this, error is at “RobotIds”: [ “{{context.entities.input_RobotID}}” ]
Error while giving Variables in array

Array Data type is Numeric

Hi @srihari.posanapalli,

Providing values to a parameter in an Array format is not supported, however, you can try to push these array values into the context variables through a script node.

https://developer.kore.ai/docs/bots/bot-builder-tool/dialog-task/using-session-and-context-variables-in-tasks/

And use the context variable as value to the parameter.

Let us know if you need any further information.

Regards,
Yoga Ramya

Hi @yogaramya.mendu,
The problem here is, “” added to array, like this "[values]", but my requirement is [values], it must be without having Double quotes. if we have double quotes it will be error

I need this in that json body “RobotIds” : [ 145282, 785432]

But to achieve this we generally used “{{variable}}” —> “RobotIds”: “{{context.entities.input_RobotID}}”
suppose context.entities.input_RobotID = [ 145282, 785432]
so it resulting like this “RobotIds”: “[ 145282, 785432]”

even if i used context variables also same issue.
or is there any way to add json object directly to the body

please help me

@yogaramya.mendu
Hi, We are also facing the same issue while passing context variable valued to POST request body, it is considering it as string.

Hello @truptidudhanikar @srihari.posanapalli ,

When using context variable as part of payload for an API, it is recommended to create the payload json in a script node first.

For example your payload should look like:

{ 
“startInfo”:
                         { 
                           “ReleaseKey”: context.entities.input_ReleaseKey,
                           "Strategy": context.entities.input_Strategy,
                           "RobotIds": [ 123457 ],
                           "NoOfRobots": 0,
                           "Source": “Manual”,
                           "InputArguments": "{}"
                         }
}

There is no reason to use parenthesis for the entities, since we are not using it in message prompt.

As for using array for a parameter - you may create a custom variable like context.arrayId assign values to that and simply use this context variable in the body.

Hope this helps… Let me know if you have any other questions.