{
  "updatedAt": "2024-10-16T02:43:16.000Z",
  "createdAt": "2024-10-16T02:39:57.577Z",
  "id": "MYlyUIJyAnCEntvf",
  "name": "Note Notion with Telegram Bot - Share",
  "description": null,
  "active": false,
  "isArchived": false,
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "id": "b24e63a2-f269-4f65-b177-8bbeda620798",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        840,
        420
      ],
      "webhookId": "b4bc60c9-ea55-4072-ab52-e6d292a3a5bb",
      "credentials": {
        "telegramApi": {
          "id": "Pcl8w8DIgdcIHukY",
          "name": "notion helper bot"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $json.message.from.id }}",
        "text": "Nhập:\n[Tiêu đề ]\n[Nội dung]",
        "replyMarkup": "forceReply",
        "forceReply": {
          "force_reply": true
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "098f8a0e-be29-4c1b-bd37-2cbc875c5ef0",
      "name": "hoi_ghi_chu",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1380,
        40
      ],
      "credentials": {
        "telegramApi": {
          "id": "Pcl8w8DIgdcIHukY",
          "name": "notion helper bot"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $('set').item.json.message.from.id }}",
        "text": "=Done  {{ $json.url }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "c5c237e3-b9b2-4e0d-b3eb-6b4765a12a7f",
      "name": "hoi_ghi_chu1",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1820,
        240
      ],
      "credentials": {
        "telegramApi": {
          "id": "Pcl8w8DIgdcIHukY",
          "name": "notion helper bot"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6e613571-ae25-40df-981b-5610caf6f1de",
              "name": "title",
              "value": "={{ $json.message.text.split(\"\\n\").first() }}",
              "type": "string"
            },
            {
              "id": "b45acd11-25c0-4d9b-9575-26ebe583c4b4",
              "name": "description",
              "value": "={{ $json.message.text }}",
              "type": "string"
            },
            {
              "id": "4f4d0111-7ad7-470a-9d84-74f18cc6265a",
              "name": "message.from.id",
              "value": "={{ $json.message.from.id }}",
              "type": "number"
            },
            {
              "id": "1e48be93-e48b-4d48-bcff-87fa4035ff9b",
              "name": "=khongDau",
              "value": "={{ $json.message.text.toLowerCase().normalize('NFD').replace(/[\\u0300-\\u036f]/g, '').replaceAll('đ','d').replaceAll('Đ','d') }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "48c8c6a1-d008-4b5e-aa78-b3f1abb3d1c2",
      "name": "set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1380,
        240
      ]
    },
    {
      "parameters": {
        "chatId": "={{ $json.message.from.id }}",
        "text": "Tìm gì?:\nTừ khóa cần tìm",
        "replyMarkup": "forceReply",
        "forceReply": {
          "force_reply": true
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "ef72cf45-ff1e-4f95-8805-5122ef0bffe1",
      "name": "hoi_tim",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1380,
        400
      ],
      "credentials": {
        "telegramApi": {
          "id": "Pcl8w8DIgdcIHukY",
          "name": "notion helper bot"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": "=/ghichu",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "=ghichu"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "243768a0-a47c-4010-a760-b68826fd65f1",
                    "leftValue": "={{ $json.message.reply_to_message.text }}",
                    "rightValue": "Nhập:",
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "nhap_ghi_chu"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "d3b1a6c0-06d4-465d-9b52-4ab87d2498ed",
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": "/tim",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "tim"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "ef73fec2-5a88-42f7-85a0-6fb84d924a77",
                    "leftValue": "={{ $json.message.reply_to_message.text }}",
                    "rightValue": "=Tìm gì?:",
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "tim_gi"
            }
          ]
        },
        "options": {}
      },
      "id": "862fadef-68f6-4ce2-a75c-61a8830f4dac",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.1,
      "position": [
        1060,
        420
      ]
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": {
          "__rl": true,
          "value": "11cca8ef-cb26-80eb-81f2-ea5733823461",
          "mode": "list",
          "cachedResultName": "Database ghi chú - template",
          "cachedResultUrl": "https://www.notion.so/11cca8efcb2680eb81f2ea5733823461"
        },
        "filterType": "manual",
        "filters": {
          "conditions": [
            {
              "key": "Name|title",
              "condition": "contains",
              "titleValue": "={{ $json.message.text }}"
            },
            {
              "key": "keyword không dấu|rich_text",
              "condition": "contains",
              "richTextValue": "={{ $json.message.text.toLowerCase().normalize('NFD').replace(/[\\u0300-\\u036f]/g, '').replaceAll('đ','d').replaceAll('Đ','d') }}"
            }
          ]
        },
        "options": {}
      },
      "id": "29cdb9df-9cf8-4efd-b631-f34d3da7cfc4",
      "name": "search",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        1380,
        600
      ],
      "alwaysOutputData": true,
      "credentials": {
        "notionApi": {
          "id": "AQhyFgKXkfRXnuKJ",
          "name": "Binh notion"
        }
      }
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "options": {}
      },
      "id": "46084e49-6633-4b74-a4d9-337bc3e46b37",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        1620,
        600
      ],
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "0bc5c613-0585-46c9-82ce-b0076e7b1f65",
              "leftValue": "={{ $json.data[0] }}",
              "rightValue": 0,
              "operator": {
                "type": "object",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "e8d2fb9a-1fe6-4175-a555-3d4bdf723a22",
      "name": "If_has_results",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.1,
      "position": [
        1840,
        600
      ]
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "=Kết quả:  {{ $json.data.length }}\n- {{ $json.data.map(item => `[${item.name}](${item.url})`).join(\"\\n- \") }}",
        "replyMarkup": "inlineKeyboard",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "2d358ecb-9f60-4a6d-961f-cad2b2104457",
      "name": "tra_ve_list_ket_qua",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        2120,
        440
      ],
      "credentials": {
        "telegramApi": {
          "id": "Pcl8w8DIgdcIHukY",
          "name": "notion helper bot"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "=Không có kết quả nào!",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "4de9c214-3eb3-44d7-8059-cbef5c0f45b8",
      "name": "bao_khong_co_ket_qua",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        2120,
        620
      ],
      "credentials": {
        "telegramApi": {
          "id": "Pcl8w8DIgdcIHukY",
          "name": "notion helper bot"
        }
      }
    },
    {
      "parameters": {
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "value": "11cca8ef-cb26-80eb-81f2-ea5733823461",
          "mode": "list",
          "cachedResultName": "Database ghi chú - template",
          "cachedResultUrl": "https://www.notion.so/11cca8efcb2680eb81f2ea5733823461"
        },
        "title": "={{ $json.title }}",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Chi tiết|rich_text",
              "textContent": "={{ $json.description }}"
            },
            {
              "key": "keyword không dấu|rich_text",
              "textContent": "={{ $json.khongDau }}"
            }
          ]
        },
        "options": {}
      },
      "id": "f8b667b5-b275-48a6-a37f-cfff316d310b",
      "name": "them_ghi_chu",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        1600,
        240
      ],
      "credentials": {
        "notionApi": {
          "id": "AQhyFgKXkfRXnuKJ",
          "name": "Binh notion"
        }
      }
    },
    {
      "parameters": {
        "content": "## Hướng dẫn sử dụng\n\n1. Tạo bot Telegram: chat với BotFather (https://t.me/BotFather) để tạo\n\nLấy API Token và tạo Command với format\nghichu - Ghi chú\ntim - tìm ghi chú\n\n2. Nhân bản template [Ghi chú Notion Telegram Bot](https://agate-plant-c32.notion.site/11cca8efcb2680eb81f2ea5733823461?v=11cca8efcb2681a18be0000cef4ae5cb&pvs=4)\n3. Tạo một Interation (App) trong Notion [Link tạo Interatetion](https://www.notion.so/profile/integrations) => Lấy key api Notion\n\n4. Sửa các node báo lỗi báo đỏ do chưa thiết lập chứng thức Notion và Telegram Bot\n5. Sẵn sàng sử dụng\n\n",
        "height": 388.58100558659214,
        "width": 427.12849162011184
      },
      "id": "fd1590aa-cae1-473f-8620-704289312350",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        660,
        -20
      ]
    }
  ],
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "set": {
      "main": [
        [
          {
            "node": "them_ghi_chu",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "hoi_ghi_chu",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "set",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "hoi_tim",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "search": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "If_has_results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If_has_results": {
      "main": [
        [
          {
            "node": "tra_ve_list_ket_qua",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "bao_khong_co_ket_qua",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "them_ghi_chu": {
      "main": [
        [
          {
            "node": "hoi_ghi_chu1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "pinData": {},
  "versionId": "172d397b-38ae-48fb-bdcf-30a88eb58cc4",
  "activeVersionId": null,
  "versionCounter": 1,
  "triggerCount": 1,
  "shared": [
    {
      "updatedAt": "2024-10-16T02:39:57.587Z",
      "createdAt": "2024-10-16T02:39:57.587Z",
      "role": "workflow:owner",
      "workflowId": "MYlyUIJyAnCEntvf",
      "projectId": "Nlp7kXCVcAfb0cmG",
      "project": {
        "updatedAt": "2024-07-25T03:06:26.102Z",
        "createdAt": "2024-07-25T03:06:26.102Z",
        "id": "Nlp7kXCVcAfb0cmG",
        "name": "Bình Đặng <dangngocbinh.dnb@gmail.com>",
        "type": "personal",
        "icon": null,
        "description": null,
        "creatorId": "92f1ca82-c19e-4a7d-8458-93b65f67f4c7"
      }
    }
  ],
  "tags": [
    {
      "updatedAt": "2024-10-04T03:03:40.628Z",
      "createdAt": "2024-10-04T03:03:40.628Z",
      "id": "MW10UcI4NI01thiG",
      "name": "share"
    }
  ],
  "activeVersion": null
}