Back to Blog

How to Create Parameters with cloud code Actions

Code is less user friendly than a drag & drop interface but it allows you to do more. Sometimes you need to set variable or create parameters within your Flow without using the input of the user.

In this example we will show you how to create a variable or parameter that contains the current datetime in 3 steps:

1. Create your Design

Let’s kick it off with a design. You can start with a text trigger, an event or any other trigger. It al depends on your case. The last text reply will show the value of our new variable.

Create param with Actions

2. Add Your Cloud Code action

This one depends on what you would like to accomplish. In this example we want to create a param “dts” that contains the current date time as a value. Therefore we can use the code below.

async payload => {
  return {
    params: {
      ...payload.params,
      dts: [{
        value: (new Date().toLocaleString())
      }]
    }
  }
}

3. Test your experience

Our design is finished and our Action is covered. We can now use the Try it Out to see if our code is actually creating a param. Use the curly brackets {{}} to show the value of your param.

Create param with Cloud Code Actions
Get StartedContact us