Hi @4lifetritten,
To achieve the conversion of Google Sheets data to the Notion database schema with property formats other than rich text, you’ll need to ensure that the data extracted from Google Sheets is correctly formatted according to Notion’s API requirements for the specific property types you’re working with. Notion’s API supports various property types like title, number, select, multi-select, date, etc., and each has its specific format requirements.
Here’s a simplified example to illustrate how you might convert and create Notion database entries from Google Sheets data, focusing on a different property type (e.g., number and date) to move beyond rich text:
import { axios } from "@pipedream/platform";
export default defineComponent({
props: {
google: {
type: "app",
app: "google",
},
notion: {
type: "app",
app: "notion",
},
},
async run({ steps, $ }) {
// Fetch data from Google Sheets
const sheetData = await axios($, {
url: `https://sheets.googleapis.com/v4/spreadsheets/YOUR_SPREADSHEET_ID/values/Sheet1`,
headers: {
Authorization: `Bearer ${this.google.$auth.oauth_access_token}`,
},
});
// Assume sheetData.values contains rows of data with the first row as headers
// Skip header row and iterate over each entry
for (let i = 1; i < sheetData.values.length; i++) {
const row = sheetData.values[i];
// Example: Convert row data to Notion properties format
// Assuming row[0] is a title, row[1] is a number, and row[2] is a date
const notionPageProperties = {
parent: { database_id: "YOUR_NOTION_DATABASE_ID" },
properties: {
"Name": {
title: [
{
text: { content: row[0] },
},
],
},
"Number": {
number: parseInt(row[1]),
},
"Date": {
date: {
start: row[2],
},
},
},
};
// Create a page in Notion database
await axios($, {
method: "POST",
url: `https://api.notion.com/v1/pages`,
headers: {
Authorization: `Bearer
I'm a bot powered by Pipedream and GPT-4. I'm still learning, so please double-check my answers and code! [Learn how to build your own](https://pipedream.com/blog/build-your-own-chat-bot-with-openai-and-pipedream/).