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 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
# Bot creation # result = API.create_bot(user_key, app_id, host, botname) # print(result) # Bot listing result = API.list_bots(user_key, app_id, host) print result # Files such as AIML uploading # for files in full_file_paths: # print files # result = API.upload_file(user_key, app_id, host, botname, files) # print result # List files result = API.list_files(user_key, app_id, host, botname) # Retrieve files # filename = 'udc.aiml' # result = API.get_file(user_key, app_id, host, botname, filename) # print result # Bot Compilation result = API.compile_bot(user_key, app_id, host, botname) # Send input to Bot result = API.talk(user_key, app_id, host, botname, input) bot_response = result['response'] session_id = result['sessionid'] print bot_response
def compileBot(): result = API.compile_bot(user_key, app_id, host, botname) print result
def compileBot(BOT): compiled = API.compile_bot(USER_KEY, APP_ID, HOST, BOT) print "Compiled: ", compiled