Notion icon
To automate your workflows, you need to sign an account first. It’s free.

Notion Flows

Notion Integration for

Quick Start


This is a changed database forward (to telegram) bot.

use std::env;

use notion_flows::{database_update_handler, listen_to_database_update, notion::models::Page};
use tg_flows::{ChatId, Telegram};

#[tokio::main(flavor = "current_thread")]
pub async fn run() {
    let database = env::var("database").unwrap();


async fn handler(page: Page) {
    let title = page.title().unwrap_or("<untitled>".to_string());
    let pros: String = page
        .map(|(k, v)| format!("- {}: {:?}", k, v))

    let msg = format!("# {}\n{}", title, pros);

    let chat_id = env::var("chat_id").unwrap();
    let chat_id = ChatId(chat_id.parse().unwrap());

    let token = env::var("token").unwrap();
    let tele = Telegram::new(token);
    tele.send_message(chat_id, msg).ok();

[listen_to_database_update()] is responsible for registering a listener for the database. When a new database changes (as page) coming, the handler is called with received Page.


    use std::str::FromStr;
    use notion_flows::notion::{ids::PageId, NotionApi};

    let notion = NotionApi::new("API_TOKEN").unwrap();
    let page_id = PageId::from_str("PAGE_ID").unwrap();
    let page = notion.get_page(page_id).await;

Action as NotionApi.

ref: Notion API Reference