if __name__=="__main__" : event = { "field": "askBot", "path": "Query/askBot", "arguments": { "identity": "service", "botid": "uri:bot:demo:salesbot", #"question": "show average revenue of sales with country equals Australia per country" #"question": "show number of sales" "question": "tell me average revenue of sales by country" } } b = App.route(event) print pprint.pformat(b) exit() print getBotStatus(botid="uri:bot:demo:salesbot", identity="xxx") event = { "field": "createOrUpdateLexBot", "path": "Mutation/createOrUpdateLexBot", "arguments": { "identity": "service", "botid": "uri:bot:demo:salesbot" } } b = App.route(event)
"Sorry, this is not clear for and old bot", "Can you try to reformulate ?", "Hmm, i'm just a bot", "Well, this is clear, i'm not really awake right now" ]) if __name__=="__main__" : print App.route( { "field" : "askBot", "arguments": { "botid":"uri:bot:demo:FinancialCoach", "question" : "how many people are living in paris" } } ) r= askBot(identity="", botid="uri:bot:demo:FinancialCoach", question="how many people are living in paris") print pprint.pformat(r) exit() #print Bot.put_alias("FinancialCoach") print Bot.put_bot_version("FinancialCoach") exit() print getBotStatus(identity="", botid="uri:bot:demo:FinancialCoach")
"/arguments/identity": "identity" }) def invite(accountid, email, identity): accountid = accountid.split(":")[2] user = Item(parent=accountid, name=email, objecttype="user", creator=identity, createdat=ID.now(), ID="uri:user:%(accountid)s:%(email)s" % vars(), search=email) user.save() if __name__ == "__main__": response = App.route({ "field": "listBots", "path": "Account/listBots", "arguments": { "identity": "*****@*****.**", "options": { "limit": 1, "offset": 1 } }, "source": { "ID": "uri:account:20180911183119" } }) print pprint.pformat(response)
"/arguments/identity": "identity", "/arguments/options": "options" }) def list_accounts(identity, options): accounts = [] iterator = apply_options(Item.query("user", Item.name.__eq__(identity)), options) for user in iterator: try: print user.attribute_values account = Item.get("account", user.parent) accounts.append(account.attribute_values) except Exception, e: pass return accounts if __name__ == "__main__": response = App.route({ "field": "listMyAccounts", "path": "Query/listMyAccounts", "arguments": { "identity": "*****@*****.**", "options": { "limit": 200 } } }) #response = list_accounts("*****@*****.**",None) print pprint.pformat(response)
Bot.add_slot_type(slot["name"], slot["enumerationValues"]) logger().critical("Saving Intent `%s` to Lex", intent) Bot.add_intent(intent_config) logger().info("Putting Bot %s", bot.name) Bot.build(bot.name, intents=[i["name"] for i in intents]) logger().info("Putting Bot Alias %s %s", bot.name, "demo") Bot.put_alias(bot.name) Bot.put_bot_version(bot.name) return botgraph if __name__ == "__main__": #x = to_grammar("#nbof# people living in @city @city.val",to_lex) #print x #exit() graph = App.route({ "field": "createOrUpdateLexBot", "arguments": { "botid": "uri:bot:demo:FinancialCoach" }, "identity": { "claims": { "email": "*****@*****.**" } } }) #print pprint.pformat(expand_intent("howmany",graph))
"/arguments/identity": "identity" }) def deleteIntent(identity, intentid): try: intent = Item.get("intent", intentid) intent.delete() rules = Item.parent_index.query(intentid) for r in rules: r.delete() return True except Exception: return False return False if __name__ == "__main__": print pprint.pformat( getIntent(intentid="uri:intent:demo:mybot:q", identity="")) from grapher.json_utils import to_json print pprint.pformat( to_json( App.route({ "field": "getIntent", "arguments": { "intentid": "uri:intent:demo:mybot:q", "identity": "xxx" } })))