This Google Apps Script injects an AI-powered writing assistant in Google Docs. The script is powered by OpenAI's Chat Completions API.
The tool provides these features within Google Docs:
- Generate Ideas: Generate 10 ideas based on input text.
- Generate Essay: Generates ~400 essay based on prompt.
- Summarize Text: Summarize given text.
- Generate Social Media Posts: Generate text for social media posts on Twitter, Linkedin and Instagram.
Watch the demo video below to see this tool in action:
doc-assistant-demo.webm
Components
- Google Docs: Google Docs serve as the starting point where you can use this tool.
- Google Apps Script: The
DocAssistant.gsscript adds a new menu item "DocAssistant" and sub menus for different features within Google Docs. The script invokes OpenAI Chat Completions API with a prompt that includes details about the selected feature and the selected text. - OpenAI Chat Completions API: The OpenAI API generates the content as requested by user. I used
gpt-3.5-turbomodel for the demo, see Usage section for using a different model.
- User Input: User selects some text and selects one of features from the "DocAssistannt" menu.
- Generate Prompt: The
DocAssistant.gsscript generates a prompt based on the selected feature and the selected text. - Invoke OpenAI Chat Completions API: The script invokes the OpenAI Chat Completions API with the generated prompt.
- Update Document: The script appends the LLMs response at the end of the document.
- Open any document in Google Docs and go to: Extensions > Apps Script.
- Add the Google Apps Script (DocAssistant.gs) to your project.
- Set script properties:
OPENAI_API_KEY: Set your OpenAI keyOPENAI_MODEL: Set model name (Default isgpt-3.5-turbo)
DocAssistantmenu will appear in the Google Docs menu bar.

