Web triggers are incoming HTTPS calls that invoke a function, such as from a third-party webhook implementation. Web triggers are configured in the app’s manifest and the URL to call is created through the Forge CLI.
The request is serialized to JSON and passed to the function in the format described below. The function that is invoked is responsible for parsing the JSON data.
The HTTP response is formed from the JSON format described below. If the function result is not compatible with the
JSON format, then an error response with status code 500
is sent.
See the web trigger module for more details.
Your handler should be defined as a function.
1 2export const trigger = (payload, context) => { return { statusCode: 200, headers: {}, body: 'Hello, world!', } }
A web trigger module should be declared in the app manifest.
1 2modules: webtrigger: - key: example function: my-function function: - key: my-function handler: index.trigger
There are two ways to generate a webtrigger URL. If you are an administrator of an installation, you can run forge webtrigger
via the CLI webtrigger command. Alternatively, you can programatically generate webtrigger URLs via the SDK.
Property | Type | Required | Description |
---|---|---|---|
body | string | HTTP request body. | |
headers | object | HTTP headers sent by the caller. Format: Example: | |
method | string | Yes | HTTP method used by the client. For example: GET , POST , PUT , or DELETE. |
path | string | Yes | Path of request sent by the caller. |
queryParameters | { [key: string]: string[] } | Parsed values from the query string on the request URL. | |
* | any | Additional properties are provided to support forward compatibility. |
1 2{ "method": "POST", "headers": { "Accept": [ "*/*" ], "Postman-Token": [ "5249865e-4106-447d-aa17-52df5e57c2b9" ], "accept-encoding": [ "gzip, deflate" ], "User-Agent": [ "PostmanRuntime/7.13.0" ], "content-length": [ "71" ], "Connection": [ "keep-alive" ], "Host": [ "localhost:8080" ], "Cache-Control": [ "no-cache" ], "Content-Type": [ "text/plain" ] }, "body": "{\n\t\"hello\": 1,\n\t\"test\": [\"foo\", \"bar\"],\n\t\"foo\": {\n\t\t\"bar\": \"hello\"\n\t}\n}", "path": "/x1/XUBR5WnG2Hk2V52APDdGaRSDm", "queryParameters": { "apples": [ "red", "green" ], "grapes": [ "green" ] } }
Property | Type | Required | Description |
---|---|---|---|
body | string | HTTP response body sent back to the caller. | |
headers | object | HTTP headers sent by the caller. Format: Example: | |
statusCode | integer | Yes | HTTP status code returned to the caller. |
statusText | string | Text returned to communicate status. The text provides context to the status code. | |
* | any | Additional properties are provided to support forward compatibility. |
Rate this page: