Random 4 digits Number

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:

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

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?

Powered by HelpDocs

Powered by HelpDocs