> ## Documentation Index
> Fetch the complete documentation index at: https://trigger-v3-fix-additional-files.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# DynamicTrigger: Overview

> `DynamicTrigger` allows you to define a trigger that can be configured dynamically at runtime.

Sometimes you want to subscribe to a webhook but you don't know the exact configuration until runtime.

## Constructor

### [DynamicTrigger()](/sdk/dynamictrigger/constructor)

Creates a new `DynamicTrigger` instance. You should use the [`TriggerClient.defineDynamicTrigger`]() method instead of calling this directly.

## Instance methods

### [register()](/sdk/dynamictrigger/register)

Use this method to register a new schedule with the DynamicTrigger.

### [unregister()](/sdk/dynamictrigger/unregister)

Use this method to unregister a schedule from the DynamicTrigger, using the id you used when registering it.

### Example use cases:

#### Subscribe to new GitHub issues for all your repos

1. Create a `DynamicTrigger` with the [onIssueOpened](/integrations/apis/github-triggers) event.
2. Loop through all of your repos add them to it.
3. Use an [onNewRepository](/integrations/apis/github-triggers) trigger and add them to the `DynamicTrigger`.

<RequestExample>
  ```typescript DynamicTrigger
  //1. create a DynamicTrigger
  const dynamicOnIssueOpenedTrigger = client.defineDynamicTrigger({
    id: "github-issue-opened",
    event: events.onIssueOpened,
    source: github.sources.repo,
  });

  //2. create a Job that is attached to the dynamic trigger
  client.defineJob({
    id: "listen-for-dynamic-trigger",
    name: "Listen for dynamic trigger",
    version: "0.1.1",
    trigger: dynamicOnIssueOpenedTrigger,
    integrations: {
      slack,
    },
    run: async (payload, io, ctx) => {
      await io.slack.postMessage("Slack 📝", {
        text: `New Issue opened on repo: ${payload.issue.html_url}. \n\n${JSON.stringify(ctx)}`,
        channel: "C04GWUTDC3W",
      });
    },
  });

  //3. Register the DynamicTrigger anywhere in your app
  async function registerRepo(owner: string, repo: string) {
    //the first param (key) should be unique
    await dynamicOnIssueOpenedTrigger.register(`${owner}-${repo}`, {
      owner,
      repo,
    });
  }

  //4. Register inside other Jobs
  client.defineJob({
    id: "new-repo",
    name: "New repo",
    version: "0.1.1",
    //5. when a new repo is created in your org
    trigger: github.triggers.org({
      event: events.onNewRepository,
      org: "triggerdotdev",
    }),
    run: async (payload, io, ctx) => {
      const owner = payload.repository.owner.login;
      const repo = payload.repository.name;
      //6. Register the dynamic trigger so you get notified when an issue is opened. A task will automatically be created
      await dynamicOnIssueOpenedTrigger.register(`${owner}-${repo}`, {
        owner,
        repo,
      });
    },
  });
  ```
</RequestExample>
