For the pull requests related question, you should take a look at this blog post: https://blog.jetbrains.com/teamcity/2019/08/building-github-pull-requests-with-teamcity/
Although this blog post explains this all from the UI perspective, you can serialize all the config to Kotlin DSL as described in the first post about Kotlin DSL: https://blog.jetbrains.com/teamcity/2019/03/configuration-as-code-part-1-getting-started-with-kotlin-dsl/