LaunchDarkly
Overview
Section titled “Overview”A LaunchDarkly flag trigger starts Promptless documentation work when a matching feature flag changes, such as a flag turned on in production. Use it when your team releases features by changing flags, so documentation work starts at rollout.
Connecting LaunchDarkly sets up flag-change delivery to Promptless. A LaunchDarkly flag trigger then chooses which flag changes start documentation work.
Before you start
Section titled “Before you start”- LaunchDarkly connected to Promptless. If it isn’t connected yet, connect it first.
- An organization admin role, to add triggers.
Connect LaunchDarkly
Section titled “Connect LaunchDarkly”Skip this section if LaunchDarkly is already connected on the Integrations page.
You need an admin role in your Promptless organization to connect LaunchDarkly, and a LaunchDarkly account that can create access tokens.
-
In LaunchDarkly, open Authorization settings and create an access token.
-
Mark the token as a service token. A service token isn’t tied to an individual user, so the integration keeps working when team members leave.
-
For the token’s role, select Inline policy.
-
Enter this policy:
[{"effect": "allow","actions": ["createWebhook", "deleteWebhook"],"resources": ["webhook/*"]},{"effect": "allow","actions": ["viewProject"],"resources": ["proj/*"]}]The policy grants Promptless the minimum permissions it needs:
createWebhookanddeleteWebhookonwebhook/*let Promptless manage its subscription to flag-change events.viewProjectonproj/*lets Promptless view projects and flag state.
-
Save the token, and copy it. For more on API access tokens, see the LaunchDarkly docs.
-
On the Promptless Integrations page, select Connect LaunchDarkly.
-
Paste the service token into the modal, and select Connect.
Promptless validates the token and creates a webhook in your LaunchDarkly account that delivers flag-change events. LaunchDarkly then shows as connected on the Integrations page.
Add a LaunchDarkly flag trigger
Section titled “Add a LaunchDarkly flag trigger”-
On the Configuration page, switch to YAML mode.
-
In the
triggerssection, add alaunchdarkly_flagtrigger with one or more match clauses:triggers:launchdarkly-checkout-flags:trigger_type: launchdarkly_flagmatch:- project_key: [checkout]environment_key: [production]flag_key: [express-checkout]- project_key: [billing] -
Select Save.
The first clause sets all three fields, so it matches only a change to the express-checkout flag in the checkout project’s production environment. The second clause sets project_key alone, so it matches any flag change in the billing project. A change that matches either clause starts documentation work.
The trigger map key, such as launchdarkly-checkout-flags, is yours to name. The trigger_type value launchdarkly_flag is a fixed type identifier.
You can also add this trigger on the Triggers tab, from the A LaunchDarkly flag entry under Product & releases. Each clause there has three fields, Projects, Environments, and Feature flags, which set project_key, environment_key, and flag_key.
Backfill isn’t available for LaunchDarkly flag triggers, so a flag change from before you added the trigger starts no documentation work.
Match a flag change
Section titled “Match a flag change”A LaunchDarkly flag trigger matches on three optional list fields:
| Field | What it watches |
|---|---|
project_key | The LaunchDarkly projects. |
environment_key | The environments. |
flag_key | The individual flags. |
Each clause under match must set at least one of these fields, and Promptless rejects an empty clause. Within a clause, a flag change matches when it satisfies every field you set. Separate clauses are ORed. A field you leave empty matches every value, so a clause with only project_key matches any flag change in those projects.
Promptless matches each key exactly as you enter it and doesn’t check it against your LaunchDarkly account. A misspelled project, environment, or flag key saves as valid configuration but never matches a real flag change, so copy keys from LaunchDarkly.
What Promptless receives
Section titled “What Promptless receives”When a matching flag changes, Promptless receives this context from the flag-change webhook LaunchDarkly delivers:
- The flag key, project key, and environment key.
- The action taken and the event title.
- The email of the member who made the change.
The webhook carries no before and after flag values or targeting-rule details, and Promptless makes no LaunchDarkly API call to fetch more.
Example
Section titled “Example”A team runs a checkout project in LaunchDarkly and gates its new express-checkout flow behind the express-checkout flag. They add a LaunchDarkly flag trigger scoped to project_key: [checkout], environment_key: [production], and flag_key: [express-checkout].
When an engineer turns express-checkout on in production, LaunchDarkly delivers the change to Promptless. The trigger matches, and Promptless starts a documentation run for the change. Following the run’s publishing policy, Promptless drafts the express-checkout documentation and opens a documentation PR or leaves a draft suggestion. It then sends the usual Slack or Microsoft Teams notification.
To confirm afterward that a flag rollout started a run, check the events Promptless lists in the docs PR description. See Trigger events in documentation PRs.
See also
Section titled “See also”- LaunchDarkly integration, for webhook verification and what disconnecting removes
- Triggers, for how triggers work and how to follow what one did
- Configuration Reference, for every trigger field