def api_handler(credentials_dict, aiml_file, update): user_key = credentials_dict['user_key'] app_id = credentials_dict['app_id'] botname = credentials_dict['botname'] host = 'aiaas.pandorabots.com' if not update: result = api.create_bot(user_key, app_id, host, botname) if result != botname + ' has been created!': return result #make sure to change demobots to aiaas when testing complete url = 'https://' + host + '/bot/' + app_id + '/' + botname + '/file/vguide.aiml' query = {"user_key": user_key} response = requests.put(url, params=query, data=aiml_file) if not response.ok: return "There was a problem with uploading your aiml file" properties = '[["name","' + credentials_dict[ 'name'] + '"],["default-get", "unknown"], ["default-property", "unknown"], ["default-map", "unknown"], ["learn-filename", "pops_learn.aiml"]]' url = 'https://' + host + '/bot/' + app_id + '/' + botname + '/properties' response = requests.put(url, params=query, data=properties) if not response.ok: return "There was a problem with uploading your aiml file" result = api.compile_bot(user_key, app_id, host, botname) if result != botname + ' has been successfully compiled!': return result if update: result = credentials_dict['name'] + ' was updated successfully!' else: result = credentials_dict[ 'name'] + ' was created and uploaded to ' + host + ' as ' + botname return result
def __init__(self): HOST = 'aiaas.pandorabots.com' APP_ID = settings.PANDORA_BOT_APP_ID USER_KEY = settings.PANDORA_BOT_USER_KEY BOT_NAME = settings.PANDORA_BOT_NAME self.bot = API.create_bot(USER_KEY, APP_ID, HOST, BOT_NAME)
def api_handler(credentials_dict, aiml_file, update): user_key = credentials_dict['user_key'] app_id = credentials_dict['app_id'] botname = credentials_dict['botname'] host = 'aiaas.pandorabots.com' if not update: result = api.create_bot(user_key,app_id,host,botname) if result != botname + ' has been created!': return result #make sure to change demobots to aiaas when testing complete url = 'https://' + host + '/bot/' + app_id + '/' + botname + '/file/vguide.aiml' query = {"user_key": user_key} response = requests.put(url, params=query, data=aiml_file) if not response.ok: return "There was a problem with uploading your aiml file" properties = '[["name","' + credentials_dict['name'] + '"],["default-get", "unknown"], ["default-property", "unknown"], ["default-map", "unknown"], ["learn-filename", "pops_learn.aiml"]]' url = 'https://' + host + '/bot/' + app_id + '/' + botname + '/properties' response = requests.put(url, params=query, data=properties) if not response.ok: return "There was a problem with uploading your aiml file" result = api.compile_bot(user_key,app_id,host,botname) if result != botname + ' has been successfully compiled!': return result if update: result = credentials_dict['name'] + ' was updated successfully!' else: result = credentials_dict['name'] + ' was created and uploaded to ' + host + ' as ' + botname return result
def createBot(BOT): result = API.create_bot(USER_KEY, APP_ID, HOST, BOT) print result