Updated: 8/9/2024

Other methods used in Botmaker

Here you will learn about other methods used within the Botmaker platform.



Here you will learn about other methods used on the Botmaker platform.
Estimated reading time: 03 minutes


Freemarker


We use Freemarker as a "template engine" for bot responses. You can get more information at the following link: Freemarker. We have certain functions written in this technology to facilitate common tasks, such as shortening URLs. In order to use it in sending a template, you must include this text within a variable:


  • ${shortenURL('https://www.google.com/')} and it will be replaced by the URL in a short version.
  • Methods
  • JSON - ${json2('{a:"123"}').a}
  • Stringify - ${stringify('[{"f": "a"},{"f": "b"}]'?eval[0])[0…2]}
  • AddToArray - ${addToArray([1,2,3],4)}
  • IsEmpty - ${isEmpty('')?then('s','n')}
  • GetOrDefault - ${getOrDefault(null,'default')}
  • DateISO - ${fromDateTimeToDateISO('13-12-2018')}
  • Today - ${today()}
  • TodayAddDays - ${todayAddDays(1)}
  • TodayDateAddDays - ${todayDateAddDays(1)}
  • ShortenURL - ${shortenURL('https://www.google.com/')}
  • TimeDiff - ${timeDiff('10:00:00', '-3', 'HH:mm:ss', 'm', '83')}
  • Bold - text
  • Italic - text


Regular expressions


We use regular expressions to validate data entered by the client. Also, to find a certain combination of characters to trigger events or store that information in variables. You can get more information at the following link: Regular Expressions. An example of its use is to trigger the regular expression (.*) which refers to anything the client says.


Applications


Both functionalities can be combined with each other for different purposes. An example of this is to search for a code or word in the client's message to save it in a variable, so that we can work with it later.

  • variable = ${lastUserSentence?matches(r"(.\b(textstringtosearch)\b.)")?groups[2]}

Written by Botmaker
Updated: 02/09/24