During the execution of your plan, you can create a task to send HTTP requests to a third-party application endpoint. For example, when a flow task successfully executes, you can send an HTTP message to a designated endpoint. |
An HTTP task is a request between and another application. These requests are delivered using over HTTP and can be interpreted by the receiving application to take action.
NOTE: Your receiving application may require that you whitelist the host and port number or IP address of the platform. Please refer to the documentation for your application. |
NOTE: It's possible that webhook requests can be submitted back to the platform to execute API tasks within the platform. However, there are security concerns. Additional configuration is required. For more information, see Configure Webhooks. |
To send an HTTP request to a target application, the application must be configured to receive the request:
Requests from outside of the application domain must be enabled.
NOTE: Your receiving application may require that you whitelist the host and port number or IP address of the platform. Please refer to the documentation for your application. |
Open your plan in Plan View. Click a node to create a new task.
In the right panel, select HTTP task.
Set the following parameters:
Parameter | Description | ||
---|---|---|---|
Name | User-visible name of the task. | ||
Url | URL where the webhook message is received by the other application. | ||
Headers | Insert HTTP content headers as key-value pairs. For example, if your body is in JSON format, you should include the following header:
Please refer to the documentation for your receiving application about the required headers. | ||
Body | (
| ||
Method | Select the HTTP method to use to deliver the message. The appropriate method depends on the receiving application. Most use cases require the POST method. | ||
Secret key | (Optional) A secret key can be used to verify the webhook payload. This secret value must be inserted in this location, and it must be included as part of the code used to process the requests in the receiving application. Insert the secret value here as a string without quotes. For more information on how this secret key is used to generate a signature, see Verify Webhook Signatures below. | ||
Validate SSL certificate | When set to
| ||
Retry on failure | If the returned status code is outside of the 200-299 range, then the webhook is considered to have failed. When this option is enabled, the request is retried. When a message is retried, the following header is submitted:
|
You can create a task to run another job on the successful execution of this one.
Tip: Use this method to create conditional sequences of job executions. |
As needed, you can specify task overrides as part of a launching a job via API. For more information, see API Workflow - Run Job.
NOTE: For this example, the platform must be whitelisted to receive requests from itself. Additional configuration is required. For more information, see Configure Webhooks. |
Review the URL for the recipe object. In the example below, the recipe Id value is 4
:
http://www.example.com:3005/flows/1?recipe=4&tab=recipe |
Retain this value for below.
Parameter | Description | |||
---|---|---|---|---|
Name | This name appears in the | |||
Url | Specify the URL as follows, replacing the example values with your own:
| |||
Headers | Insert the following two headers:
| |||
Body | In the body, insert the recipe Id for the value for
| |||
Method | Select the POST method. |
Tip: Slack tasks are now a supported product feature. For more information, see Create Slack Task. |
You can create an HTTP task to deliver a text message to a Slack channel of your choice.
Set up your Slack installation to receive HTTP messages:
Parameter | Description | |
---|---|---|
Name | This name appears in the | |
Method | Select the POST method. | |
Url | Paste the URL that you copied from Slack. | |
Headers | Copy the content headers from the Slack cURL command:
| |
Body |
|
You can reference metadata information from the plan definition and the current plan run as part of the request of your HTTP task.
Notes:
Each task in the current run is referenced using a two-letter code. Examples:
{{$http_xx.name}} {{$flow_xy.name}} |
A plan metadata reference is constructed using the following syntax. In the appropriate textbox, enter one of the following values:
Tip: Start by typing |
Entered value | Plan metadata reference type | |
---|---|---|
| Metadata information from the plan definition or the current plan run. | |
| Metadata information for the flow tasks executed in the current plan run. | |
| Metadata information for the outputs generated by the specific flow task. In this example:
|
The following request body contains references to the Plan name, plan run identifier, and the flow that was just executed:
{"text":"Plan: {{$plan.name}} RunId: {{$plan.runId}} Flow: {{$flow_7p.name}} Success."} |
The following request body contains plan execution information using timestamps:
{"text":"Plan: {{$plan.name}} RunId: {{$plan.runId}} - plan start: {{$plan.startTime}} Running time: {{$plan.duration}} Times: - last task start: {{$flow_7p.startTime}} - last task end: {{$flow_7p.endTime}} "} |
You can reference information from an HTTP task that has already occurred:
{"text":"{{$http_qg.name}} returned {{$http_qg.statusCode}}."} |
The following request body references information from a flow task in the plan:
{"text":"{{$flow_7p.name}} execution: Duration: {{$flow_7p.duration}} Status: {{$flow_7p.status}} For more information, see jobIds: {{$flow_7p.jobIds}} "} |
The following request body references information from the underlying output for the above flow task:
{"text":"Flow reference information: Name: {{$flow_7p['2013 POS'].name}} Favorite column: {{$flow_7p['2013 POS'].columns.Store_Nbr.name}} Least favorite data source: {{$flow_7p['2013 POS'].sources['POS-r01.txt'].name}} For more information, see jobIds: {{$flow_7p.jobIds}} "} |
Notes:
You can reference columns from the generated results using the .columns.
reference.
.sources
reference.For more information, see Plan Metadata References.
This example demonstrates how you can use an HTTP task to deliver plan metadata to AWS lambda functions. A similar approach could be used for Google Cloud functions.
In this case, the rowCount
value from the flow task execution is delivered via HTTP task to an AWS lambda function.
General steps:
HTTP task: generates an HTTP request whose body includes a reference to the rowCount metadata variable. Request body:
{ "rowCount": "{{$flow_7p['My Flow Name'].output['My output name'].rowCount}}" } |
AWS Lambda functions: The following is pseudo-code for Lambda:
import json def lambda_handler(event, context): httpTaskBody = json.loads(event["body"]) rowCount = httpTaskBody["rowCount"] return { 'statusCode': 200, 'body': json.dumps(rowCount) } |
Google Cloud functions: The following is pseudo-code for Google Cloud functions:
def get_row_count(request): request_json = request.get_json() if request_json and 'rowCount' in request_json: rowCount = request_json['rowCount'] return rowCount return 'No rowCount attribute provided' |
Depending on the target application, implementing signature verification may require developer skills. |
Optionally, you can configure the platform to sign the HTTP requests sent for a flow. Signed requests guarantee that the requests are sent from the platform, instead of a third party.
Below, you can review how the signature is created, so that you can configure the receiving application to properly process the signature and its related request.
HTTP requests are signed by inserting the X-Webhook-Signature
header in the request. These signatures are in the following form:
X-Webhook-Signature: t=<timestamp>,sha256=<signature> |
where:
<timestamp>
- Timestamp when the signature was sent. Value is in UNIX time.<signature>
- SHA256 signature. The platform generates this signature using a hash-based message authentication code (HMAC) with SHA-256. More information on these values is available below.
Example:
X-Webhook-Signature: t=1568818215724,sha256=55fa71b2e391cd3ccba8413fb51ad16984a38edb3cccfe81f381c4b8197ee07a |
Depending on the application, you may need to complete one of the following sets of tasks to verify the task signatures:
NOTE: You may need to whitelist the platform in your application. See the application's documentation for details. |
You may be required to create some custom coding for your application. Below, you can review details on how to do so, including a JavaScript example.
The timestamp value (t=<timestamp>
) appears at the beginning of the header value to prevent replay attacks, where an attacker could intercept a valid payload and its signature and re-transmit them.
The task signature includes as part of its hashed value:
Split the X-Webhook-Signature
header:
1568818215724
55fa71b2e391cd3ccba8413fb51ad16984a38edb3cccfe81f381c4b8197ee07a
In the receiving application, you can recompute the signature to verify that the request was sent from the platform.
Suppose the above example is the signature for a POST
request, and the request body is test
. The concatenated value is the following:
1568818215724.test |
You can now compute the HMAC authentication code in your receiving application. In the following JavaScript example, the secret key value is mySecret
:
const crypto = require('crypto'); const message = '1568818215724.test'; // as defined above const hmac = crypto.createHmac('sha256', 'mySecret'); hmac.update(message) const expectedSignature = hmac.digest('hex'); |
The value returned by your code and the value included as the signature in the X-Webhook-Signature
header should be compared: