ApplicationExperienceEdge 1.10.0

GCP: Function Node

The GCP (Google Cloud Platform): Function Node allows a workflow to execute a Google Cloud Function.

GCP: Function Node

Node Properties

There are three main configuration sections for the GCP: Function Node…

Service Account Configuration

GCP: Function Node Host Config

First, a Service Account auth token is required for the workflow to authenticate with Google Cloud Functions. You may enter this token one of two ways:

Function Configuration

GCP: Function Node Config

Next, specify the Cloud Function to call, as well as any data to send. All applicable fields are templatable.

  • Function Name Template: (Required) The name of the Cloud Function to be called.
  • GCP Region Template: (Required) The location where the Cloud Function is hosted.
  • Source Data Method: The data sent to the Cloud Function can be the entire payload, the value at a payload path, or a JSON template.

    • Workflow Payload: The entire current payload will be sent to the Cloud Function.
    • Payload Path: The value at the given payload path will be sent to the Cloud Function.
    • JSON Template: The value is expected to be a JSON template which will be the object sent to the Cloud Function.

Result Path

Finally, you may optionally store the result of the Cloud Function on the payload. More information about returning data from Google Cloud Functions can be found in their documentation.

GCP: Function Node Result

Node Example

If the result path is configured, when a workflow executes a Cloud Function its result will be placed on the payload. For example:

Executing the following GCP Function…

exports.sum = (req, res) => {
  const { num1, num2 } = req.body;
  const sum = num1+num2
  res.status(200).send(sum.toString());
};

results in the following payload:

{
  "data": {
    "functionOut": {
      "result": "15",
      "executionId": "lhf3ghvp82u0"
    }
  }
}

Node Errors

Errors resulting from the configuration of the GCP: Function Node itself will error the workflow like so:

GCP: Function Node Error

If an error is thrown from the Cloud Function, it will appear on the payload. Here’s an example of a Cloud Function that tried to parse invalid JSON:

{
  ...
  "data": {
    "functionOut": {
      "error": "Error: function crashed. Details:\nUnexpected token o in JSON at position 1"
    }
  }
  ...
}