import json
import logging
import urllib.request
import os

logger = logging.getLogger()
logger.setLevel(logging.DEBUG)

MSW_API = os.environ.get('SF_MSW_API', None)

if not MSW_API:
  logger.error("Couldn't read SF_MSW_API env variable")


def close(fulfillment_state, message):
    return {
        'dialogAction': {
            'type': 'Close',
            'fulfillmentState': fulfillment_state,
            'message': message
        }
    }


def lambda_handler(event, context):
    logger.debug('event.bot.name={}'.format(event['bot']['name']))
    logger.debug('dispatch userId={}, intentName={}'.format(
        event['userId'], event['currentIntent']['name']))
    j = json.loads(urllib.request.urlopen(
        "http://magicseaweed.com/api/{}/forecast/?spot_id=912".format(
            MSW_API)).read())
    logger.debug('json.response={}'.format(j))

    return close('Fulfilled',
                 {'contentType': 'PlainText',
                  'content': 'This worked! {}'.format(j[0]['solidRating'])})

@@ -1,12 +1,70 @@
+%22%22%22lambda_function.py main entry point for aws lambda%22%22%22%0A%0A
 import json%0A
@@ -115,185 +115,52 @@
 os%0A%0A
-logger = logging.getLogger()%0Alogger.setLevel(logging.DEBUG)%0A%0AMSW_API = os.environ.get('SF_MSW_API', None)%0A%0Aif not MSW_API:%0A  logger.error(%22Couldn't read SF_MSW_API env variable%22
+%0AMSW_API = os.environ.get('SF_MSW_API', None
 )%0A%0A%0A
@@ -198,16 +198,49 @@
 ssage):%0A
+    %22%22%22Close dialog generator%22%22%22%0A
     retu
@@ -429,17 +429,167 @@
 nt, 
-context):
+_):%0A    %22%22%22Lambda Handler%0A       Entry point for every lambda function call%0A    %22%22%22%0A    logger = logging.getLogger(__name__)%0A    logger.setLevel(logging.DEBUG)
 %0A   
@@ -618,27 +618,21 @@
 ot.name=
-%7B%7D'.format(
+%25s', 
 event%5B'b
@@ -640,25 +640,24 @@
 t'%5D%5B'name'%5D)
-)
 %0A    logger.
@@ -679,18 +679,18 @@
  userId=
-%7B%7D
+%25s
 , intent
@@ -698,83 +698,185 @@
 ame=
-%7B%7D'.format(%0A        event%5B'userId'%5D, event%5B'currentIntent'%5D%5B'name'%5D)
+%25s', event%5B'userId'%5D,%0A                 event%5B'currentIntent'%5D%5B'name'%5D)%0A%0A    if not MSW_API:%0A        logger.error(%22Couldn't read SF_MSW_API env variable%22
 )%0A    
+ 
-j
+   return%0A%0A    res
  = j
@@ -1046,21 +1046,16 @@
 nse=
-%7B%7D'.format(j)
+%25s', res
 )%0A%0A 
@@ -1183,17 +1183,19 @@
 .format(
-j
+res
 %5B0%5D%5B'sol

Fix pylint warnings