Creating Expressions

Once you have declared expressions in your content and have finished adding contents. You are then presented with a screen where you can define your expressions. An expression is similar to a function in which you can include your instructions or logic which can be executed. An expression should always return a value and the return value would be treated as string. Expressions can also contain variables.

Let’s take a look at a simple example of a content.

Hi @name
It’s a beautiful day tomorrow. How about we take a long drive on our #vehicle 

In this content, we have the variable @name and expression #vehicle. Now, let’s define our expression as:

#vehicle
{
 if(@people<=2)
  {
   return "bike";
  }
   else
  {
   return "car";
  }
}

Considering we pass the payload as below:

{
 "@name" : "John",
 "@people": 3
}

The content would now be generated as:

Hi John
It’s a beautiful day tomorrow. How about we take a long drive on our car