Add trigger

Prev Next

Available in Classic and VPC

Here is an example to help you understand how to add triggers that run actions. This example creates a trigger that updates user location and calls the hello action when the user location is updated. For learning this example, see the following guides:

  • How to create an action
    • Cloud Functions > Action > Create action

Create action

  1. Write source code that receives and outputs name and location.
function main(params) {
    return {payload:  'Hello, ' + params.name + ' from ' + params.place};
}
  1. Create an action in the console using the source code written in step 1.
    cloudfunctions-example04_v2_01_ko

Add trigger

You can add a trigger that runs actions as follows:

  1. Go to action details by selecting the action named helloAction created in the console.
    cloudfunctions-example04_v2_02_ko
  2. Click [Add] in the trigger section.
  3. Select Create new for connection method and select API Gateway for type.
    cloudfunctions-example04_v2_03_ko
  4. Configure settings to create API Gateway endpoint that will call the action through API Gateway.
    cloudfunctions-example04_v2_04_ko

Check run results

You can run the trigger and check if the action runs properly. To check, take the following steps:

  1. Run the action by calling the API Gateway endpoint. For detailed run methods, see Run trigger in API Gateway trigger.
curl -X POST -H "Content-Type: application/json" https://func.apigw.ntruss.com/api/v1/hello?blocking=true&result=true -d '{"name": "Cloud Functions", "place": "NAVER Cloud"}'
  1. Check detailed information about run results in the Monitoring tab menu of the action details screen. Check if the action ran by viewing the most recent activation information and verify that the action triggered processes parameters correctly.
    cloudfunctions-example04_v2_05_ko