Thielak
Developer
Posts: 14
Joined: Tue May 02, 2017 11:59 pm

Get a random value from Var/User/Bot

Sun Jun 11, 2017 1:28 am

Reading the forum I found out you can add multiple values to a variable (e.g. <User Add="test">value1</User>) and then list them using <User List="test" />.
Is there any way, or would it be possible to add a way to pick one single value at random (like <User Random="test" />)?

User avatar
Fantom
Help & Support
Posts: 320
Joined: Fri Oct 25, 2013 9:20 pm

Re: Get a random value from Var/User/Bot

Sun Jun 11, 2017 11:17 am

I don't think thats possible with values in user settings variable. Even if you modified the "List-Separator" and "List-End" variable values for Bot settings it would have a global impact which would be bad. I think the right way to get this done is via a custom adapter.

Thielak
Developer
Posts: 14
Joined: Tue May 02, 2017 11:59 pm

Re: Get a random value from Var/User/Bot

Mon Jun 12, 2017 1:45 am

I understand, I just thought it would be nice to create a Model like "tell me one of your favorite movies" and the bot answering with one from the list using something like <Bot Random="Favorite_Movies" />

Code: Select all

<Siml Version="1.0">
 <BotSettings>
  <Variable Name="Favorite_Movies">
   <Value>Contact</Value>
   <Value>God Father</Value>
   <Value>Life Is Beautiful</Value>
   <Value>Green Miles</Value>
  </Variable>
 </BotSettings>
</Siml>

User avatar
Leslie
Lead Software Architect
Posts: 377
Joined: Fri Sep 14, 2012 12:20 pm
Contact: Website

Re: Get a random value from Var/User/Bot

Mon Jun 12, 2017 11:21 am

There you go.

Try

SIML Code

<Random Get="favorite_movies" Source="Bot"/>
in v2.1.3

Please note this hasn't been committed to the specification and is an additional add-on to the Random tag implementation. If in the future there's any change, running the the SIML optimization tool (will made available in Bot Studio) would automatically adjust your SIML code.

Thielak
Developer
Posts: 14
Joined: Tue May 02, 2017 11:59 pm

Re: Get a random value from Var/User/Bot

Mon Jun 12, 2017 12:14 pm

Leslie wrote:Try

SIML Code

<Random Get="favorite_movies" Source="Bot"/>
in v2.1.3
That works perfectly, thank you!

I'm sorry if I haven't thought of it before but I had more ideas about variables with multiple entries.
More specifically, I thought about something like <Bot Count="favorite_movies" /> to get how many entries there are, and maybe a <Bot Get="favorite_movies" Index="2" /> to get a specific one.
I'm not sure if the second one would even be feasible to implement or if either of them would be useful in the eyes of the devs, but throwing ideas at you can't hurt right :P

Return to “Feature Request and Suggestions”

Who is online

Users browsing this forum: No registered users and 1 guest