Triggers allow you to set up real time integrations with hundreds of underlying services (Ex. Salesforce, Slack, Jira etc.).
The job of setting webhooks, subscripting to events from a 3rd party system can be made hassle free by using the vast library of Tray Triggers.
Here is how you can implement a basic use case of notifying Sales
channel in Slack for new / updated leads in Salesforce:
find_record
operation of Salesforce connectorsend_message
operation of Slack connectorReturns a list with all the available triggers from Tray's trigger library. A trigger can have multiple versions.
The following key data is returned:
Service name
and version
are required inputs for Get service environments
Trigger name
and version
are required inputs for Get trigger operations and Create subscription
The service id
is required for building the url for the Auth-only dialog.
Authorization | string You can either pass your master token here or user token of an end user. Example: Bearer 3fd74d349xxxxxxxxxxxxxxxxxxxxxxxxd90df521 |
OK - returns an elements
array which contains the name
and version
(required for Get service environments Get trigger operations and Create subscription)
Array of objects (PublicConnectorEventsTrigger) |
Invalid input
Unauthorized - Verify the token validity
Forbidden
Not found
Limit exceeded
Internal error
{- "elements": [
- {
- "name": "slack-trigger",
- "description": "Slack brings all your communication together in one place. It's real-time messaging, archiving and search for modern teams.",
- "service": {
- "id": "3e21b055-xxxx-xxxx-xxxx-72af0843b283",
- "name": "slack",
- "version": 4
}, - "version": "7.0",
- "title": "Slack trigger"
}, - {
- "name": "shopify-trigger",
- "service": {
- "id": "e0b2cbd7-xxxx-xxxx-xxxx-31d028968e0b",
- "name": "shopify",
- "version": 4
}, - "title": "Shopify",
- "version": "4.1",
- "description": "Shopify gives you everything you need to build a successful online business."
}
]
}
Returns a list with all the available operations for a given trigger
Each trigger operation has an input schema that can be used by a frontend to build a form or validate data.
You can then use the input schema to construct your inputs for the 'Create subscription' operation.
Authorization | string You can either pass your master token here or user token of an end user. Example: Bearer 3fd74d349xxxxxxxxxxxxxxxxxxxxxxxxd90df521 |
OK - Returns an elements
array which contains the input schema for Create subscription
Array of objects (PublicConnectorEventsTriggerOperation) |
Invalid input
Unauthorized - Verify the token validity
Forbidden
Not found
Limit exceeded
Internal error
{- "elements": [
- {
- "name": "events_api",
- "title": "On Slack event",
- "description": "",
- "inputSchema": {
- "advanced": [ ],
- "additionalProperties": false,
- "type": "object",
- "properties": {
- "event": {
- "type": "string",
- "enum": [
- {
- "text": "A channel was archived",
- "value": "channel_archive"
}, - {
- "text": "A channel was created",
- "value": "channel_created"
}
], - "description": "",
- "title": "Event"
}
}, - "required": [
- "event"
]
}, - "authScopes": [
- "chat:write:bot",
- "chat:write:user"
]
}
]
}
Delivery of event payloads after a subscription is created are billable.
Every event payload that is processed (see note below) by Tray is billed as 1 task.
Note: Processed events include:Since all of the above events were processed by Tray, these will be billed.
Creates a subscription using a trigger operation and returns the state
of subscription.
The input is a regular json object that must fit the input schema of the operation as retrieved from Get trigger operations.
The authId field should be the id of a previously created authentication.
The output is also a regular json object containing the response from the 3rd party. The state
field indicates the current status of the subscription.
This reqest has a 60 seconds timeout, if the subscription is created successfully within 60 seconds, you will receive a response with active
state.
Once a subscription is in active
state, the events would start coming at the endpoint
defined the request.
Here is how the event payload may look like:
{
"id": "<uuid>",
"subscription": {
"id": "<uuid>",
"externalId": "<external_id>"
},
"outcome": "success",
"body": {},
"timestamp": "2023-04-13 10:04:00Z"
}
If the outcome is success
, the body
in the above payload would follow the Output Schema of the trigger operation.
If the outcome is failure
, then manual testing with the API is required as every 3rd party service would have it's own failure responses.
Authorization | string This must be a user token to call the connector on behalf of an end user. Note that authID must belong to the end user whose user token is being used. Example: Bearer 3fd74d349xxxxxxxxxxxxxxxxxxxxxxxxd90df521 |
required | object (PublicConnectorEventsTriggerReference) Reference to link the Trigger |
operation required | string programmatic name of the Trigger operation. Obtained using Get Trigger operations |
authenticationId | string <uuid> Unique id of the auth returned by Create Authentication |
required | object |
externalId | string Unique identifier for the subscription in your database. |
endpoint required | string The URL where you want to receive the payloads from the Subscription. |
name required | string Name of the Subscription. Can be used to display in the UI. |
Ok - Returns the deatils of the Subscription object.
authenticationId | string <uuid> Unique id of the auth returned by Create Authentication |
endpoint required | string The URL where you want to receive the payloads from the Subscription. |
object This is returned when subscripton creation fails on the third party service. | |
externalId | string Unique identifier for the subscription in your database. Will only be returned if you passed it in the request. |
id required | string Unique ID of the subscription in Tray's database. |
required | object |
name required | string Name of the subcription |
operation required | string Trigger operation used to create subscription |
signingKey required | string Unique key that can be used to verify the source of payload was Tray. Read the guide here for explanation. |
state required | string (SubscriptionState) Current state of the subcription |
required | object (PublicConnectorEventsTriggerReference) Details about the trigger name and version |
Invalid input
Unauthorized - Verify the token validity
Forbidden
Not found
Limit exceeded
Internal error
{- "name": "test-typeform-subscription",
- "trigger": {
- "name": "typeform-trigger",
- "version": "4.1"
}, - "operation": "webhook",
- "authenticationId": "1a7f8a5b-6848-438a-8317-f09876d521ab",
- "input": {
- "form_id": "R8B26k6g"
},
}
{- "id": "bcbbxxxx-xxxx-xxxx-xxxx-xxxx524030e5",
- "name": "John Doe's Typeform subscription",
- "trigger": {
- "name": "typeform-trigger",
- "version": "4.1"
}, - "operation": "events_api",
- "authenticationId": "1a7fxxxx-xxxx-xxxx-xxxx-xxxx76d521ab",
- "endpoint": "<endpoint_to_send_connector_events_to>",
- "input": {
- "form_id": {
- "type": "string",
- "value": "R8B26k6g"
}, - "public_url": {
- "type": "jsonpath",
- "value": "$.env.public_url"
}
}, - "state": "active",
- "signingKey": "ilYCCd7R40K1Ba9ra7k3VdKLKEUw9y9fvCiLEGGJdO/Gz73zqvR16IxUyZc3+ieGJsdfXz3Z0H8+ubb3wVtJLw=="
}
Returns a paginated list of susbcriptions.
You can use the pageInfo parameters to traverse through pages and collect response.
If hasNextPage
is true then pass the endCursor to query parameter after
to obtain the next page of response.
Authorization | string You can either pass your master token here or user token of an end user. Example: Bearer 3fd74d349xxxxxxxxxxxxxxxxxxxxxxxxd90df521 |
OK - Returns an elements
array of all the trigger subscriptions and pageInfo for pagination
Array of objects (PublicConnectorEventsSubscription) | |
required | object (PublicPageInfo) |
Invalid input
Unauthorized - Verify the token validity
Forbidden
Not found
Limit exceeded
Internal error
{- "elements": [
- {
- "id": "<uuid>",
- "externalId": "<external_id>",
- "publicUrl": "<public_url>",
- "name": "<name_of_subscription>",
- "trigger": {
- "name": "slack-trigger",
- "version": "7.0",
- "operation": "events_api"
}, - "endpoints": {
- "connectorEventEndpoint": "<endpoint_to_send_connector_events_to>",
- "stateChangeEventEndpoint": "<endpoint_to_send_state_changes_to>"
}, - "state": "ACTIVE"
}, - {
- "id": "<uuid>",
- "externalId": "<external_id>",
- "publicUrl": "<public_url>",
- "name": "<name_of_subscription>",
- "trigger": {
- "name": "slack-trigger",
- "version": "7.0",
- "operation": "events_api"
}, - "endpoints": {
- "connectorEventEndpoint": "<endpoint_to_send_connector_events_to>",
- "stateChangeEventEndpoint": "<endpoint_to_send_state_changes_to>"
}, - "state": "CREATION_FAILED",
- "errorMessage": "Subscription could not be created. Reason: <x>"
}
], - "pageInfo": {
- "startCursor": "<cursor_for_previous_page>",
- "endCursor": "<cursor_for_next_page>",
- "hasNextPage": true,
- "hasPreviousPage": false
}
}
Returns a single subscription object using subscription ID
as the parameter.
Authorization | string You can either pass your master token here or user token of an end user. Example: Bearer 3fd74d349xxxxxxxxxxxxxxxxxxxxxxxxd90df521 |
OK - Returns a Subscription
object
externalId | string Unique ID of the Subscription on your end that you can use to query Subscriptions using Get Subscriptions |
id required | string Unique ID of the Subscription on Tray's end |
required | object (PublicConnectorEventsTriggerReference) Reference to link the Trigger |
state required | string (SubscriptionState) Indicated current state of the Subscription |
object Details about error if any in creating the subscription | |
authenticationId | string <uuid> Unique id of the auth returned by Create Authentication |
operation required | string Programmatic name of the Trigger operation. Obtained using Get Trigger operations |
required | object A JSON object that follows that input schema of the above operation returned by Get Trigger operations |
name required | string Name of the Subscription e.g. |
endpoint required | string Your URL where Tray would post events |
Invalid input
Unauthorized - Verify the token validity
Forbidden
Not found
Limit exceeded
Internal error
{- "id": "<uuid>",
- "externalId": "<external_id>",
- "publicUrl": "<public_url>",
- "name": "<name_of_subscription>",
- "trigger": {
- "name": "slack-trigger",
- "version": "7.0"
}, - "operation": "events_api",
- "endpoint": "<endpoint_to_send_connector_events_to>",
- "state": "active"
}
Deletes a subscription using subscription ID
as the parameter.
Authorization | string You can either pass your master token here or user token of an end user. Example: Bearer 3fd74d349xxxxxxxxxxxxxxxxxxxxxxxxd90df521 |
No content - The subscription was deleted successfully
Invalid Input
Unauthorized
Forbidden
Not Found
Limit Exceeded
Internal Error