Set up a trigger
Add a delivery endpoint, then subscribe connected accounts to a polling trigger or register a webhook trigger with the app. Everything happens in the Scalekit dashboard.
Set up a trigger in the Scalekit dashboard so your server receives an event each time something changes in a user’s connected app. You add a delivery endpoint once per environment, then subscribe to triggers on each connection. Polling triggers and webhook triggers need different setup: follow the section for the kind you picked.
New to triggers? How triggers work explains the two kinds and how events are delivered.
Before you start
Section titled “Before you start”- Triggers turned on for the environment.
- A connection for an app that has triggers, such as Salesforce or Slack. The connector catalog’s Has triggers filter lists them.
- The Admin or Developer role. See Team members and roles.
- A server with a public HTTPS URL that accepts
POSTrequests. While you develop, a tunnel to your local server works. - For a polling trigger: a connected account in
ACTIVEstatus on the connection. Authorize a user shows how to create one. - For a webhook trigger: access to the app’s admin settings at the provider, such as your Slack app or Gong’s automation rules.
Add a delivery endpoint
Section titled “Add a delivery endpoint”A delivery endpoint is the URL on your server where Scalekit sends trigger events. An endpoint can receive events from every connection in the environment, or only from the connections you choose, so you can send different apps’ events to different endpoints.
-
In the Scalekit dashboard, select the environment, then open Developers > Trigger Delivery and select Add endpoint.
-
Enter your Endpoint URL, for example
https://example.com/scalekit/triggers, and an optional Description. -
Under Receives events from, choose All connections, or Only these connections and pick the connections. You can change this later without registering the endpoint again.
-
Select Save endpoint.
-
In the endpoints table, select Reveal under Signing secret, then copy the secret. It starts with
whsec_. Store it with your other server secrets, for example asSCALEKIT_TRIGGER_SECRET, and never expose it to a browser.
Each environment has its own endpoints and secrets. Add an endpoint in Production too when you go live.
Open the connection’s triggers
Section titled “Open the connection’s triggers”Open AgentKit > Connections, select the connection, then open the Triggers tab. It lists the triggers the connector offers, each tagged:
- Webhook or Polled: how Scalekit learns about changes.
- Per user or Per connection: whether you subscribe each connected account or the connection once.
Select Show details on a trigger to see Requires, the scopes the connection must grant for the trigger to work, and for a polling trigger Cadence, its default and minimum interval.
Above the list, a setup card shows the steps this connection still needs, such as generating a webhook URL or connecting an account. Once they’re done, it shrinks to a Setup complete line with a Manage button.
Subscribe to a polling trigger
Section titled “Subscribe to a polling trigger”Polling triggers need no setup in the app. Subscribe each connected account whose changes you want.
-
On the Triggers tab, select Subscribe next to the trigger, such as Lead created in Salesforce or Activity created or updated in Pipedrive.
-
Pick the connected account. To subscribe several at once, select Subscribe several accounts and pick them. An account that can’t receive the trigger, for example because it isn’t
ACTIVE, shows why and isn’t added. -
Fill in the trigger’s settings. Most are optional, such as a lead source: leave one empty to receive every matching record. Some triggers have required settings, such as the object a Salesforce object trigger watches. Each connector’s page lists its triggers’ settings, as in Salesforce triggers. Each distinct set of values is a separate subscription.
-
Optional: set Check interval (seconds). It defaults to the trigger’s default interval, and an interval below the trigger’s minimum is refused.
-
Select Subscribe.
When a trigger’s settings shape the query Scalekit runs, such as a Salesforce filter, Scalekit runs the query once on the account before it creates the subscription. If the app rejects it, nothing is created. See A subscription is refused.
The first check runs shortly after you subscribe, then once per interval. Records created or changed before you subscribed aren’t sent, except ones changed shortly before, which the first check can pick up.
Some triggers read at most a set number of records in each check, which their Max records per poll setting controls. Records past the limit in one check are skipped, not carried over to the next, so set it above the most records you expect to change in one interval.
Subscribe from code
Section titled “Subscribe from code”To subscribe accounts as users connect, call the API from your server instead of the dashboard. You still add the delivery endpoint in the dashboard. Set interval to how often Scalekit checks the app; it must be at least the trigger’s minimum, and leaving it out uses the trigger’s default. Put the trigger’s settings in config, keyed as on the connector’s page.
This example subscribes a user’s Salesforce account to Lead created, checking every 15 minutes, and receives only leads from the web:
import osfrom datetime import timedelta
from dotenv import load_dotenvfrom scalekit import ScalekitClientfrom scalekit.common.exceptions import ScalekitServerException
load_dotenv()scalekit_client = ScalekitClient( env_url=os.environ["SCALEKIT_ENVIRONMENT_URL"], client_id=os.environ["SCALEKIT_CLIENT_ID"], client_secret=os.environ["SCALEKIT_CLIENT_SECRET"],)actions = scalekit_client.actions
# The user's connected account, which must be ACTIVEaccount = actions.get_connected_account_details( connection_name="salesforce", identifier="user_123").connected_account
try: subscription = actions.triggers.create_subscription( account.connection_id, "salesforce_lead_created", connected_account_id=account.id, interval=timedelta(minutes=15), config={"lead_source": "Web"}, ) print(subscription.id, subscription.status, subscription.effective_interval)except ScalekitServerException as e: print(e.error_code, e.message)import 'dotenv/config';import { ScalekitClient } from '@scalekit-sdk/node';
const envUrl = process.env.SCALEKIT_ENVIRONMENT_URL!;const scalekit = new ScalekitClient( envUrl, process.env.SCALEKIT_CLIENT_ID!, process.env.SCALEKIT_CLIENT_SECRET!,);
// The user's connected account, which must be ACTIVEconst { connectedAccount } = await scalekit.actions.getConnectedAccount({ connectionName: 'salesforce', identifier: 'user_123',});
// Subscribing goes through the REST API, with an access token for your environmentconst tokenResponse = await fetch(`${envUrl}/oauth/token`, { method: 'POST', body: new URLSearchParams({ grant_type: 'client_credentials', client_id: process.env.SCALEKIT_CLIENT_ID!, client_secret: process.env.SCALEKIT_CLIENT_SECRET!, }),});const { access_token } = await tokenResponse.json();
const response = await fetch( `${envUrl}/api/v1/connections/${connectedAccount!.connectionId}/trigger-subscriptions`, { method: 'POST', headers: { Authorization: `Bearer ${access_token}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ trigger_name: 'salesforce_lead_created', connected_account_id: connectedAccount!.id, interval_seconds: 900, config: { lead_source: 'Web' }, }), },);console.log(response.status, await response.json());Save it as subscribe.mts and run it with npx tsx subscribe.mts.
Install the packages first: pip install scalekit-sdk-python python-dotenv, or npm install @scalekit-sdk/node dotenv. Replace salesforce with your connection’s name and user_123 with the user’s identifier.
The subscription’s effective_interval (effective_interval_seconds in the REST response) is the interval Scalekit uses, which is longer when the subscription is Throttled. To change the interval later, delete the subscription and create it again. To subscribe up to 100 accounts in one call, use batch_create_subscriptions. See Subscribe to a trigger and Subscribe several accounts in the API reference.
Set up a webhook trigger
Section titled “Set up a webhook trigger”Webhook triggers need three things from your app at the provider: Scalekit’s webhook URL registered as the event destination, the provider’s signing secret saved in Scalekit, and a subscription to the provider’s events the trigger uses. The setup card on the Triggers tab walks you through them in order. Each provider names these settings differently: the connector’s page lists where they are, as in Slack triggers.
-
Generate the webhook URL. In the setup card, select Generate webhook URL. The URL is unique to this connection.
-
Paste the provider’s signing secret. Copy the signing secret from your app’s settings at the provider. In the setup card, select Set signing secret, paste it and select Save.
Save the secret before you register the URL. Some providers check the URL as soon as you paste it, and Scalekit needs the secret to answer that check.
-
Register the URL with the provider. Copy the URL from the setup card and paste it into your app’s event or webhook settings. If the provider checks the URL, Scalekit answers for you.
Then subscribe your app at the provider to the events the trigger needs. The connector’s page lists them. Subscribe only to those: events that match no trigger subscription aren’t delivered to your endpoint.
-
Confirm the registration. Back in the setup card, select I’ve registered it. Scalekit can’t see the provider’s settings, so this step is marked done only when you confirm.
-
Subscribe. Select Subscribe next to the trigger. A Per connection trigger has no account to pick. Optional: fill in the trigger’s settings, such as a channel, to receive only matching events. Then select Subscribe.
Events from the provider now reach your delivery endpoint within seconds.
Replace the provider’s signing secret
Section titled “Replace the provider’s signing secret”When you rotate the signing secret at the provider, update it in Scalekit without dropping events:
-
Open the connection’s Triggers tab, select Manage on the Setup complete line, then select Replace signing secret.
-
Paste the new secret and select Save. Scalekit now accepts events signed with either the previous or the new secret. The card shows when the previous secret stops being accepted.
-
Update the secret at the provider.
-
Select Confirm rotation, and confirm. From then on, Scalekit accepts only the new secret, and rejects events signed with the previous one.
Check it worked
Section titled “Check it worked”There’s no test event to send, so make a real change:
- Polling trigger: create or change a matching record in the app, such as a new lead in Salesforce or a new activity in Pipedrive, in the subscribed user’s account. Wait up to one interval.
- Webhook trigger: do what the trigger watches for in the app, such as mentioning your app in a Slack channel it’s in.
Then open Developers > Trigger Delivery. Under Recent delivery attempts, the event appears with your server’s response code. A 2xx code means your server accepted it. To handle the request in your server, see Receive trigger events.
Common problems
Section titled “Common problems”An account can’t be subscribed
Section titled “An account can’t be subscribed”The account picker shows why next to the account. The common reasons:
- The account’s credential has expired: ask the user to reconnect, as in Handle inactive accounts, then subscribe again.
- The account hasn’t finished connecting: the user hasn’t completed the authorization link. Wait until the account is
ACTIVE. - The account’s grant doesn’t cover a scope the trigger requires: add the scopes listed under Requires to the connection, then ask the user to reconnect so they grant the new scopes.
A subscription is refused
Section titled “A subscription is refused”When a trigger’s settings shape its query, Scalekit tests the query on the account before it creates the subscription. Nothing is created when the test fails:
the provider rejected this subscription's query: …: the app refused the query, and the rest of the message is the app’s reason, such as a field that doesn’t exist. Fix the setting it names, such as Fields or Filter, and subscribe again.the connected account's credential was refused while checking this subscription's query; reconnect the account and retry: ask the user to reconnect, as in Handle inactive accounts, then subscribe again.the provider could not be reached to check this subscription's query; nothing was created, retry shortly: the app didn’t answer in time. Subscribe again in a few minutes.
No events arrive
Section titled “No events arrive”- Check that an endpoint covers the connection: the setup card on the Triggers tab shows how many delivery endpoints cover it. An endpoint set to Only these connections must include this connection.
- Check Recent delivery attempts on Developers > Trigger Delivery. A non-
2xxcode or No response means the request reached your server, or tried to, and failed there. - For a polling trigger, wait a full interval after the change, and check that the change matches the subscription’s settings.
- For a webhook trigger, check that the provider shows the URL as verified and that your app at the provider subscribes to the right events.
The provider says the webhook URL didn’t verify
Section titled “The provider says the webhook URL didn’t verify”Save the provider’s signing secret in Scalekit first, then register the URL again. Scalekit answers the provider’s check only once it has the secret.
API reference
The endpoints this page's code calls, with every field and the SDK method for each: