Friday, April 7, 2017

Let's Bot In!





I was trying out the steps on building a slack bot and I would like to share my notes with you guys.

Here are some takeaways on this blog:
1. How to set the base Python Version in your virtual environment.
2. How to switch to the created virtual environments.
3. How to export environment variables in windows.

Let's start!

I am running a Windows 8.1 machine with both python 2.7 and 3.5 installed in their respective folders.
c:\Python27
c:\Python35

Part of the process is to create a virtual environment to have an independent library structure and avoid conflicts. I created a virtual environment via PowerShell and used python 3.5 as the base. Here's a guide on how to create virualenv on Windows with PowerShell.

To run PowerShell in Windows, go to the command prompt and run: C:\>powershell
 
By default, my machine is runnning Python 2.7. To set the base Python version of the virtual environment to 3.5, perform the steps below: Go to your virtual environmnt directory:

 Set the base Python version:

To work on or switch to other virtual environments, use the command:

One of the challenges I had was how to export the secret tokens as environment variables. The line below does not work for me.

The syntax is different for windows. After searching the interwebs, this article helped me out. I replaced the line instead with the script below and I was able to extract the bot ID.:

That's about it! I just followed the steps and was able to deploy a slack bot! Developing the bot brains is a different story, but hey! I got it working... hohohoho..

No comments:

Post a Comment