├── README.md └── script.js /README.md: -------------------------------------------------------------------------------- 1 | # autodeck 2 | Automatic pitch deck generator for Google Sheets (v0.1) 3 | -------------------------------------------------------------------------------- /script.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | async function onOpen(e) { 5 | var response = await createDeck("Kitten mittens"); 6 | 7 | } 8 | 9 | 10 | function appendSlideWithTitleAndBody(title, body) { 11 | var presentation = SlidesApp.getActivePresentation(); 12 | var slide = presentation.appendSlide(); 13 | 14 | var slideWidth = presentation.getPageWidth(); 15 | var slideHeight = presentation.getPageHeight(); 16 | 17 | var titleShape = slide.insertShape(SlidesApp.ShapeType.TEXT_BOX, 50, 50, slideWidth - 100, 50); 18 | var titleText = titleShape.getText(); 19 | titleText.setText(title); 20 | titleText.getTextStyle().setFontSize(36); 21 | titleText.getTextStyle().setBold(true); 22 | 23 | var bodyShape = slide.insertShape(SlidesApp.ShapeType.TEXT_BOX, 50, 120, slideWidth - 100, slideHeight - 150); 24 | var bodyText = bodyShape.getText(); 25 | bodyText.setText(body); 26 | bodyText.getTextStyle().setFontSize(30); 27 | } 28 | 29 | 30 | function appendSlideWithTitleBodyAndImage(title, body, imageUrl) { 31 | var presentation = SlidesApp.getActivePresentation(); 32 | var slide = presentation.appendSlide(); 33 | 34 | var slideWidth = presentation.getPageWidth(); 35 | var slideHeight = presentation.getPageHeight(); 36 | 37 | var titleShape = slide.insertShape(SlidesApp.ShapeType.TEXT_BOX, 50, 50, slideWidth - 300, 50); 38 | titleShape.getText().setText(title); 39 | 40 | var bodyShape = slide.insertShape(SlidesApp.ShapeType.TEXT_BOX, 50, 100, slideWidth - 300, slideHeight - 150); 41 | bodyShape.getText().setText(body); 42 | 43 | var imageWidth = slideWidth - (slideWidth - 250); 44 | var imageHeight = slideHeight - 100; 45 | 46 | var imageBlob = UrlFetchApp.fetch(imageUrl).getBlob(); 47 | var image = slide.insertImage(imageBlob, slideWidth - imageWidth - 50, 50, imageWidth, imageHeight); 48 | } 49 | 50 | 51 | 52 | 53 | async function createDeck(input) { 54 | updateFirstShapeText(input); 55 | console.log("getCompletion"); 56 | const apiUrl = 'https://api.openai.com/v1/completions'; 57 | prompt = 'You are an illustrative writer and expert marketer who specializes in venture capital and startup analysis. For the provided startup description, write a 7 part narrarative targeting investors on why investing in this startup is great opportunity. Each section should be one sentence. Provide the answer as a JSON array with the following format:{"problem":"This startup provides a platform to create an online marketplace for small independent sellers to connect with customers, reducing barriers to entry to the e-commerce space and allowing them to reach more customers than ever before.","approach":"By leveraging a network of small business owners, the startup is empowering these merchants to compete with the established players in the e-commerce space, leveling the playing field and providing better value to customers.","solution":"The startup\'s platform offers an easy-to-use interface and low transaction fees for merchants, allowing them to quickly launch their own online store and start selling in minutes.","customer":"The ideal customer for this startup is a small business owner who wants to reach more customers but doesn\u2019t have the resources to set up their own website or pay for expensive advertising.","market":"The total addressable market for this startup is estimated to be around $10 billion globally, with the potential to expand into other markets as the platform becomes more popular.","go to market":"The startup will focus on onboarding small business owners through targeted ads and influencer marketing, as well as building relationships with independent retailers and providing them with the resources they need to get started.","funding":"The startup is looking to raise $3 million in venture capital, with the goal of selling 10-15% of the company for this amount.","inspiring quote":"\'Today\u2019s mighty oak is just yesterday\u2019s nut, that held its ground\' - David Icke"}### STARTUP DESCRIPION'+input+'.###RESULT (JSON):'; 58 | const body = JSON.stringify({ 59 | model : "text-davinci-003", 60 | prompt: prompt, 61 | max_tokens: 1000, 62 | stop: ['###'], 63 | temperature: 0.7 64 | }); 65 | const options = { 66 | method: 'POST', 67 | headers: { 68 | 'Content-Type': 'application/json', 69 | 'Authorization': `Bearer sk-...` //ADD API KEY HERE 70 | }, 71 | payload: body, 72 | muteHttpExceptions: true 73 | }; 74 | const response = UrlFetchApp.fetch(apiUrl, options); 75 | const json = JSON.parse(response.getContentText()); 76 | console.log(json); 77 | const answer = JSON.parse(json.choices[0].text.trim()); 78 | processJson(answer); 79 | return json.choices[0].text.trim(); 80 | } 81 | 82 | 83 | function processJson(json) { 84 | console.log("processJson") 85 | for (const key in json) { 86 | if (json.hasOwnProperty(key)) { 87 | const value = json[key]; 88 | // Call your function here and pass in the key and value 89 | // For example, if your function is called myFunction: 90 | //myFunction(key, value); 91 | console.log("key: "+key+". value: "+value); 92 | appendSlideWithTitleAndBody(key, value); 93 | } 94 | } 95 | } 96 | 97 | 98 | function updateFirstShapeText(text) { 99 | var presentation = SlidesApp.getActivePresentation(); 100 | var slide = presentation.getSlides()[0]; // Get the first slide 101 | var shape = slide.getShapes()[0]; // Get the first shape of the slide 102 | var textRange = shape.getText(); 103 | textRange.setText(text); // Update the text of the shape 104 | var shape = slide.getShapes()[1]; // Get the first shape of the slide 105 | var textRange = shape.getText(); 106 | textRange.setText("Pitch Deck Draft"); // Update the text of the shape 107 | } 108 | --------------------------------------------------------------------------------