{"id":13433595,"url":"https://github.com/HCYT/notionAI","last_synced_at":"2025-03-17T13:30:33.703Z","repository":{"id":110978325,"uuid":"609450275","full_name":"HCYT/notionAI","owner":"HCYT","description":"NotionAI.js is a JavaScript library for accessing OpenAI's GPT-3 language model through the Notion API. Generate human-like text, translate, and change tone with ease.","archived":false,"fork":false,"pushed_at":"2023-03-24T04:04:13.000Z","size":60,"stargazers_count":21,"open_issues_count":7,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-28T16:12:46.797Z","etag":null,"topics":["chatgpt","gpt-3","js","notion","notion-api","notionai"],"latest_commit_sha":null,"homepage":"https://pmlife.day/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HCYT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-03-04T07:51:45.000Z","updated_at":"2024-07-31T07:36:44.000Z","dependencies_parsed_at":"2024-01-21T03:17:46.690Z","dependency_job_id":"bb5b27c1-d738-4659-96c5-dc00fb7aee63","html_url":"https://github.com/HCYT/notionAI","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HCYT%2FnotionAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HCYT%2FnotionAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HCYT%2FnotionAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HCYT%2FnotionAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HCYT","download_url":"https://codeload.github.com/HCYT/notionAI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244041327,"owners_count":20388218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt","gpt-3","js","notion","notion-api","notionai"],"created_at":"2024-07-31T02:01:30.250Z","updated_at":"2025-03-17T13:30:33.347Z","avatar_url":"https://github.com/HCYT.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Hello user\n\nIf you need the latest information or want to raise an issue, please visit my Github page. Note that the NPM page will only be updated when new versions are released.\n\nPlease use the latest version, v1.0.4.\n\nThe next version will be v1.1.0, as referenced in https://github.com/HCYT/notionAI/issues/7\n\n# NotionAI.js\n\nNotionAI.js is a JavaScript library that provides a simple and convenient interface for interacting with the Notion API. It includes functions for writing prompts, changing the tone of text, translating text, and more.\n\n## Installation \n\nTo get started, you can either clone or fork the project from GitHub, or use \"npm install\" to install it.\nTo install NotionAI.js, you can use npm:\n\n```\nnpm i @cyh0809/notionai\n```\n\n### usage\n\n```\n// setting and import\nconst { NotionAI,TOPICS,TONE,LANGUAGE } = require('@cyh0809/notionai')\nconst dotenv = require('dotenv')\ndotenv.config({ path: './.env' });\nconst notionAI = new NotionAI(process.env[\"NOTION_TOKEN\"], process.env[\"NOTION_SPACE_ID\"]);\n\n\n// usage example\nlet prompt = \"\";\nlet topic =\"poem\"\nprompt = \"give me a poem\";\nasync function example1(topic, prompt) {\n    \n    try {\n        const result = await notionAI.writingPrompt(prompt);\n        console.log(`Writing with topic \"${topic}\": ${result}`);\n    } catch (err) {\n        console.error(err);\n    }\n}\n\nexample1(topic,prompt);\n```\n\nMake sure to replace process.env[\"NOTION_TOKEN\"] and process.env[\"NOTION_SPACE_ID\"] with your actual Notion API token and spaceId, respectively.\n\nThe NotionAI class relies on the setting class for its configuration options, which include the Notion API token and spaceId.\n\nTo use the NotionAI class, you can import it and create a new instance with the Notion API token and space ID. Then, you can call any of its methods with the appropriate parameters to make a request to the Notion API.\n\n## How to get the token and spaceId\n\nMake sure you subscribe to NotionAI; otherwise, you will only be able to use it 20 times.\n\nYou can refer to https://github.com/HCYT/notionAI/issues/1 to learn how to get the token and spaceId.\n\n\n------------------------------------------\n\nThe NotionAI supports multiple types:\n\n## option usage\n### TOPICS, TONE, LANGUAGE\n```\n/// TOPICS\nTOPICS.helpMeWrite\nTOPICS.helpMeEdit\nTOPICS.helpMeDraft\nTOPICS.continueWriting\nTOPICS.changeTone\nTOPICS.summarize\nTOPICS.improveWriting\nTOPICS.fixSpellingGrammar\nTOPICS.translate\nTOPICS.explainThis\nTOPICS.makeLonger\nTOPICS.makeShorter\nTOPICS.findActionItems\nTOPICS.simplifyLanguage\n/// TONE\nTONE.professional\nTONE.casual\nTONE.straightforward\nTONE.confident\nTONE.friendly\n/// LANGUAGE\nLANGUAGE.english\nLANGUAGE.korean\nLANGUAGE.chinese\nLANGUAGE.japanese\nLANGUAGE.spanish\nLANGUAGE.russiab\nLANGUAGE.french\nLANGUAGE.german\nLANGUAGE.italian\nLANGUAGE.portuguese\nLANGUAGE.dutch\nLANGUAGE.indonesia\nLANGUAGE.tagalog\nLANGUAGE.vietnamese\n```\n\n## usage\n\nIf you use the `helpMeWrite` or `helpMeDraft` option, you can follow this example\n\n```\nasync function example2(topic, prompt) {\n    try {\n        const result = await notionAI.writing(topic, prompt);\n        console.log(`Writing with topic \"${topic}\": ${result}`);\n        return result;\n    } catch (err) {\n        console.error(err);\n    }\n}\n\nconst prompt=\"give me a joke\";\nexample2(TOPICS.helpMeDraft,prompt)\n\n```\n\n\nIf you use the `helpMeEdit` option, you can follow this example\n\n```\nlet prompt=\"help Me Edit the article \"\nlet pageTitle=\"the page title you already has\"\nlet pageContent=\"the page content you already has\"\nlet selectedText=\"you need ai help you edit content\"\n\nasync function example3(topic, prompt, pageTitle, pageContent, selectedText) {\n    try {\n      const result = await notionAI.writing(topic, prompt, pageTitle, pageContent, selectedText);\n      console.log(`Writing with topic \"${topic}\": ${result}`);\n      return result;\n    } catch (err) {\n      console.error(err);\n      return err;\n    }\n  }\n\n  example3(TOPICS.helpMeEdit, prompt, pageTitle, pageContent, selectedText);\n\n```\n\n\nIf you use the `continueWriting` option, you can follow this example\n\n```\n\nlet pageTitle=\"the article title\"\nlet previousContent=\"the previous Content\"\nlet restContent=\"paragraph you need to continue\"\n\nasync function example4(pageTitle, previousContent, restContent) {\n  try {\n    const text = await notionAI.writing(TOPICS.helpMeEdit, pageTitle, previousContent, restContent);\n    console.log(`Writing with topic \"${TOPICS.helpMeEdit}\": ${text}`);\n    return text;\n  } catch (err) {\n    console.error(err);\n  }\n}\n```\n\n\n\nIf you use the `summarize`,`improveWriting`,`fixSpellingGrammar`,`explainThis`,`makeLonger`,`makeShorter`,`findActionItems`,`simplifyLanguage` option, you can follow this example\n\n```\n\nlet pageTitle=\"joke\"\nlet selectedText=\"joke\",\"Why did the scarecrow win an award? Because he was outstanding in his field.\";\nasync function example5(pageTitle, selectedText) {\n  try {\n    const result = await notionAI.writing(TOPICS.makeLonger, pageTitle, selectedText);\n    console.log(`Writing with topic \"${TOPICS.makeLonger}\": ${result}`);\n  } catch (err) {\n    console.error(err);\n  }\n}\n\n```\n\n\n### changeTone of article\n\n`changeTone(tone, text)`: This method takes a tone and text as input and returns a result from the Notion API.\n\nYou can use the option\n\n``` \nTONE.professional\nTONE.casual\nTONE.straightforward\nTONE.confident\nTONE.friendly\n```\n#### usage\n\n```\nlet text = \"This document provides an introduction to the composition of a Scrum team, including the Scrum Master, the Product Owner, and the development team members.\"\n\nasync function example6() {\n  try {\n    const result = await notionAI.changeTone(TONE.professional, text);\n    console.log(`Writing with topic \"${topic}\": ${result}`);\n  } catch (err) {\n    console.error(err);\n  }\n}\n\n```\nResult\nThis document will introduce you to the members of a Scrum team, including the Scrum Master, the Product Owner, and the development team members.\n\n\n### writingPrompt\n\npageTitle,selectedText,pageContent allow null,you can use \"\"\n\n#### usage\n\n```\nwritingPrompt(prompt, pageTitle, selectedText, pageContent)\n\nlet prompt = \"tell me a joke\"\nwritingPrompt(prompt, \"\", \"\", \"\")\n\n```\n\n#### You can refer to the following prompt list\n```\nBrainstorm Ideas - A process of generating a large number of creative ideas or solutions to a problem through group discussion or individual brainstorming.\n\nBlog Post - An online article or entry written in a blog format that covers a specific topic, typically written in an informal or conversational style.\n\nOutline - A structured plan or summary of a document, speech, or project, usually presented in bullet points or headings.\n\nSocial Media Post - A message or update posted on a social media platform, such as Facebook, Twitter, or Instagram, to communicate with an audience and engage with them.\n\nPress Release - A written or recorded statement to the media announcing news, events, or product launches related to a business or organization.\n\nCreative Story - A narrative work of fiction or non-fiction that uses imaginative language, vivid imagery, and creative techniques to convey a message or entertain the reader.\n\nEssay - A short piece of writing that expresses the author's perspective or argument on a specific topic, typically written in a formal style and structured into paragraphs.\n\nPoem - A piece of writing that uses language, sound, and rhythm to evoke emotions, express thoughts or feelings, or convey a message.\n\nMeeting Agenda - A list of topics or items to be discussed during a meeting, usually arranged in a specific order and including the time allotted for each item.\n\nPros and Cons List - A method of decision-making or analysis that lists the advantages and disadvantages of a particular choice or option.\n\nJob Description - A document that outlines the duties, responsibilities, and requirements of a particular job position.\n\nSales Email - An email message sent to potential customers to introduce a product or service, highlight its features and benefits, and persuade them to make a purchase.\n\nRecruiting Email - An email message sent to job seekers to promote a job opportunity, explain the company's culture and values, and invite them to apply for the position.\n```\n\n### Translate Article\n`translateText(language, text)`: This method takes a language and text as input and returns a result from the Notion API.\n\nYou can translate to these language\n```\nenglish, korean, chinese, japanese, spanish, russiab, french, german, italian, portuguese, dutch, indonesia, tagalog, vietnamese\n```\n\nusage\n```\nlet text = \"This document provides an introduction to the composition of a Scrum team, including the Scrum Master, the Product Owner, and the development team members.\"\n\nasync function myFunction() {\n  try {\n    const result = await notionAI.translateText(LANGUAGE.chinese, text);\n    console.log(`translateText : ${result}`);\n  } catch (err) {\n    console.error(err);\n  }\n}\n\n```\n\n\n\n\n## Contributing\nWelcome to contribute to NotionAI.js by creating pull requests or issues. If you find any bugs or have suggestions for new features, please feel free to open an issue on the GitHub repository. We appreciate any contributions and will review them as soon as possible.\n\n## License\nNotionAI is licensed under the [MIT](https://github.com/HCYT/notionAI/blob/master/LICENSE) License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHCYT%2FnotionAI","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHCYT%2FnotionAI","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHCYT%2FnotionAI/lists"}