gunthercox/chatterbot-corpus

How to implement the API's response in yaml?

rajendraarora16 opened this issue ยท 7 comments

I have created the same chatbot using SUSI, however the best part is that I can implement my built-in api's like this one using indentation with given queries entered by users:

https://github.com/kumar-mind/kumar-bot/blob/master/conf/kumar/en_train_finding_skill.txt

Can we do the same thing in this project? I would be more happy to know about this feature implementation. I have found that yaml is the best approach for providing skill sets instead of creating .txt

For your reference, I am adding this example:
https://kumar.rajendraarora.com

It can be quite simple to return API responses in yaml format. Here is a quick (non framework specific) example:

def get(request):
    import yaml

    data = {
        'some_key': 'some data value'
    }

    return Response(
        data=yaml.dump({'hello': 0}, default_flow_style=False),
        headers={
            'Content-Type': 'application/x-yaml'
        }
    )

I hope this helps.

Can I give the response to user while fetching the APIs response in your dialogue file?

Also have one query like how will I find the indentation if suppose users want to find a train from Kota to bdts. How will I get the indentation "Kota" and "bdts" here??

I will be more happy if you could help me regarding this query and will be implementing the same into my next project.

Replying to a user's input can be achieved using ChatterBot, there is several examples in the documentation: https://chatterbot.readthedocs.io/en/stable/examples.html


Could you clarify what you mean by "indentation"?

Indentation means let's say users writes his query:

"Show me the Mexican restaurants in los Angeles."

Indentation will lead to "mexican" and "los Angeles" here. So can we achieve this?

That can definitely be done. ChatterBot doesn't have this feature built in, but the nltk python library can be used to achieve entity extraction. They have a great article with examples that can be found here: https://www.nltk.org/book/ch07.html

Sorry not "indentation", it's entity. My bad :)

Thank you!

No problem, I hope that article helps ๐Ÿ˜„