Create Slack Bot using WolframAlpha API
I read a thread on Reddit about WolframAlpha API and I decided to try my hands on it. I created two slack Bot using WolframAlpha and both work very nicely see some of the best tweets from L. There is an issue with WolframAlpha API it allows only 2000 API calls in a month, you need to take their paid plans if you make heavy usages.
Ok, before we start the tutorial, I would like to mention, if you are preparing for the internship or full-time job, make sure you read one of the best guides currently available on the web: Summer Internship — The Ultimate Guide on Hackernoon And, if you want to contribute to Open Source projects like this Slack bot, I highly recommend you to read our Getting started with Open Source Guide.
Ok so let’s get started.
This tutorial is about How to create your own Slack Bot using WolframAlpha API. I created one but you can not use it directly as it uses my App-Id and can make only 2000 API calls. (Obviously, I’m not going to spend my money)
You need basic knowledge of python to create your own Slack Bot.
Dev WolframAlpha- Go to developer WolframAlpha and create your account.- Go to My apps section and click on Get an AppID.
Heroku- Go to Heroku and create an account there. Heroku allows you to deploy maximum 5 apps on the cloud for free.- Once you create your account there. Go to Dashboard.- Click on the ‘+’ sign or ‘New’ on the top right, create a new app.
- Write the name and click on Create App. - You will be redirected to your app page. Click on Connect to Dropbox. I’ll tell you the reason why we are choosing Dropbox to for our code hosting.
Files in your directory- LICENCE: This is my LICENCE file. - Procfile
: This is a startup file and tells what is the first step when we deploy our app on the cloud.- app.json
: It is a manifest format for describing web apps. It declares environment variables, add-ons, and other information required to run an app on Heroku. This document describes the schema in detail.- app.py
: Main part of your project. - config.py.example
: config.py
files store variables and other stuff which is used in your project (Flask).- requirements.txt
: This file specifies Python Module dependencies. All the required modules would be downloaded first while deploying your app. Read more about it here.
Changes to be made- Open your project click on fileconfig.py.example
and add your APP_ID in single quotes.- Change the name of the file from config.py.example
to config.py
.- If I upload my fileconfig.py
on GitHub, anyone can use my APP_ID to make calls. That’s the reason naming it as config.py.example
:p
commit
click on Deploy.{your_slack_url}/home
click on Add next to slash Commands.- Command: thel
[If you want to change this check explanation of the code below]- URL: {your_herokuapp_url}/thel
[This can be changed see, code below]- Customize name: Give it some name. I gave it — The L
- For the Autocomplete help text, check to show the command in auto-complete list.- Description: The Genius L, is now in slack to answer all your queries
OR [anything you want to write].- Usage Hint: search query
- Descriptive Level: Search Query
/thel
or [your command]
and type Query.I already explained usages of the files in the directory. I created this Slack Bot using WolframAlpha Module and Flask framework. You should know working with Python modules and all the syntax to understand the code.
Please comment below for the issues related to the post and anything related to the Slack bot. Please use the issue tracker to report any bugs or file feature requests. You can also join Eulercoder Organization on Github, just us an email with following details — Your Name, Your Education level and whether you want to join as a contributor or a mentor.
Clap to Recommend this guide.
This article was originally published on my blog: http://eulercoder.me
If anything is not clear and you want more in-depth information about something, please write an email to me — [email protected] . You can also subscribe to our mailing list to received weekly updates of our latest posts on Internships and Jobs!
Thank you!