How to Search or Retrieve a Notion Card in a Database Using a GitHub PR Title?

This topic was automatically generated from Slack. You can find the original thread here.

I’m setting up a workflow where in when there’s a new PR in Github, I want the PR URL to be added on an existing Notion card inside a Notion database. What are the best way to search or retrieve a notion card in a database using the title of the PR in github?

To achieve the workflow where a new PR in GitHub triggers the addition of the PR URL to an existing Notion card inside a Notion database, you can follow these steps. This solution involves using the GitHub trigger for new or updated pull requests and then searching for a Notion card by title (which matches the title of the PR) to update it with the PR URL. ### Step 1: Set up the GitHub Trigger 1. Search for the GitHub app from the trigger menu in your Pipedream workflow. 2. Select the “New or Updated Pull Request” trigger. 3. Connect your GitHub account. 4. Select the repository you want to monitor for new or updated pull requests. ### Step 2: Retrieve the Notion Card in a Database To search or retrieve a Notion card in a database using the title of the PR from GitHub, you’ll need to use the Notion API. Unfortunately, as of my last update, there isn’t a direct action in Pipedream’s pre-built components for searching a Notion database by title. However, you can achieve this by making an HTTP request to the Notion API using a custom code step in your workflow. Here’s an example code snippet that you can use in a Node.js code step to search for a Notion page by title: ``` import { axios } from “@pipedream/platform” export default defineComponent({ props: { notion: { type: “app”, app: “notion”, }, }, async run({ steps, $ }) { const databaseId = “your-database-id-here”; // Replace with your Notion Database ID const prTitle = steps.trigger.event.pull_request.title; // Assuming this is the step that triggers the workflow const response = await axios($, { method: “POST”, url: https://api.notion.com/v1/databases/${databaseId}/query, headers: { Authorization: Bearer ${this.notion.$auth.oauth_access_token}, “Notion-Version”: “2021-08-16”, }, data: { filter: { property: “Name”, // Assuming “Name” is the property where the PR title would match text: { contains: prTitle, }, }, }, }); // Assuming the first result is the page you want to update const pageId =

can you translate the code above into a python code