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

Closed
opened 2025-10-14 17:30:32 -06:00 by navan · 0 comments
Owner

Originally created by @ohoachuck on 10/17/2020

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.

*Originally created by @ohoachuck on 10/17/2020* 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](https://openchatbot.io/swagger/swagger.html)) 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: ```json 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](https://stackoverflow.com/questions/7871903/returning-json-data-out-of-the-callback-function). 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 ? 2. 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.
navan closed this issue 2025-10-14 17:30:33 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github/program-y#51
No description provided.