First you have to create a telegram bot using @BotFather. Once a conversation began use its commands and click on
/start. Then follow the procedure:
- On the command list select the command
/newbotand choose a name for your bot, for example:
- Choose an username for your bot, it must end with
bot, for example:
- At this point Botfather will tell you that the creation has taken place successfully and will send you a message with the token to be used to interact with the bot via HTTP API. We will use this token in the quarkus section
- You can start a new conversation with your bot from the
telegram.me/<bot_username>to verify that everything was created correctly.
Create an integration#
First of all you have to create an integration which is the way in which Notion allows third-party applications to interact with their resources, to do this you have to go to this page: My integrations, and click on the + New Integration button
On the Basic Information page choose a name for your integration, select a workspace in which the extension will be enabled and click on Submit.
Now on the integration page you must get the Internal Integration Token which we will need later in the configuration of our application.
Create a DB and connect to the integration#
At this point we need to create our Notion database which we will then connect to the integration we have just created. Create a new Page and put a new database, choose a title and set the column in this way:
|Type: Checkbox||Type: Title||Type: URL||Type: Multi-select||Type: Date|
If you want to launch the project without any modification, give the name to the columns exactly as indicated in the table above.
Now click on the three dots in the upper right of the page, click on the add connections button, select the integration you created earlier and Confirm.
If you did everything correctly now your integration is correctly linked to your database. Congrats!
- API documentation: https://developers.notion.com/reference
- Postman Collection: https://www.postman.com/notionhq/
- Database object: https://developers.notion.com/reference/database
- Page object: https://developers.notion.com/reference/page
- Create a page: https://developers.notion.com/reference/post-page
- Property values: https://developers.notion.com/reference/property-value-object
Within the Quarkus project, the
application.yaml file must be created and positioned in the
src->main->Resources folder, with this content:
#QUARKUS quarkus: smallrye-health: root-path: /health http: port: 30090 rest-client: notionclient-api: url: 'https://api.notion.com/v1/' scope: 'javax.inject.Singleton' #TELEGRAM telegram: bot: username: <YOUR_BOT_USERNAME> token: <YOUR_BOT_TOKEN> formatted: response: 'Page with title: "%1$s" saved in Notion database with tags: %2$s' #NOTION notion: db: <YOUR_NOTION_DATABASE_ID> secret: <YOUR_NOTION_SECRET_KEY> version: '2022-06-28'
<YOUR_BOT_USERNAME>: is the username that you choose for your bot in the Telegram section, ex:
<YOUR_BOT_TOKEN>: is the token that Botfather sends you back when you create a new bot
<YOUR_NOTION_DATABASE_ID>: is the id of your notion database that you can read in the url of your database page
<YOUR_NOTION_SECRET_KEY>: is the Internal Integration Token that you get in the Secrets tab of your integration