Functions are modules of code that are used for accomplishing a certain task programmatically.

With few exceptions, functions can be used in the following JavaScript code panels in interactions:

  • Pre-Process Code
  • Post-Process Code
  • Process User Response

For info on the order of operations (i.e., which code is run when), see this section.


Your custom JavaScript code should be compatible with ES5, i.e., ECMAScript 5 (2009). There is an exception: The toLocaleString method isn't supported.

Also, your custom JavaScript code must complete within 5 seconds. Otherwise, it times out, and the execution flow continues on as per the order of operations.

Important notes

  • Function names are case-sensitive in the JavaScript.
  • Functions require the botContext. prefix.
  • Functions are scoped ONLY for the JavaScript panel in which they appear.