├── README.md
├── images
├── SlideAI-logo.png
├── slideAI-UI.png
└── slideAI-sample.png
└── lib
├── Code.gs
└── index.html
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | [![Contributors][contributors-shield]][contributors-url]
4 | [![Forks][forks-shield]][forks-url]
5 | [![Stargazers][stars-shield]][stars-url]
6 | [![Issues][issues-shield]][issues-url]
7 | [![LinkedIn][linkedin-shield]][linkedin-url]
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
SlideAI
19 |
20 |
21 | SlideAI is an automated PowerPoint generator that streamlines the process of creating engaging presentations. By leveraging artificial intelligence, SlideAI takes care of content creation, slide design, and formatting, saving valuable time and effort. Simply input your key points, and SlideAI intelligently generates visually appealing slides with appropriate layouts, graphics, and text. It understands the context and presents information in a concise and captivating manner. With SlideAI, professionals can focus on delivering impactful presentations while eliminating the hassle of manual slide creation.
22 |
23 |
24 | Explore the docs »
25 |
26 | View Demo
27 | ·
28 | Report Bug
29 | ·
30 | Request Feature
31 |
32 |
33 |
34 |
35 |
36 |
37 | ## ♾️ About The Project
38 |
39 | SlideAI is an innovative project that aims to revolutionize the process of creating engaging presentations. Leveraging the power of artificial intelligence, SlideAI automates content creation, slide design, and formatting, providing a streamlined and efficient solution for professionals and individuals who frequently work with PowerPoint presentations.
40 |
41 | The main objective of SlideAI is to save valuable time and effort by eliminating the manual and repetitive tasks involved in creating visually appealing slides. With SlideAI, users can simply input their key points or content, and the AI-powered system intelligently generates captivating slides with appropriate layouts, graphics, and text.
42 |
43 | One of the key features of SlideAI is its ability to understand the context of the content provided. This ensures that the generated slides not only present the information in a concise manner but also capture the attention of the audience by using appropriate visual elements. The AI model behind SlideAI has been trained on a vast amount of data to recognize patterns, structure information effectively, and create compelling presentations.
44 |
45 | To enrich the visual experience, SlideAI incorporates the Bing API to search for relevant images on the internet. The system intelligently selects appropriate images based on the content and context of the slides, enhancing the overall quality and impact of the presentation.
46 |
47 | The underlying technology of SlideAI is built upon the OpenAI API, which provides a robust platform for natural language processing and generation. By leveraging this powerful API, SlideAI ensures that the generated content is coherent, well-structured, and aligned with the user's input.
48 |
49 | The benefits of using SlideAI are manifold. Professionals can focus more on the delivery and impact of their presentations, as the time-consuming tasks of slide creation and design are automated. This not only improves productivity but also allows presenters to create visually appealing and captivating presentations without the need for extensive design skills.
50 |
51 | In summary, SlideAI is a groundbreaking project that harnesses the power of artificial intelligence to automate PowerPoint presentation creation. By leveraging the OpenAI API for content generation and the Bing API for image search, SlideAI streamlines the process of creating engaging presentations, saving time, effort, and enhancing the overall quality of the final product. With SlideAI, professionals can deliver impactful presentations while leaving behind the hassle of manual slide creation.
52 |
53 | (back to top)
54 |
55 | ## ⚙️ Built With
56 |
57 | The technologies and tools used are:
58 |
59 | - [![AppScript][app-script]][app-script-url]
60 | - [![OpenAI API][openai]][openai-url]
61 | - [![Bing API][bing]][bing-url]
62 | - [![Google Slides API][googleslides]][googleslides-url]
63 |
64 | (back to top)
65 |
66 |
67 |
68 | ## 🧑💻 Getting Started
69 |
70 | Follow the below steps to set up the project:
71 |
72 | ### Prerequisites
73 |
74 | The project needs to be set up as an Appscript project, for that purpose you need to sign in at [AppScript](https://script.google.com/u/1/home/start)
75 |
76 | ### Installation
77 |
78 | 1. Setup a new AppScript Project.
79 | 2. Copy the files from lib folder to the project.
80 | 3. Replace the below API Keys with your ones:
81 |
82 | ```sh
83 | //Enter your details here
84 | //You will find your presntation ID in the link of your google slides.
85 | PRESENTATION_ID = "ENTER_YOUR_PRESENTATION_ID";
86 | OPENAI_KEY = "Bearer ENTER_YOUR_OPENAI_KEY";
87 | BING_API_KEY = "ENTER_YOUR_BING_SEARCH_API_KEY";
88 | ```
89 |
90 | 4. In your AppScript Project, from the left pane, add a Service named - **Google Slides API**
91 |
92 | 5. Deploy the project as a new deployment, keeping the settings as per your need.
93 |
94 | 6. Move to the deployment link and Enter the input details, and see the changes updated in your presentation.
95 |
96 | (back to top)
97 |
98 |
99 |
100 | ## 💡 Features
101 |
102 |
103 |
104 | - Presentation Maker for Projects
105 | - Image Inclusion using Bing API
106 | - Content Generation using OpenAI API
107 | - Presentation Design using Slides API
108 |
109 | (back to top)
110 |
111 |
112 |
113 | ## 🛣️ Roadmap
114 |
115 | - [x] Relevant Content Generation
116 | - [x] Relevant Image Addition
117 | - [x] Formatting of the Presentation
118 | - [ ] Automatic Download of the Presntation
119 |
120 | See the [open issues](https://github.com/siddhesh-desai/SlideAI/issues) for a full list of proposed features (and known issues).
121 |
122 | (back to top)
123 |
124 |
125 |
126 | ## 👣 Contributing
127 |
128 | Any contributions you make are **greatly appreciated**.
129 |
130 | If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
131 | Don't forget to give the project a star! Thanks again!
132 |
133 | 1. Fork the Project
134 | 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
135 | 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
136 | 4. Push to the Branch (`git push origin feature/AmazingFeature`)
137 | 5. Open a Pull Request
138 |
139 | (back to top)
140 |
141 |
142 |
143 | ## 📧 Contact
144 |
145 | Siddhesh Desai - [@thesiddheshdesai](https://www.linkedin.com/in/thesiddheshdesai/) - siddheshdesai777@gmail.com
146 |
147 | Project Link: [https://github.com/siddhesh-desai/SlideAI](https://github.com/siddhesh-desai/SlideAI)
148 |
149 | (back to top)
150 |
151 | ## 📸 Screenshots
152 |
153 |
154 |
155 |
156 |
157 |
158 | ## ✨ Contributors
159 |
160 | Thanks go to these wonderful people:
161 |
162 | - [Siddhesh Desai](https://github.com/siddhesh-desai/)
163 | - [Ashish Fargade](https://github.com/ashishfargade/)
164 | - [Pradyun Gayakwad](https://github.com/Pglol03/)
165 | - [Prathmesh Haridas](https://github.com/pjharidas/)
166 | - [Jayant Singh](https://github.com/jayantsingh-22)
167 |
168 | [contributors-shield]: https://img.shields.io/github/contributors/siddhesh-desai/SlideAI.svg?style=for-the-badge
169 | [contributors-url]: https://github.com/siddhesh-desai/SlideAI/graphs/contributors
170 | [forks-shield]: https://img.shields.io/github/forks/siddhesh-desai/SlideAI.svg?style=for-the-badge
171 | [forks-url]: https://github.com/siddhesh-desai/SlideAI/network/members
172 | [stars-shield]: https://img.shields.io/github/stars/siddhesh-desai/SlideAI.svg?style=for-the-badge
173 | [stars-url]: https://github.com/siddhesh-desai/SlideAI/stargazers
174 | [issues-shield]: https://img.shields.io/github/issues/siddhesh-desai/SlideAI.svg?style=for-the-badge
175 | [issues-url]: https://github.com/siddhesh-desai/SlideAI/issues
176 | [license-shield]: https://img.shields.io/github/license/siddhesh-desai/SlideAI.svg?style=for-the-badge
177 | [license-url]: https://github.com/siddhesh-desai/SlideAI/blob/master/LICENSE.txt
178 | [linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
179 | [linkedin-url]: https://linkedin.com/in/thesiddheshdesai
180 | [app-script]: https://img.shields.io/badge/AppScript-000000?style=for-the-badge&logo=javascript&logoColor=white
181 | [app-script-url]: https://developers.google.com/apps-script/
182 | [openai]: https://img.shields.io/badge/OpenAI-0769AD?style=for-the-badge&logo=OpenAI&logoColor=white
183 | [openai-url]: https://platform.openai.com/docs/introduction
184 | [bing]: https://img.shields.io/badge/BingAPI-20232A?style=for-the-badge&logo=microsoftbing&logoColor=61DAFB
185 | [bing-url]: https://www.microsoft.com/en-us/bing/apis
186 | [googleslides]: https://img.shields.io/badge/GoogleSlides-000000?style=for-the-badge&logo=google&logoColor=white
187 | [googleslides-url]: https://developers.google.com/slides/
188 |
--------------------------------------------------------------------------------
/images/SlideAI-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/siddhesh-desai/SlideAI/0ddbf887d236f4c57e21817fb8d6cfad45d21157/images/SlideAI-logo.png
--------------------------------------------------------------------------------
/images/slideAI-UI.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/siddhesh-desai/SlideAI/0ddbf887d236f4c57e21817fb8d6cfad45d21157/images/slideAI-UI.png
--------------------------------------------------------------------------------
/images/slideAI-sample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/siddhesh-desai/SlideAI/0ddbf887d236f4c57e21817fb8d6cfad45d21157/images/slideAI-sample.png
--------------------------------------------------------------------------------
/lib/Code.gs:
--------------------------------------------------------------------------------
1 | function doGet() {
2 | return HtmlService.createHtmlOutputFromFile("index");
3 | }
4 |
5 | var generatedUrls = [];
6 | var list = [];
7 |
8 | //Enter your details here
9 | PRESENTATION_ID = "ENTER_YOUR_PRESENTATION_ID";
10 | OPENAI_KEY = "Bearer ENTER_YOUR_OPENAI_KEY";
11 | BING_API_KEY = "ENTER_YOUR_BING_SEARCH_API_KEY";
12 |
13 |
14 |
15 | //Creating a new presentation
16 | function createPresentation() {
17 | try {
18 | const presentation = Slides.Presentations.create({ title: "SlideAI" });
19 | console.log("Created presentation with ID: " + presentation.presentationId);
20 | return presentation.presentationId;
21 | } catch (e) {
22 | // TODO (developer) - Handle exception
23 | console.log("Failed with error %s", e.message);
24 | }
25 | }
26 |
27 | //Delete Slides
28 | function deleteAllSlides(presentationId) {
29 | var presentation = SlidesApp.openById(presentationId);
30 | var slides = presentation.getSlides();
31 |
32 | // Iterate over each slide and delete it
33 | for (var i = slides.length - 1; i >= 0; i--) {
34 | var slide = slides[i];
35 | slide.remove();
36 | // presentation.removeSlide(slide);
37 | }
38 | }
39 |
40 | //Generate Link from Slides ID
41 | function generateSlidesLink(presentationId) {
42 | return "https://docs.google.com/presentation/d/" + presentationId + "/edit";
43 | }
44 |
45 | //Main Function
46 | function runn(
47 | project_name,
48 | project_description,
49 | color,
50 | author_names,
51 | institute_logo,
52 | occasion
53 | ) {
54 |
55 | //deleteAllSlides(PRESENTATION_ID);
56 | // const PRESENTATION_ID = createPresentation();
57 | // console.log(generateSlidesLink(PRESENTATION_ID));
58 | //Project Details
59 | // const project_name = "SlideAI";
60 | // const project_description = "SlideAI is an automated PowerPoint generator that streamlines the process of creating engaging presentations. By leveraging artificial intelligence, SlideAI takes care of content creation, slide design, and formatting, saving valuable time and effort. Simply input your key points, and SlideAI intelligently generates visually appealing slides with appropriate layouts, graphics, and text. It understands the context and presents information in a concise and captivating manner. With SlideAI, professionals can focus on delivering impactful presentations while eliminating the hassle of manual slide creation.";
61 | // const color = '#FF0000';
62 | // const author_names = 'XYZ';
63 | // const institute_logo = "https://img.collegepravesh.com/2017/05/VIT-Pune-Logo.png";
64 | // const occasion = 'EDI Review';
65 |
66 | // addTitleSlide(PRESENTATION_ID, project_name, color, occasion, 'Authors: ' + author_names);
67 | var slideIDDD = createSlide(PRESENTATION_ID, 0);
68 | addIntro(PRESENTATION_ID, project_name, project_description);
69 | addPS(PRESENTATION_ID, project_name, project_description);
70 | addMotivation(PRESENTATION_ID, project_name, project_description);
71 | addSolution(PRESENTATION_ID, project_name, project_description);
72 | addUnique(PRESENTATION_ID, project_name, project_description);
73 | addMethodology(PRESENTATION_ID, project_name, project_description);
74 | addTechnology(PRESENTATION_ID, project_name, project_description);
75 | addBenefits(PRESENTATION_ID, project_name, project_description);
76 | addLimitations(PRESENTATION_ID, project_name, project_description);
77 | addConclusion(PRESENTATION_ID, project_name, project_description);
78 | var slideIDD = createSlide(PRESENTATION_ID, 11);
79 | // addThankyouSlide(PRESENTATION_ID, color, author_names);
80 |
81 | addImagestoAllSlides(
82 | PRESENTATION_ID,
83 | project_description,
84 | color,
85 | institute_logo,
86 | project_name,
87 | occasion,
88 | author_names
89 | );
90 | }
91 |
92 | function generateDownloadLink(presentationId) {
93 | return (
94 | "https://docs.google.com/presentation/d/" + presentationId + "/export/pptx"
95 | );
96 | }
97 |
98 | function addTitleSlide(
99 | PRESENTATION_ID = "1ROXSzo28oiI8c6SSvsa1GXGruDkps9KpqlnoMqPLcQo",
100 | project_name = "SlideAI",
101 | color = "#FF0000",
102 | occasion = "EDI End Semester Examination",
103 | authors = "Authors: Siddhesh Desai, Ashish Fargade"
104 | ) {
105 | var slideID = createSlide(PRESENTATION_ID, 0);
106 | // var presentation = SlidesApp.openById(PRESENTATION_ID);
107 | // var slide = presentation.getSlides()[0];
108 |
109 | return;
110 | }
111 |
112 | function addThankyouSlide(PRESENTATION_ID, color, authors) {
113 | var slideIDD = createSlide(PRESENTATION_ID, 11);
114 | // var presentation = SlidesApp.openById(PRESENTATION_ID);
115 | // var slide = presentation.getSlides()[11];
116 |
117 | return;
118 | }
119 |
120 | function addImagestoAllSlides(
121 | PRESENTATION_ID = "1ROXSzo28oiI8c6SSvsa1GXGruDkps9KpqlnoMqPLcQo",
122 | project_description = "SlideAI is an automated PowerPoint generator that streamlines the process of creating engaging presentations. By leveraging artificial intelligence, SlideAI takes care of content creation, slide design, and formatting, saving valuable time and effort. Simply input your key points, and SlideAI intelligently generates visually appealing slides with appropriate layouts, graphics, and text. It understands the context and presents information in a concise and captivating manner. With SlideAI, professionals can focus on delivering impactful presentations while eliminating the hassle of manual slide creation.",
123 | color = "#FF0000",
124 | image_url = "https://img.collegepravesh.com/2017/05/VIT-Pune-Logo.png",
125 | project_name = "SlideAI",
126 | occasion = "Bla",
127 | authors = "sjbkas"
128 | ) {
129 | var presentation = SlidesApp.openById(PRESENTATION_ID);
130 | generateKeyWords(project_description);
131 | for (var i = 0; i < 13; i++) {
132 | var slide = presentation.getSlides()[i];
133 | if (i == 0) {
134 | addRectangleToSlide(slide, 0, 0, 750, 300, color);
135 | addTextToSlide(
136 | slide,
137 | 50,
138 | 90,
139 | 650,
140 | 80,
141 | project_name,
142 | 50,
143 | "League Spartan",
144 | "#FFFFFF"
145 | );
146 | addTextToSlide(
147 | slide,
148 | 50,
149 | 160,
150 | 650,
151 | 60,
152 | occasion,
153 | 30,
154 | "League Spartan",
155 | "#FFFFFF"
156 | );
157 | addTextToSlide(
158 | slide,
159 | 50,
160 | 330,
161 | 650,
162 | 60,
163 | authors,
164 | 20,
165 | "League Spartan",
166 | "#000000"
167 | );
168 | addLogo(slide, image_url);
169 | } else if (i == 11) {
170 | addRectangleToSlide(slide, 0, 0, 750, 300, color);
171 | addTextToSlide(
172 | slide,
173 | 50,
174 | 90,
175 | 650,
176 | 80,
177 | "Thank you!",
178 | 50,
179 | "League Spartan",
180 | "#FFFFFF"
181 | );
182 | addTextToSlide(
183 | slide,
184 | 50,
185 | 160,
186 | 650,
187 | 60,
188 | "Feel free to ask queries.",
189 | 30,
190 | "League Spartan",
191 | "#FFFFFF"
192 | );
193 | addTextToSlide(
194 | slide,
195 | 50,
196 | 330,
197 | 650,
198 | 60,
199 | authors,
200 | 20,
201 | "League Spartan",
202 | "#000000"
203 | );
204 | addLogo(slide, image_url);
205 | } else {
206 | addImage(slide, list[i % 10]);
207 | addRectangleToSlide(slide, 0, 0, 800, 10, color);
208 | }
209 | }
210 | return;
211 | }
212 |
213 | // Adding Introduction
214 | function addIntro(PRESENTATION_ID, project_name, project_description) {
215 | var slideID = createSlide(PRESENTATION_ID, 1);
216 |
217 | // var presentation = SlidesApp.openById(PRESENTATION_ID);
218 | // var slide = presentation.getSlides()[0];
219 | // if (slide) {
220 | prompt =
221 | "Write a curated introduction of 80 words for a presentation for the project named " +
222 | project_name +
223 | " which works as follows - " +
224 | project_description;
225 | addHeaderText(PRESENTATION_ID, slideID, "Introduction");
226 | content = truncateString(getInfo(prompt), 500);
227 | addContentText(PRESENTATION_ID, slideID, content);
228 | // addImage(slide, content);
229 | // Utilities.sleep(5000);
230 | // } else {
231 | console.log("Slide not found for ID: " + slideID);
232 | // }
233 | return;
234 | }
235 |
236 | // Adding Motivation
237 | function addMotivation(PRESENTATION_ID, project_name, project_description) {
238 | var slideID = createSlide(PRESENTATION_ID, 3);
239 |
240 | // var presentation = SlidesApp.openById(PRESENTATION_ID);
241 | // var slide = presentation.getSlides()[0];
242 |
243 | // if (slide) {
244 | prompt =
245 | "Understand and write the motivation of making the project less than 80 words for a presentation for the project named " +
246 | project_name +
247 | " which works as follows - " +
248 | project_description;
249 | addHeaderText(PRESENTATION_ID, slideID, "Motivation");
250 | content = getInfo(prompt);
251 | addContentText(PRESENTATION_ID, slideID, content);
252 | // addImage(slide, content);
253 | // Utilities.sleep(5000);
254 | // } else {
255 | console.log("Slide not found for ID: " + slideID);
256 | // }
257 | return;
258 | }
259 |
260 | //Add Problem Statement
261 | function addPS(PRESENTATION_ID, project_name, project_description) {
262 | var slideID = createSlide(PRESENTATION_ID, 2);
263 |
264 | // var presentation = SlidesApp.openById(PRESENTATION_ID);
265 | // var slide = presentation.getSlides()[0];
266 |
267 | // if (slide) {
268 | prompt =
269 | "Understand and write the problem statements in bullets for a presentation for the project named " +
270 | project_name +
271 | " which works as follows - " +
272 | project_description;
273 | addHeaderText(PRESENTATION_ID, slideID, "Problem Statement");
274 | content = getInfo(prompt);
275 | addContentText(PRESENTATION_ID, slideID, content);
276 | // addImage(slide, content);
277 | // Utilities.sleep(5000);
278 | // } else {
279 | // console.log("Slide not found for ID: " + slideID);
280 | // }
281 | return;
282 | }
283 |
284 | // Adding Our Solution
285 | function addSolution(PRESENTATION_ID, project_name, project_description) {
286 | var slideID = createSlide(PRESENTATION_ID, 4);
287 |
288 | // var presentation = SlidesApp.openById(PRESENTATION_ID);
289 | // var slide = presentation.getSlides()[0];
290 | // if (slide) {
291 | prompt =
292 | "Understand and write the content which should be of 70 words for 'Our Solution' Slide of presentation for the project named" +
293 | project_name +
294 | " which works as follows - " +
295 | project_description;
296 | addHeaderText(PRESENTATION_ID, slideID, "Our Solution");
297 | content = getInfo(prompt);
298 | addContentText(PRESENTATION_ID, slideID, content);
299 | // addImage(slide, content);
300 | // Utilities.sleep(5000);
301 | // } else {
302 | // console.log("Slide not found for ID: " + slideID);
303 | // }
304 | return;
305 | }
306 |
307 | // Adding What's Unique?
308 | function addUnique(PRESENTATION_ID, project_name, project_description) {
309 | var slideID = createSlide(PRESENTATION_ID, 5);
310 |
311 | // var presentation = SlidesApp.openById(PRESENTATION_ID);
312 | // var slide = presentation.getSlides()[0];
313 | // if (slide) {
314 | prompt =
315 | "Understand and write the unique features in bullet points for the project named" +
316 | project_name +
317 | " which works as follows - " +
318 | project_description +
319 | " It should be less than 80 Words";
320 | addHeaderText(PRESENTATION_ID, slideID, "What's Unique?");
321 | content = addSpaceAfterFullStop(getInfo(prompt));
322 | addContentText(PRESENTATION_ID, slideID, content);
323 | // addImage(slide, content);
324 | // Utilities.sleep(5000);
325 | // } else {
326 | // console.log("Slide not found for ID: " + slideID);
327 | // }
328 | return;
329 | }
330 |
331 | // Adding Methodology
332 | function addMethodology(PRESENTATION_ID, project_name, project_description) {
333 | var slideID = createSlide(PRESENTATION_ID, 6);
334 |
335 | // var presentation = SlidesApp.openById(PRESENTATION_ID);
336 | // var slide = presentation.getSlides()[0];
337 | // if (slide) {
338 | prompt =
339 | "Understand and write the methodology in less than 80 words for the presentation of the project named" +
340 | project_name +
341 | " which works as follows - " +
342 | project_description;
343 | addHeaderText(PRESENTATION_ID, slideID, "Methodology");
344 | content = getInfo(prompt);
345 | addContentText(PRESENTATION_ID, slideID, content);
346 | // addImage(slide, content);
347 | // Utilities.sleep(5000);
348 | // } else {
349 | // console.log("Slide not found for ID: " + slideID);
350 | // }
351 | return;
352 | }
353 |
354 | // Adding Technology Used
355 | function addTechnology(PRESENTATION_ID, project_name, project_description) {
356 | var slideID = createSlide(PRESENTATION_ID, 7);
357 |
358 | // var presentation = SlidesApp.openById(PRESENTATION_ID);
359 | // var slide = presentation.getSlides()[0];
360 | // if (slide) {
361 | prompt =
362 | "Understand and write the technologies and softwares used in bullet points for the presentation of the project named" +
363 | project_name +
364 | " which works as follows - " +
365 | project_description +
366 | " It should be less than 80 Words";
367 | addHeaderText(PRESENTATION_ID, slideID, "Technology Used");
368 | content = addSpaceAfterFullStop(getInfo(prompt));
369 | addContentText(PRESENTATION_ID, slideID, content);
370 | // addImage(slide, content);
371 | // Utilities.sleep(5000);
372 | // } else {
373 | // console.log("Slide not found for ID: " + slideID);
374 | // }
375 | return;
376 | }
377 |
378 | // Adding Benefits
379 | function addBenefits(PRESENTATION_ID, project_name, project_description) {
380 | var slideID = createSlide(PRESENTATION_ID, 8);
381 |
382 | // var presentation = SlidesApp.openById(PRESENTATION_ID);
383 | // var slide = presentation.getSlides()[0];
384 | // if (slide) {
385 | prompt =
386 | "Understand and write the benefits in bullet points for the presentation of the project named" +
387 | project_name +
388 | " which works as follows - " +
389 | project_description +
390 | " It should be less than 80 Words";
391 | addHeaderText(PRESENTATION_ID, slideID, "Benefits");
392 | content = addSpaceAfterFullStop(getInfo(prompt));
393 | addContentText(PRESENTATION_ID, slideID, content);
394 | // addImage(slide, content);
395 | // Utilities.sleep(5000);
396 | // } else {
397 | // console.log("Slide not found for ID: " + slideID);
398 | // }
399 | return;
400 | }
401 |
402 | // Adding Limitations
403 | function addLimitations(PRESENTATION_ID, project_name, project_description) {
404 | var slideID = createSlide(PRESENTATION_ID, 9);
405 |
406 | // var presentation = SlidesApp.openById(PRESENTATION_ID);
407 | // var slide = presentation.getSlides()[0];
408 | // if (slide) {
409 | prompt =
410 | "Understand and write the limitations in bullet points for the presentation of the project named" +
411 | project_name +
412 | " which works as follows - " +
413 | project_description +
414 | " It should be less than 80 Words";
415 | addHeaderText(PRESENTATION_ID, slideID, "Limitations");
416 | content = addSpaceAfterFullStop(getInfo(prompt));
417 | addContentText(PRESENTATION_ID, slideID, content);
418 | // addImage(slide, content);
419 | // Utilities.sleep(5000);
420 | // } else {
421 | // console.log("Slide not found for ID: " + slideID);
422 | // }
423 | return;
424 | }
425 |
426 | // Adding Conclusion
427 | function addConclusion(PRESENTATION_ID, project_name, project_description) {
428 | var slideID = createSlide(PRESENTATION_ID, 10);
429 |
430 | // var presentation = SlidesApp.openById(PRESENTATION_ID);
431 | // var slide = presentation.getSlides()[0];
432 | // if (slide) {
433 | prompt =
434 | "Understand and write the conclusion for the presentation of the project named" +
435 | project_name +
436 | " which works as follows - " +
437 | project_description +
438 | " It should be less than 80 Words";
439 | addHeaderText(PRESENTATION_ID, slideID, "Conclusion");
440 | content = getInfo(prompt);
441 | addContentText(PRESENTATION_ID, slideID, content);
442 | // addImage(slide, content);
443 | // Utilities.sleep(5000);
444 | // } else {
445 | // console.log("Slide not found for ID: " + slideID);
446 | // }
447 | return;
448 | }
449 |
450 | //Add Header Text
451 | function addHeaderText(presentationId, pageId, content) {
452 | //Get Unique ID
453 | const pageElementId = Utilities.getUuid();
454 |
455 | const requests = [
456 | {
457 | createShape: {
458 | objectId: pageElementId,
459 | shapeType: "TEXT_BOX",
460 | elementProperties: {
461 | pageObjectId: pageId,
462 | size: {
463 | width: {
464 | magnitude: 425,
465 | unit: "PT",
466 | },
467 | height: {
468 | magnitude: 60,
469 | unit: "PT",
470 | },
471 | },
472 | transform: {
473 | scaleX: 1,
474 | scaleY: 1,
475 | translateX: 36,
476 | translateY: 36,
477 | unit: "PT",
478 | },
479 | },
480 | },
481 | },
482 | {
483 | insertText: {
484 | objectId: pageElementId,
485 | text: content,
486 | insertionIndex: 0,
487 | },
488 | },
489 | {
490 | updateTextStyle: {
491 | objectId: pageElementId,
492 | fields: "foregroundColor,bold,italic,fontFamily,fontSize,underline",
493 | style: {
494 | foregroundColor: {
495 | opaqueColor: {
496 | themeColor: "ACCENT2",
497 | },
498 | },
499 | bold: true,
500 | italic: false,
501 | underline: false,
502 | fontFamily: "League Spartan",
503 | fontSize: {
504 | magnitude: 30,
505 | unit: "PT",
506 | },
507 | },
508 | textRange: {
509 | type: "ALL",
510 | },
511 | },
512 | },
513 | ];
514 |
515 | //Batch Update
516 | try {
517 | const response = Slides.Presentations.batchUpdate(
518 | {
519 | requests: requests,
520 | },
521 | presentationId
522 | );
523 | console.log(
524 | "Created Textbox with ID: " + response.replies[0].createShape.objectId
525 | );
526 | return response;
527 | } catch (e) {
528 | console.log("Failed with error %s", e.message);
529 | }
530 | }
531 |
532 | //Get Information from API
533 | function getInfo(prompt) {
534 | var response = UrlFetchApp.fetch(
535 | "https://api.openai.com/v1/engines/text-davinci-002/completions",
536 | {
537 | method: "post",
538 | headers: {
539 | "Content-Type": "application/json",
540 | Authorization:
541 | OPENAI_KEY,
542 | },
543 | payload: JSON.stringify({
544 | prompt: prompt,
545 | max_tokens: 1024,
546 | temperature: 0,
547 | n: 1,
548 | }),
549 | }
550 | );
551 |
552 | answer = JSON.parse(response).choices[0].text.trim();
553 | console.log(answer);
554 | return answer;
555 | }
556 |
557 | //Add Content Text
558 | function addContentText(presentationId, pageId, content) {
559 | //Get Unique ID
560 | const pageElementId = Utilities.getUuid();
561 |
562 | //Get Content Here
563 | // const content = 'sit amet justo donec enim diam vulputate ut pharetra sit amet aliquam id diam maecenas ultricies mi eget mauris pharetra et ultrices neque ornare aenean euismod elementum nisi quis eleifend quam adipiscing vitae proin sagittis nisl rhoncus mattis rhoncus urna neque viverra justo nec ultrices dui sapien eget mi proin sed libero enim sed faucibus turpis in eu mi bibendum neque egestas congue quisque egestas diam in arcu cursus euismod quis viverra nibh cras pulvinar mattis nunc sed blandit libero volutpat sed cras ornare arcu dui vivamus arcu felis bibendum ut tristique et egestas quis ipsum suspendisse ultrices gravida dictum';
564 |
565 | const requests = [
566 | {
567 | createShape: {
568 | objectId: pageElementId,
569 | shapeType: "TEXT_BOX",
570 | elementProperties: {
571 | pageObjectId: pageId,
572 | size: {
573 | width: {
574 | magnitude: 425,
575 | unit: "PT",
576 | },
577 | height: {
578 | magnitude: 300,
579 | unit: "PT",
580 | },
581 | },
582 | transform: {
583 | scaleX: 1,
584 | scaleY: 1,
585 | translateX: 36,
586 | translateY: 95,
587 | unit: "PT",
588 | },
589 | },
590 | },
591 | },
592 | {
593 | insertText: {
594 | objectId: pageElementId,
595 | text: content,
596 | insertionIndex: 0,
597 | },
598 | },
599 | {
600 | updateTextStyle: {
601 | objectId: pageElementId,
602 | fields: "foregroundColor,bold,italic,fontFamily,fontSize,underline",
603 | style: {
604 | foregroundColor: {
605 | opaqueColor: {
606 | themeColor: "ACCENT2",
607 | },
608 | },
609 | bold: false,
610 | italic: false,
611 | underline: false,
612 | fontFamily: "League Spartan",
613 | fontSize: {
614 | magnitude: 17,
615 | unit: "PT",
616 | },
617 | },
618 | textRange: {
619 | type: "ALL",
620 | },
621 | },
622 | },
623 | ];
624 |
625 | //Batch Update
626 | try {
627 | const response = Slides.Presentations.batchUpdate(
628 | {
629 | requests: requests,
630 | },
631 | presentationId
632 | );
633 | console.log(
634 | "Created Textbox with ID: " + response.replies[0].createShape.objectId
635 | );
636 | return response;
637 | } catch (e) {
638 | console.log("Failed with error %s", e.message);
639 | }
640 | }
641 |
642 | //Adding image on slide
643 | function addImage(slide, image_text) {
644 | var image_url = fetchImageUrl(image_text);
645 | if (image_url != null) {
646 | console.log("Inserted Here");
647 | console.log(slide);
648 | console.log(image_url);
649 | try {
650 | var image = slide.insertImage(image_url.trim());
651 | image.setWidth(245);
652 | image.setHeight(405);
653 | image.setLeft(475);
654 | image.setTop(0);
655 | return;
656 | } catch (e) {
657 | console.log("Image not found!");
658 | }
659 | } else {
660 | console.log("Image URL is null");
661 | }
662 | }
663 |
664 | //Adding logo on slide
665 | function addLogo(slide, image_url) {
666 | if (image_url != null) {
667 | console.log("Inserted Here");
668 | console.log(slide);
669 | console.log(image_url);
670 | var image = slide.insertImage(image_url.trim());
671 | image.setWidth(100);
672 | image.setHeight(100);
673 | image.setLeft(575);
674 | image.setTop(30);
675 | return;
676 | } else {
677 | console.log("Image URL is null");
678 | }
679 | }
680 |
681 | //Fetching Image URL
682 | function fetchImageUrl(image_text) {
683 | // var prompt = "Suggest only one keyword for image to be searched on internet which needs to be inserted on a powerpoint slide that has following content - " + image_text;
684 | // keywords = getInfoHigh(prompt);
685 | // if (generatedUrls.includes(keywords)) {
686 | // prompt = "Suggest only one keyword other than the following " + generatedUrls + " for image to be searched on internet which needs to be inserted on a powerpoint slide that has following content - " + image_text;
687 | // keywords = getInfoHigh(prompt);
688 | // generatedUrls.push(keywords);
689 | // }
690 | image_url = getImageUrlByKeywords(
691 | image_text,
692 | BING_API_KEY
693 | );
694 | console.log(image_url);
695 | return image_url;
696 | }
697 |
698 | //Get Information from API - Great Temperature
699 | function getInfoHigh(prompt) {
700 | var response = UrlFetchApp.fetch(
701 | "https://api.openai.com/v1/engines/text-davinci-002/completions",
702 | {
703 | method: "post",
704 | headers: {
705 | "Content-Type": "application/json",
706 | Authorization:
707 | OPENAI_KEY,
708 | },
709 | payload: JSON.stringify({
710 | prompt: prompt,
711 | max_tokens: 1024,
712 | temperature: 1,
713 | n: 1,
714 | }),
715 | }
716 | );
717 |
718 | answer = JSON.parse(response).choices[0].text.trim();
719 | console.log(answer);
720 | return answer;
721 | }
722 |
723 | //Add Space after full stop
724 | function addSpaceAfterFullStop(text) {
725 | var updatedText = text.replace(/\. /g, ".\n\n");
726 |
727 | return updatedText;
728 | }
729 |
730 | //removing extra stuff
731 | function truncateString(input, count) {
732 | if (input.length <= count) {
733 | return input;
734 | }
735 |
736 | var truncatedText = input.substr(0, count);
737 | var lastFullStopIndex = truncatedText.lastIndexOf(".");
738 |
739 | if (lastFullStopIndex !== -1) {
740 | truncatedText = truncatedText.substr(0, lastFullStopIndex + 1);
741 | }
742 | console.log(truncatedText);
743 | return truncatedText;
744 | }
745 |
746 | //Creating a new slide
747 | function createSlide(presentationId, num) {
748 | const pageId = Utilities.getUuid();
749 |
750 | const requests = [
751 | {
752 | createSlide: {
753 | objectId: pageId,
754 | insertionIndex: num,
755 | slideLayoutReference: {
756 | predefinedLayout: "BLANK",
757 | },
758 | },
759 | },
760 | ];
761 |
762 | try {
763 | const slide = Slides.Presentations.batchUpdate(
764 | {
765 | requests: requests,
766 | },
767 | presentationId
768 | );
769 | console.log(
770 | "Created Slide with ID: " + slide.replies[0].createSlide.objectId
771 | );
772 | return pageId;
773 | } catch (e) {
774 | // TODO (developer) - Handle Exception
775 | console.log("Failed with error %s", e.message);
776 | }
777 | }
778 |
779 | //Fetching image url from Bing API
780 | function getImageUrlByKeywords(
781 | keywords,
782 | apiKey = BING_API_KEY
783 | ) {
784 | var query = encodeURIComponent(keywords);
785 | var url =
786 | "https://api.bing.microsoft.com/v7.0/images/search?q=" +
787 | query +
788 | "&count=1&safeSearch=Strict";
789 |
790 | var response = UrlFetchApp.fetch(url, {
791 | headers: {
792 | "Ocp-Apim-Subscription-Key": apiKey,
793 | },
794 | });
795 |
796 | var result = JSON.parse(response.getContentText());
797 |
798 | if (result.value && result.value.length > 0) {
799 | var bestMatchUrl = result.value[0].contentUrl;
800 | console.log(bestMatchUrl);
801 | return bestMatchUrl;
802 | } else {
803 | return null; // No image found
804 | }
805 | }
806 |
807 | //Generate keywords
808 | function generateKeyWords(content) {
809 | jsonn = getInfo(
810 | "Understand and Generate 10 tools and computer technologies separated by comma related to the below project - " +
811 | content
812 | );
813 | console.log(jsonn);
814 | list = csvToList(jsonn);
815 | console.log(list);
816 | }
817 |
818 | function csvToList(csvString) {
819 | // Split the CSV string into an array of values
820 | if (csvString.includes(",")) {
821 | var csvValues = csvString.split(",");
822 | } else {
823 | var csvValues = csvString.split("\n");
824 | }
825 |
826 | // Trim whitespace from each value and create a new list
827 | var list = csvValues.map(function (value) {
828 | return removeNumbersSpacesFullStops(value.trim());
829 | });
830 |
831 | return list;
832 | }
833 |
834 | //String to list
835 | function stringToJsonToList(inputString) {
836 | // Convert string to JSON object
837 | var jsonObject = JSON.parse(inputString);
838 |
839 | // Convert JSON object to list
840 | var list = [];
841 | for (var key in jsonObject) {
842 | if (jsonObject.hasOwnProperty(key)) {
843 | list.push(jsonObject[key]);
844 | }
845 | }
846 |
847 | return list;
848 | }
849 |
850 | function addRectangleToSlide(
851 | slide,
852 | left = 0,
853 | top = 0,
854 | width = 750,
855 | height = 10,
856 | color = "#FF0000"
857 | ) {
858 | var rectangle = slide.insertShape(SlidesApp.ShapeType.RECTANGLE);
859 | rectangle.setWidth(width);
860 | rectangle.setHeight(height);
861 | rectangle.setLeft(left);
862 | rectangle.setTop(top);
863 | rectangle.getFill().setSolidFill(color);
864 | rectangle.getBorder().getLineFill().setSolidFill(color);
865 | return;
866 | }
867 |
868 | function addTextToSlide(
869 | slide,
870 | left,
871 | top,
872 | width,
873 | height,
874 | content,
875 | fontSize,
876 | fontFamily,
877 | textColor
878 | ) {
879 | var textBox = slide.insertTextBox(content);
880 | textBox.setWidth(width);
881 | textBox.setHeight(height);
882 | textBox.setLeft(left);
883 | textBox.setTop(top);
884 |
885 | // Set text style for font size and family
886 | var textRange = textBox.getText();
887 | var textStyle = textRange.getTextStyle();
888 | textStyle.setFontSize(fontSize);
889 | textStyle.setFontFamily(fontFamily);
890 | textStyle.setBold(true);
891 |
892 | // Set text color
893 | textStyle.setForegroundColor(textColor);
894 | }
895 |
896 | function removeNumbersSpacesFullStops(input) {
897 | // Remove numbers
898 | var withoutNumbers = input.replace(/[0-9]/g, "");
899 |
900 | // Remove spaces
901 | var withoutSpaces = withoutNumbers.replace(/\s/g, "");
902 |
903 | // Remove full stops
904 | var withoutFullStops = withoutSpaces.replace(/\./g, "");
905 |
906 | return withoutFullStops;
907 | }
908 |
--------------------------------------------------------------------------------
/lib/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SlidesAI
6 |
7 |
8 |
9 |
10 |
146 |
147 |
148 |
155 |
225 |
226 |
259 |
260 |
261 |
--------------------------------------------------------------------------------