01.5.6 New Page in Database
Node New Page in Database triggers the execution of the scenario when a page is added to the Notion database.
For example, let's create a scenario that:
- Runs when a new page is added to the Notion database;
- Converts and returns data about the created page in JSON format.
![](/img/notion/505692fb-2105-494a-9cb3-d0a830612124/Untitled.png)
You need to add three nodes:
- (1) New Page in Database, to triggers the scenario and retrieves data about the added page;
![](/img/notion/91cb3e50-50f5-4a93-8356-f568e3c9aefc/Untitled.png)
- (2) JavaScript, to transform the information into the required format using code;
![](/img/notion/8011fd7a-3cd0-40c7-802f-5917606c9825/Untitled.png)
export default async function run({execution_id, input, data}) {
const Row = data["{{1.data.properties.Fruit.title.[0].text.content}}"];
const Edited = data["{{1.data.last_edited_time}}"];
const resultRawJSON = JSON.stringify({
"Row": Row,
"Edited": Edited,
});
return {
resultRawJSON
}
}
- (3) Webhook response, to returning the scenario execution response.
![](/img/notion/f5c9265a-4301-4e1c-9aa1-9ea729e18332/Untitled.png)
The result of the scenario execution is a JSON with the necessary attributes of the added page:
![](/img/notion/42e0297c-efd3-44c1-9501-3a893fe5e45d/Untitled.png)
{"Row":"Pineapple","Edited":"2023-11-01T20:13:00.000Z"}