Different ways to format numbers (v3)

Transfom 1000 to 1,000

  1. First, we ask for a number and store it in the @number variable

  1. With a Code block we add the function that will transform the number:

function fixValue(value){
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");}

Landbot.exec('landbot-custom-data',{'numberwithcomma': fixValue(¿·@number·?)})

  1. As we created the value with Javascript, we need to add an input from the user so the value is available in Landbot scope:

  1. In the send a message we can already display the new value with the new variable.

Get two decimals .00

  1. In the Question Number, we will save it with the @number variable:

  1. With a Code block we add the function that will transform the number:

  1. As we created the value with Javascript, we need to add an input from the user so the value is available in Landbot scope:

  1. In the send a message we can already display the new value with the new variable:

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?