paint-brush
Create your first Slack bot that can answer any queries using WolframAlpha APIby@tvicky002
1,328 reads
1,328 reads

Create your first Slack bot that can answer any queries using WolframAlpha API

by Vikesh TiwariSeptember 5th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

I read a thread on Reddit about WolframAlpha API and I decided to try my hands on it. I created two <a href="https://hackernoon.com/tagged/slack" target="_blank">slack</a> Bot using WolframAlpha and both work very nicely see some of the best tweets from <a href="https://twitter.com/The_L__" title="Open The L on Twitter" target="_blank">L</a>. 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.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Create your first Slack bot that can answer any queries using WolframAlpha API
Vikesh Tiwari HackerNoon profile picture

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.

Steps to create Slack Bot

Step 1: Basic Stuff



  • Dev WolframAlpha- Go to developer WolframAlpha and create your account.- Go to My apps section and click on Get an AppID.

  • Note your AppID. You will use this AppID to make calls.



  • 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.

Step 2: Changes in Code

  • Download my repo in Zip or fork it to make changes on git in the future.






  • 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

Step 3: Upload your code to Dropbox

  • open your Dropbox account.
  • If you have connected your account to Dropbox as mentioned in step 1. Open this link.
  • You’ll see a folder with the name of your app on Heroku .
  • Open that folder and upload all your files there.

Step 4: Deploying your app on Heroku

  • Open your Heroku Dashboard.
  • Click on your app and then deploy.
  • In deploy tab, in Deploy changes section. Write andcommit click on Deploy.
  • This will download all the app dependencies. If everything is fine, you will see a green tick and your deploy is on the cloud!

Step 5: Integrate it in your team

  • Open your slack. It should be like.{your_slack_url}/home
  • Click on Integration in the upper left section.
  • Click on Configured Integrations.





  • 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 queriesOR [anything you want to write].- Usage Hint: search query - Descriptive Level: Search Query

Step 6: All Done!

  • Open your slack channel and type /thel or [your command] and type Query.
  • Everything is working fine you will see the result.
  • Try basic Queries first for the testing purpose, it will give an instant response.
  • Congratulation you just created a new Slack Bot for your own Team!! Have fun! 🍻

Explanation of the Code

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!