Generate Presentation Using AI wherever u want
Method: POST
Request body contain "topic", "extraInfoSource", "email", "accessId", "slideCount" (Optional)
{ "topic": "Enter topic Name", "extraInfoSource": "Enter some extra infoSource", "email": "Enter your email", "accessId": "Enter your accessId" }
Method: POST
Request body contain "msSummaryText", "email", "accessId", "slideCount" (Optional)
{ "msSummaryText": "Enter Summary", "email": "Enter your email", "accessId": "Enter your accessId" }
Method: POST
Request body contain "youtubeURL", "email", "accessId", "slideCount" (Optional)
{ "youtubeURL: "Enter Only Youtube URL", "email": "Enter your email", "accessId": "Enter your accessId" }
Example, Let’s Build Slack Bot Using these API’s
Create a Slackbot with the MagicSlides App API.
Creating a Slackbot using the MagicSlides App API can be a fantastic project to enhance productivity and collaboration within your team. In this blog post, we'll walk through the steps to create a Slackbot that interacts with the MagicSlides App API, allowing users to seamlessly access and share presentation slides directly within Slack.
What is MagicSlides?
MagicSlides.app is a Google Slide add-on & Web App that uses AI to quickly and easily create presentation slides from any piece of text. It automatically summarises the text and creates slides from it, allowing users to customise their presentation as they see fit.
In less than two to three seconds, users can have a professional presentation ready.
Additionally, users can provide additional text to get more personalised presentations. MagicSlides is easy to use and requires no technical knowledge.
It is a great tool for quickly creating professional presentations.
Prerequisites For MagicSlides API SlackBot
Before we start building our Slackbot, make sure you have the following:
- A Slack workspace where you have permissions to create and configure Slack apps.
- Access to the Magicslides API documentation and necessary credentials (API key, tokens, etc.).
Step 1: Set Up Your Slack App
- Go to the Slack API website: https://api.slack.com/
- Log in with your Slack account.
- Navigate to "Your Apps" and click on "Create New App".
- Fill in the required details such as App Name and choose the workspace you want to develop the app for.
- Once your app is created, navigate to the "OAuth & Permissions" section.
Add following OAuth scope in Bot Token Scopes:
- Click on “Install to Workspace”.One token will generate which is your ‘SLACK_BOT_TOKEN’
- Go to Socket mode and enable socket mode
- Click on App Home and enable both Home and Message tab
- Click on event Subscribe and add the User Events which showing in image
- Click on basic information>App level token and generate token which is your ‘SLACK_APP_TOKEN’
Step 2: Build Your Slackbot
Now, let's write some code to create our Slackbot. You can use any programming language and framework of your choice. Below is a simple node.js example
require('dotenv').config(); const { App } = require('@slack/bolt'); const { URL } = require('url'); const axios = require('axios'); const app = new App({ token: process.env.SLACK_BOT_TOKEN, signingSecret: process.env.SLACK_SIGNING_SECRET, appToken: process.env.SLACK_APP_TOKEN, socketMode: true }); const youtubeRegex = /^(https?\:\/\/)?(www\.)?(youtube\.com\/watch\?v=|youtu\.be\/).+$/; app.message(async ({ message, say }) => { try { const urls = extractUrls(message.text); const messageLength = message.text.trim().length; let isYoutubeLink = false; for (const url of urls) { if (url.match(youtubeRegex)) { isYoutubeLink = true; const apiResponse = await axios.post('Your youTubeURL to ppt convert URL', { youtubeURL: url, email: 'Your Email', accessId: 'Your token to access above url' }); // console.log('API Response:', apiResponse.data); await say({ text: `YouTube API Response: ${JSON.stringify(apiResponse.data.url)}`, channel: message.channel }); break; } } const pdfRegex = /^(https?:\/\/)?([^\/\s]+\/)(\S+)\.pdf$/i; let isPdfLink = false; for (const url of urls) { const decodedUrl = decodeURIComponent(url).replace(/>/g, ''); console.log("These is ppt url...........", decodedUrl.match(pdfRegex)); if (decodedUrl.match(pdfRegex)) { isPdfLink = true; const apiResponse = await axios.post('Your pdfURL to ppt convert URL', { pdfURL: decodedUrl, email: 'Your Email', accessId: 'Your token to access above url' }); await say({ text: `PDF API Response: ${JSON.stringify(apiResponse.data.url)}`, channel: message.channel }); break; } } const isOtherLink = false; for (const url of urls) { const decodedUrl = decodeURIComponent(url).replace(/>/g, ''); console.log("These is url.........", decodedUrl) if (!isYoutubeLink && !isPdfLink) { const isOtherLink = true; const apiResponse = await axios.post('Your URL to ppt convert URL', { webURL: decodedUrl, email: 'Your Email', accessId: 'Your token to access above url' }); console.log('API Response:', apiResponse.data); await say({ text: `Simple API Response: ${JSON.stringify(apiResponse.data.url)}`, channel: message.channel }); break; } } if (!isYoutubeLink && !isPdfLink && !isOtherLink) { if (messageLength < 12) { await say('Invalid input, Try after sometime'); } else if (messageLength > 100) { const pptApiResponse = await axios.post('Your Summery to PPT convert URL', { msSummaryText: message.text, email: 'Your Email', accessId: 'Your token to access above url' }); await say({ text: `Summary API Response: ${JSON.stringify(pptApiResponse.data.url)}`, channel: message.channel }); } else if(messageLength>12 && messageLength<99){ const pptApiResponse = await axios.post('Your Topic to PPT convert URL', { topic: 'Indian Army', extraInfoSource: null, email: 'Your Email', accessId: 'Your token to access above url' }); await say({ text: `Topic to PPT API Response: ${JSON.stringify(pptApiResponse.data.url)}`, channel: message.channel }); } } } catch (error) { console.error(error); } }); // Function to extract URLs from text using the URL module function extractUrls(text) { const urlRegex = /(https?:\/\/[^\s]+)/g; const urls = text.match(urlRegex); return urls ? urls.map(url => new URL(url).href) : []; } // Start your app (async () => { await app.start(); console.log('Bot is running!'); })();
Step 3: Deploy Your Slackbot
Deploy your Slackbot to a server or a cloud platform where it can run continuously and respond to incoming requests from Slack.
nodejs api can be deployed to vercel, render and more
Conclusion:
Congratulations! You've successfully created a Slackbot that interacts with the MagicSlides App API, allowing users to easily share presentation slides within Slack channels.
Feel free to extend this bot with additional features or integrate it with other APIs to further enhance its functionality.
If need any help at any point feel free to send email to support@magicslides.app