Table of Contents

Random 4 digits Number (Web)

Pau Sanchez Updated by Pau Sanchez

Generate a 4 digits random number to be used in a variable to verify a phone number. Send this number to a third party app and validate your users by checking if their input matches or not, therefore validate if their phone number is real.

You can see a demo by clicking here.

To achieve this just add the following JS snippet in the Add JS (Custom scripts) option of the Advanced section of the Design tab:

Landbot 3

<script>
var landbotScope = this;
this.onLoad(function(){
const randomNumber = Math.floor((Math.random() * 9999) + 1);
landbotScope.setCustomData({randomnumber:randomNumber})
})
</script>

You can display this random number using the variable we custom created: @randomnumber . Bear in mind this variable won't display in any of the variables' lists.

Landbot 2

<script>
const randomNumber = Math.floor((Math.random() * 9999) + 1);
Landbot.exec("landbot-custom-data", {"randomnumber":randomNumber})
// ualee_002 //
</script>

You can display this random number using the variable we custom created: @randomnumber . Bear in mind this variable won't display in any of the variables' lists.

This function will be triggered once the bot loads. However, the random number (@randomnumber) variable won't be available until the user interacts with the bot.
These scripts and how to's are not native functionalities. Landbot won't be able to support, help or guarantee these scripts and how to's. These Workarounds and How to's are for developers, as a learning and example material on how to extend or modify some of the platform limitations.Β  Due to platform updates, some scripts might stop working in the future.Please, note that in case of Scripts and Workaround the Custom Success Team can deliver limited support.

How did we do?

Contact