#-------------------------------------------------------------------------------- # Simple Python Script with three entry points used by server to pass control to # the plugin. Return null to make no changes to flow. #-------------------------------------------------------------------------------- # Def Question # Objects available: # # key This is the users ApiKey (string) # text This is the question asked (string) # plugin This is the Plugin Object (object) # ---->Name Name of the PlugIn # ---->Key PlugIn Key # ---->ProjectName Project Name Used in Q & A # question The QuestionResponse Object (object) # ---->ApiKey ApiKey again # ---->Question Question Text # ---->Meta Array of Meta Data (from Q & A) # words Array of Word Objects (below example of word) # ---->Type # ---->Text # ---->OriginalWord # ---->Alternatives Array of Alternatives (strings) # ---->Definitions Array of Definitions # -------->definition Textual Definition # -------->partOfSpeech Text (simple Part Of Speech) # ---->POS Text (complex Part Of Speech) # ---->Category If NER recognised, Categories are # Person = 0, PersonType = 1, Location = 2, # Organization = 3, Event = 4, Product = 5, # Skill = 6, Address = 7, PhoneNumber = 8, # Email = 9, Url = 10, IP = 11, DateTime = 12, # Quantity = 13, None = 14 (Numbers are 13 with # SubCategory "Number") # ---->SubCategory String Sub Category if any # ners Named Entity Recognition results # ---->Text Entity Text - this may be multiple words # ---->Category Same as words Category # ---->SubCategoryText Further Category definition def Question(): # Do processing here and assign results to the data object. data = { "Type": 0, "Text": "Hello From Python", "Html": "
Hello From Python
", "Url": "http://example.com", "End": False, "EndReason": 0, "EndData": "" } y = json.dumps(data); return y #-------------------------------------------------------------------------------- # Def BotQuestion # Objects available: # key This is the users ApiKey (string) # text This is the question asked (string) # plugin This is the Plugin Object (object) # ---->Name Name of the PlugIn # ---->Key PlugIn Key # ---->ProjectName Project Name Used in Q & A # question The BotQuestion Object (object) # ---->Text Question Text # ---->BotQuestionType Options are: Unknown = 0, YesNo = 1, Sentence = 2, # Responses = 3, Postcode = 4, Raw = 5 # ---->PlugInQuestionKey Use this key to identify the Question asked def BotQuestion(): # Do processing here and assign results to the data object. data = { "Type": 0, "Text": plugin.Key, "Html": "Hello From Python
", "Url": "http://example.com", "End": False, "EndReason": 0, "EndData": "" } y = json.dumps(data); return y #-------------------------------------------------------------------------------- # Def BotResponse # Objects available: # key This is the users ApiKey (string) # text This is the question asked (string) # plugin This is the Plugin Object (object) # ---->Name Name of Plugin # ---->Key The PlugIn key # ---->ProjectName Project Name Used in Q & A # response The BotResponse Object (object) # ---->Text The Response Text # ---->Alternatives Alternative Responses # ---->NextQuestion Next Question Id (not much use here) # ---->PlugInResponseKey Key to identify response # question The BotQuestion Object (object) # ---->Text Question Text # ---->BotQuestionType Options are: Unknown = 0, YesNo = 1, Sentence = 2, # Responses = 3, Postcode = 4, Raw = 5 # ---->PlugInQuestionKey Use this key to identify the Question asked def BotResponse(): # Do processing here and assign results to the data object. data = { "Type": 0, "Text": plugin.Key, "Html": "Hello From Python
", "Url": "http://example.com", "End": False, "EndReason": 0, "EndData": "" } y = json.dumps(data); return y #--------------------------------------------------------------------------------