-
I want a widget that when tapped, prompts for a bit of text, then adds the text to Notion. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Regarding NotionI'm not familiar with Notion, so I don't know about the details, but it looks like they have a REST API, so this should be possible. I found their API documentation here: https://developers.notion.com/reference/post-page The easiest way to get started is probably to copy the cURL code snippet that you get from the documentation page (the code on the right) and then opening the HTTP Shortcuts app, clicking the + button, selecting "Import from cURL Command", then pasting the copied code into there and confirming. This will create a new shortcut which should have most of the settings you need. You might have to adjust the Method to be "POST" (looks like there's a bug in my app currently regarding that). You will also have to modify the "Authorization" Request Header. I needs to contain a valid API token instead of Regarding prompting for textYes, this is possible, and there are 2 ways of doing it. The easiest way is to create a variable of type "Text Input" and use that in your shortcut where needed (in this case probably in the request body). Steps how to do this:
Now, whenever you trigger this shortcut, it will prompt you to enter text, which will then be inserted at the place where you put the variable placeholder. More about variable can be found here: https://http-shortcuts.rmy.ch/variables |
Beta Was this translation helpful? Give feedback.
-
For anyone who wants to Quickly add a to-do item to a Notion page, here is the API call: curl -X PATCH "https://api.notion.com/v1/blocks/$PAGE_ID/children" \
-H 'Authorization: Bearer '"$NOTION_API_KEY"'' \
-H "Content-Type: application/json" \
-H "Notion-Version: 2021-08-16" \
--data '{
"children": [
{
"object": "block",
"type": "to_do",
"to_do": {
"text": [
{
"type": "text",
"text": {
"content": "$TEXT"
}
}
]
}
}
]
}' And this is the export from HTTP-Shortcuts {
"categories": [
{
"id": "d269f4e6-1327-48cd-a371-fb595963a7cb",
"name": "Shortcuts",
"shortcuts": [
{
"authToken": "$NOTION_API_KEY",
"authentication": "bearer",
"bodyContent": "{\"children\": [{\"object\": \"block\",\"type\": \"to_do\",\"to_do\": {\"text\": [{\"type\": \"text\",\"text\": {\"content\": \"{{d9136efd-2506-40ac-9093-70f984156a34}}\"}}]}}]}",
"headers": [
{
"id": "4b910a25-ee2a-4217-8fe7-4475f64ad4c7",
"key": "Content-Type",
"value": "application/json"
},
{
"id": "9e1f5262-d56d-4730-89f5-0b3c5d8c41ba",
"key": "Notion-Version",
"value": "2021-08-16"
}
],
"iconName": "flat_color_lightbulb_2",
"id": "7566afad-45c3-4669-85bd-ac2395cc6536",
"launcherShortcut": true,
"method": "PATCH",
"name": "notion",
"responseHandling": {
"id": "b3ef4e94-35c3-48b5-a7b0-44bc9b9bbf04",
"successMessage": "Saved!",
"successOutput": "message",
"uiType": "toast"
},
"url": "https://api.notion.com/v1/blocks/$PAGE_ID/children"
}
]
}
],
"variables": [
{
"id": "d9136efd-2506-40ac-9093-70f984156a34",
"key": "task",
"title": "Task",
"type": "text"
}
],
"version": 45
} |
Beta Was this translation helpful? Give feedback.
For anyone who wants to Quickly add a to-do item to a Notion page, here is the API call:
And this is the export from HTTP-Shortcuts