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

Change restful flask response for OpenChatBot API v2.0 when callback parameter is provided #275

Closed ohoachuck closed 3 years ago

ohoachuck commented 3 years ago

Hello Keith, I hope you are doing well, as I see you are less active than you use to be ?

After a long period, I'm getting back to OpenChatBot work and while getting down to your code, I could see the enormous work you have done to be compliant with the format. This is really great! My plan is to provide with an out of the box running program-y metabot + rich OpenChatBot web client that will be able to chat to any other compatible OpenChatBot frameworks.

Doing so, I was working on my initial web client (available at the swagger page here) that should be able to directly point to program-y restful api V2.2 url.

Then I face 2 issues :

  1. when using Ajax request, it's not possible to handle the asynchronous results unless answer is wrapped within a fonction, like:
    parseocbAnswer({"response": {"query": "hello", "userId": "2371aeb8-58d2-41bc-8382-1a205b0cbd2d", "timestamp": 1602948834.632006, "text": "Sorry, I don't have an answer for that!!!"}, "status": {"code": 200, "message": "success"}, "meta": {"botName": "OpenChatBot MetaBoto", "botIcon": "https://metaboto.com/resources/metaboto_224x224.png", "version": "3.9", "copyright": "Copyright 2020 metaboto.com", "authors": ["Olivier HO-A-CHUCK"]}})

    Obviously my fonction name here is parseocbAnswer See this StackOverflow link for the kind of issue.

This Pull request is fixing this #1issue. But I know my python code is usually bad and there are may be better or cleaner approaches to handle this. You might have an idea ?

  1. Program-y bot response['text'] currently render to HTML a formatted mix of Media content, buttons, links and so on. I have no fix yet for this as even if my issue#1 above is quite simple to come with a solution, fixing this issue#2 might be really messy if I do it. You will probably not disagree :).

I believe the proper way to handle issue #2 would be to let response['text'] as is (while still providing back media, suggestions, meta, etc.) and use response['channel']['markup'] object to provide with your rendered AIML into HTML for the type "html", and ever better add a new type "aiml" (for markup).

Any feedbacks would be appreciated. Stay safe.

Olivier.

ohoachuck commented 3 years ago

Euh, thinking of it, it might not be program-y role to handle such custom behaviour in the core API. As program-y bot framework local instance (ie: localhost:8989) would be accessed by a proper external API endpoints that can handle https on domain and path could manage this embedding content within a fonction name. So in short forget my Pull request (I don't really know how to cancel it ;( ).

Olivier

keiffster commented 3 years ago

Hi there

I’m still working on program-y just not at the pace I used to, with the current lockdown I e been working from home since March and unlikely to return until sometime in 2021. I therefore took the decision to focus on other activities to keep me sane, must if which have involved building mountain bikes ( my second passion after python related chatbots !!! )

You can change the api in the config it’s just not well documented but as you realised it’s better to expose it via a proper api

There has been an increase in activity in the past few weeks so will be addressing a couple of defects and some documentation issues. I also have a long overdue rewrite of the service interface to push out which adds a lot of value

K

Sent from my iPhone

On 18 Oct 2020, at 15:59, ohoachuck notifications@github.com wrote:

 Euh, thinking of it, it might not be program-y role to handle such custom behaviour in the core API. As program-y bot framework local instance (ie: localhost:8989) would be accessed by a proper external API endpoints that can handle https on domain and path could manage this embedding content within a fonction name. So in short forget my Pull request (I don't really know how to cancel it ;( ).

Olivier

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

ohoachuck commented 3 years ago

Hey!

Good to hear you are ok. To be honest I was a bit worried thinking you might have been touch by covid or may be some relative or something bad that kept you out of program-y. It's a good move to focus on other activity to replace the missed social activity we have when working out of home. It could be easy to get crazy while working from home when you realise its already few days you almost did not went out and was stuck in front of your screen :). Biking is cool.

I recently went back to Program-y and Open ChatBot. I will write here https://metaboto.com/ some kind of quick howto get up and running a meta-bot based on program-y. With a bot template and rich chatbox client. It might not be on your priority, but the only thing really missing is to have API v2 responding with the full Open Chatbot format (with media, suggestions, etc.) so that rich client could also show botIcons, carousels, etc. As I was explained in one ticket, I think your rendered content from medias to AIML could be given back in Channel>markup (with html ou aiml type) rather than in text object. I don't know how difficult it could be to change this depending on the way you have implemented it.

Anyway, good to see that things are doing ok with you. Live is short and it's always a good option to take time to enjoy it - outside :)!

O.

On 19 Oct 2020, at 08:56:26, Keith Sterling notifications@github.com wrote:

Hi there

I’m still working on program-y just not at the pace I used to, with the current lockdown I e been working from home since March and unlikely to return until sometime in 2021. I therefore took the decision to focus on other activities to keep me sane, must if which have involved building mountain bikes ( my second passion after python related chatbots !!! )

You can change the api in the config it’s just not well documented but as you realised it’s better to expose it via a proper api

There has been an increase in activity in the past few weeks so will be addressing a couple of defects and some documentation issues. I also have a long overdue rewrite of the service interface to push out which adds a lot of value

K

Sent from my iPhone

On 18 Oct 2020, at 15:59, ohoachuck notifications@github.com wrote:

 Euh, thinking of it, it might not be program-y role to handle such custom behaviour in the core API. As program-y bot framework local instance (ie: localhost:8989) would be accessed by a proper external API endpoints that can handle https on domain and path could manage this embedding content within a fonction name. So in short forget my Pull request (I don't really know how to cancel it ;( ).

Olivier

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/keiffster/program-y/pull/275#issuecomment-711701360, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAL454OOD5P55PW52NUBEJ3SLPPJVANCNFSM4SUOIJVQ.

ohoachuck commented 3 years ago

Correct back to as it were before. As mentioned handling callback is not program-y job. O.