Data for Actions and Triggers

This section explains how to write your triggers and actions so that they can exchange data with other actions and triggers through the Easybots platform.

Simplest: One Input and One Return


The simplest form of one Action can look like this:
[Easybots.Apps.Action]        
public double CalculateCircleArea(int radius)
{
    return Calculate(radius);
}
but for the Easybots platform the return result is not explained well enough. It is just clear that is of type 'double', but it is not known is it in squared meters, feet, or something else.
To solve this problem, the input and return parameters can be decorated with [Easybots.Apps.ParameterDescriptionAttribute]
[Easybots.Apps.Action]  
[return: ParameterDescription("area", "The area of the circle in squared meters", typeof(int))]
public double CalculateCircleArea(
    [ParameterDescription("radius", "The radius of the circle in meters", typeof(int))]
    int radius)
    {
        return Calculate(radius);
    }
That will result in:

Multiple Inputs and Multiple Returns


It is possible for one Action to have multiple inputs and multiple returns.
Multiple inputs is achieved by:
  • Declare the input parameter of the Action as an array.
  • Decorate the input parameter with multiple [Easybots.Apps.ParameterDescriptionAttribute]
[Easybots.Apps.Action]
[return: ParameterDescription("area (metric)", "Area in squared meters", typeof(int), Order=0)]
[return: ParameterDescription("area (imperial)", "Area squared feet", typeof(int), Order=1)]
[return: ParameterDescription("area as text", "Metric area as text", typeof(string), Order=2)]
public object[] CalculateSquareArea(
    [ParameterDescription("x", "The side 'x' in meters", typeof(int), Order=0)]
    [ParameterDescription("y", "The side 'y' in meters", typeof(int), Order=1)]
    int[] inputs)
{
    // 'unpack' the input parameters
    int x = inputs[0];
    int y = inputs[1];

    // Return values
    int metricArea = CalculateMetricArea(x, y);
    int imperialArea = CalculateImperialArea(x, y);
    string areaAsText = GetText(x, y);
    return new object[] { metricArea, imperialArea, areaAsText };
}
The result in Easybots Studio will be:
The same rules are valid for Triggers with the remark that only the return parameters of the Triggers are taken into account for the Easybots platform.
Next: Passing Data With Data Models