Hey @little-cartoon-10569 this is closed source code from pulumi-service, so I can't easily link it to you. We use the github app to receive webhook events from github, and we run the preview on the target branch when there's a pull request open or update event.
To do this with bitbucket you would either need a bitbucket app that similarly receives webhook events and creates a preview deployment, or, you could poll bitbucket at regular intervals to see if any new PRs have been created and then run a preview on the target branches.