What steps do I need to take to set up a scheduled trigger that sends data on a weekly basis?

Hi Atlassian Developer community,

I’m new to Forge and I’m trying to figure out how to use scheduledTrigger. My goal is to send data from my Forge app to my Node.js server every week. Specifically, I want to retrieve worklogs data and send it to the server once a week on Mondays.

I have a React front-end that calls a Node.js back-end function using invoke(), and it successfully retrieves the data I need. However, I’m not sure how to set up the 'scheduledTrigger' to make this happen automatically every week.

Can anyone provide guidance on how to use 'scheduledTrigger' in this context? Any sample code or resources would be greatly appreciated. Thank you!

Hi @SarraMEHREZ , welcome to the developer community!

You can declare a scheduledTrigger in the Forge manifest. In your case, you set the interval to be week.

    - key: my-scheduled-trigger
      function: '<your-function-key>'
      interval: week

To test your function without waiting for the scheduled trigger, we recommend declaring a web trigger. Please see our guide here for how to use a scheduled trigger: https://developer.atlassian.com/platform/forge/add-scheduled-trigger/


1 Like

Thanks for the suggestion, Michael. I tried declaring the scheduledTrigger as an array in the Forge manifest with the specified parameters, but I’m still getting an error when deploying.

 `>forge deploy
Deploying your app to the development environment.
Press Ctrl+C to cancel.

Running forge lint...
Error: The deploy failed due to errors in the app code. Fix the errors before rerunning forge deploy, or run forge deploy --no-verify to skip the linter.

2:2     error    scheduledTrigger should be array  valid-document-required

X 1 issue (1 error, 0 warnings)
  Issue found is not automatically fixable with forge lint.
Rerunning the command with --verbose may give more details.`

and this is what i wrote in my manifest file

      key: my-scheduled-trigger
      function: scheduled-trigger
      interval: week


Your syntax is a bit off. The key must be preceded by a hyphen " - ". Also, the indication of the repetition of the trigger should be in quotes.
Here I have formatted your manifest entry correctly:

        - key: my-scheduled-trigger
          function: scheduled-trigger
          interval: 'week'