keiffster / program-y

Python 3.x based AIML 2.0 Chatbot interpreter, framework, related programs and knowledge files
https://keiffster.github.io/program-y/
Other
348 stars 138 forks source link

Usage difference between Extensions, Services and OOB #243

Closed acriptis closed 4 years ago

acriptis commented 4 years ago

Could anybody clarify usage of Extensions, Services and OOB? I need some extension or service which gets the current time and writes user variable depending on time (I need to write a variable daytime with value morning, day, evening or night depending on time of conversation). Im guessing what is the best approach to implement this:

  1. Service seems to be more configurable at initialization and allows to implement logic inside: ask_question(self, bot, clientid: str, question: str) method

  2. Extension needs a method: execute(self, bot, clientid, data)

  3. And OOB which looks like the least probable candidate with relevant method: execute_oob_command(self, bot, clientid)

What is the best usage for executing arbitrary python code which should modify the state of user's context?

What do I need to get access to user-variables? It seems variables are accessible by user_context, but how can I retrieve it? is it possible to retrieve it with clientid?

keiffster commented 4 years ago

A service is an AIML compliant implementation of the sraix tag. In the spec it is used to call Restful services, but I found that implementation lacking in terms of configuration. sraix is still the way to call it but you configure it in the config file rather than part of the XML. It returns a text string that you then parse as per normal AIML

An extension is something unqiue to Program-Y and allows you to call Python libraries natively. You pass a textual sentence to execute and get a text sentence back that you can parse with srai tag

OOB is an AIML 2 spec which allows back channel communication with your client. In the text returned to your client anything inside the oob tag pair is not displayed and instead passed to an OOB processor in your client. Useful for configuring components like cameras, wifi etc on a phone

acriptis commented 4 years ago

Thanks @keiffster