You can test this by opening Postman, and calling the endpoint localhost:5000/bot (with POST method and no body). # Return message to display (replies) and update memory # Increment the # of times this has been called # In case the API does not work after 8 seconds, we return "no data" Hands-On knowledge of scikit library and NLTK is assumed. # Get the request body, and determine the dog and memoryīot_data = json.loads(request.get_data())Īnimal = bot_data In this article we will build a simple retrieval based chatbot based on NLTK library in python. The requirements for Python on SAP BTP changes from time to time – e.g., quota, runtime – so you are encouraged to check the documentation for how to deploy Python scripts: Developing Python in the Cloud Foundry Environment IMPORTANT: The focus of this tutorial is the response an application (API) must return in order to work with SAP Conversational AI. Special thanks to Yohei Fukuhara for his blog Create simple Flask REST API using Cloud Foundry. The point of the tutorial is to show you how the webhook reads the request data from the chatbot, and to show you the format of the data that must be returned to the chatbot.Īs an added bonus, we will show how to deploy a Python script to SAP BTP. The webhook will also update the memory variable that keeps track of how many times the user requested a fun fact. You will create a very simple chatbot that asks the user to pick an animal, and then have the chatbot call a webhook, which will then call an API to retrieve a “fun fact” about the animal via the cat-facts API.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |