Random answers by chat bot



Hi there

I’ve created a little chat example. I think its quite nice on its own, but I have a question regarding the random functionality.

The bot should be able to generate random answers based on a set of values.
So how do you get a random string from a list in Axure?

Currently I use multiple cases with if statements - but obviously this doesn’t scale well.
Maybe adding another repeater would be a solution, but this creates just a lot of junk in the file.
What is your solution to this problem?

Here is the file:
Chat-Repeater.rp (84.4 KB)

And here is a preview:

FB Messenger chatbot prototype template?
Change font / have different fonts when using "Insert Variable or Function"
How to implement an Instant Messenger / Live Messenger

Hmm, another way to do it would be to store your bot responses in a repeater column, with the response numbers (e.g. 1, 2, 3) in another column. You could then have your button generate a random number, store it in a variable, and then refresh the repeater that contains your bot messages. OnItemLoad of that repeater, you can use a condition to check whether the randomly generated variable value matches the row number of one of your repeater rows, and if true, then that repeater adds the message from that matching row to the repeater that contains your chat message.

Here’s an example of the expression that would generate a random number between 1 and 3, for a repeater that has 3 bot responses (3 rows):

I’ve attached the sample file that allows you to add a random bot response to your existing repeater. Hopefully this helps!Random Response with Repeater and Math.Random().rp (57.5 KB)


Many thanks for the example.

PS: I have also found this topic. In case someone is looking for a solution with strings only.

Repeater chat with bot response and changing icon