Amazon Alexa Meets IBM Domino

I had the honor of becoming a contributor for the outstanding NotesIn9 Video Podcast produced by David Leedy. In this show, I demonstrate how I built and Amazon Alexa Skill for the IBM Domino based IdeaJam app. If you have any questions, please let me know. I would be more than happy to answer them! Thank you, David, for having me on. More videos on building Alexa Skills coming soon.

IBM Bluemix Weather Company API with Python

Here is a simple example of calling the IBM Weather Company REST API using Python. The program asks for a US ZIP code and then displays some of the data. A perfect program for an intro to programming class. Also, on GitHub.


# Using the IBM Bluemix Weather Company API
# Bruce Elgort
# July 9, 2016
# Version 1.0
# IBM Weather Company Docs: https://console.ng.bluemix.net/docs/services/Weather/weather_rest_apis.html#rest_apis

import requests
import json

def get_weather(zip):
    username = 'your username'
    password = 'your password'

    watsonUrl = 'https://twcservice.mybluemix.net/api/weather/v1/location/' + zip + ':4:US' + '/observations.json?language=en-US'

    try:
        r = requests.get(watsonUrl,auth=(username,password))
        return r.text
    except:
        return False

def display_weather(results):
    print()
    print('Here is the weather for {0}'.format(results['observation']['obs_name']))
    print('{0:20} {1:<10}'.format('Current Temperature:',str(results['observation']['temp']) + '° and ' + results['observation']['wx_phrase']))
    print('{0:20} {1:<10}'.format('Feels Like: ',str(results['observation']['feels_like']) + '°'))
    print('{0:20} {1:<10}'.format('Low Temp: ',str(results['observation']['min_temp']) + '°'))
    print('{0:20} {1:<10}'.format('High Temp: ',str(results['observation']['max_temp']) + '°'))
    print('{0:20} {1:<10}'.format('Winds:',str(results['observation']['wspd']) + ' mph coming from the ' + results['observation']['wdir_cardinal']))

def get_weather():
    zip = input('Enter US ZIP code to get weather for:\n')
    results = get_weather(zip)
    if results != False:
        results = json.loads(str(results))
        display_weather(results)
    else:
        print('Something went wrong :-(')

if __name__ == '__main__':
    get_weather()

Using the Slack API with Python – A Simple Example

Here is a simple Python program that can be used to:

  • Test the API
  • Get a list of Slack Users
  • Get a list of Slack Channels
  • Get information about a Slack Channel
  • Post a message to Slack Channel

Students in my Intro to Programming and Problems Solving class at Clark College learn how to build this and other things using Python.

Have fun with it!

On Github >

# CTEC 121 / Intro to Programming and Problem Solving
# Lab - Using the Slack API
# by Bruce Elgort, 2016

# pip install slackclient to install SlackClient library
from slackclient import SlackClient
import json

def test_slack(sc):
    # use for debugging
    print("Testing API")
    print(80 * "=")
    print (sc.api_call("api.test"))

def get_channel_info(sc,channel):
    # get info about the channel
    print("Getting Channel Info")
    print(80 * "=")
    print (sc.api_call("channels.info", channel=channel))

def get_list_of_channels(sc):
    print("Getting List of Channels")
    print(80 * "=")
    # get list of channels
    channels = sc.api_call("channels.list")
    channels = json.dumps(channels)
    channels = json.loads(str(channels))
    return channels

def display_channels(channels):
    print("Display Channels")
    print(80 * "=")
    for i in channels['channels']:
        print("Channel:",i['name'])

def post_message(sc,text,channel,icon_url,username):
    print("Posting Message to Slack")
    print(80 * "=")
    # post a message into the #general channel
    print (sc.api_call("chat.postMessage",channel=channel,text=text,username=username,icon_url=icon_url,unfurl_links="true"))

def get_users(sc):
    print("Get Users")
    print(80 * "=")
    #call the users.list api call and get list of users
    users = (sc.api_call("users.list"))
    users = json.dumps(users)
    users = json.loads(str(users))
    return users

def display_users(sc,users):
    print("User List")
    print(80 * "=")
    # display active users
    for i in users['members']:
        # don't display slackbot
        if i['profile']['real_name'] != "slackbot":
            # don't display deleted users
            if not i['deleted']:
                # display real name
                print (i['profile']['real_name'])
def main():
    # define variables
    token = "your token"
    channel = "a channel id"
    username = "Username to use display for message function"
    icon_url = "icon url for message function"
    # connect to Slack
    sc = SlackClient(token)
    # test slack
    test_slack(sc)
    # get channel info
    get_channel_info(sc,channel)
    # get list of channels
    channels = get_list_of_channels(sc)
    # display channels
    display_channels(channels)
    # post message
    post_message(sc,"Visit http://slack.com",channel,icon_url,username)
    # get users
    users = get_users(sc)
    # display users
    display_users(sc,users)

main()

Updated List of College Classes I have Taught

Here’s an updated list of the courses I have taught at Clark College in Vancouver, WA over the past 4 years:

  • Web and Interface Design 1 (CTEC 270)
  • Web and Interface Design 2 (CTEC 271)
  • Programming Essentials (CTEC 112)
  • HTML Fundamentals (CTEC 122)
  • JavaScript (CTEC 126)
  • Intro to Programming and Problem Solving with Python (CTEC 121)
  • PHP with SQL 1 (CTEC 127)
  • PHP with SQL 2 (CTEC 227)
  • Business Web Practices (CTEC 165)
  • API & Advanced Integration (CTEC 228)
  • WordPress Development (CTEC 260)
  • Applied Web Development (CTEC 265)
  • AI, Robotics and 3D Printing 101
  • Web Skills Portfolio (CTEC 293)

There are some new courses on the horizon as well that I may be teaching. Stay tuned.

Slack: What Great Execution Looks Like

For those of you who know me, I’m a huge fan and user of Slack; both the company and the product. Here are some things that Slack has done and continues to do right:

  1. Social Media: They know how to use social media to connect with their users. They respond to every tweet and do their best to help you. If they can’t help you they connect you with somebody within Slack that can help.
  2. Integrations: Out of the box they offer an extensive list of products and services that they integrate with. This is a HUGE one as I use many of these integrations when I setup my new Slack groups. Oh, and did I mention that they work and they work as you would expect to work.
  3. API: The Slack API is very well thought out and documented. I have developed several bots, some simple and some quite complex using their API. There isn’t much you can’t do.
  4. Just enough features: Slack doesn’t try to be all things to all users. I’m hoping that Slack continues to carefully craft the user experience in the same way that they already have.
  5. Mobile, Web and Desktop: Right out of the gate they offered first class desktop, the web and mobile clients. All that worked very well.
  6. App Store/App Directory: Need I say more.

It’s these six things that make Slack a company and product to admire. There are so many companies trying to take on Slack and there are some other products that do what Slack does. Bottom line is that they are not Slack the company and Slack the product.

I expect in the forthcoming weeks, to see other companies announcing products to challenge Slack’s dominance and I’m looking forward to seeing how those new products align with the six things I outlined above, if at all.

My Fall 2015 Schedule at Clark College

Here is my class schedule for the fall 2015 quarter:

Monday – API & Advanced Integration (CTEC 228) 6:30-8:50PM, room SHL 124

Tuesday/Thursday – Intro to Programming and Problem Solving (CTEC 121) 10:30AM-12:50PM, room SHL 125
Tuesday/Thursday – Business Web Practices (CTEC 165) 4:00-5:50pm, room SHL 125 (Tueday) / Foster Auditorium (Thursday)

Check the Clark College website to see when you can register.