I need help with this.. Basically i need to use this command. This is the example given using CURL. All i need to do is simply paste this in cmd and it does its job.
curl \
-H "Content-Type: application/json" -X POST \
-u "{username}":"{password}" \
-d "{\"dialog_node\":\"greeting\",\"conditions\":\"#hello\",\"output\":{\"text\":\"Hi! How can I help you?\"},\"title\":\"greeting\"}" "https://gateway-s.watsonplatform.net/conversation/api/v1/workspaces/bec28d8f-18c1-4e97-8d08-9c842c658b51/dialog_nodes?version=2017-05-26"
The URL documentation can be found here: https://www.ibm.com/watson/developercloud/conversation/api/v1/?curl#create_dialognode
The problem now is that i want to run this in a python script instead of in CMD.. i have searched google and stackOverflow for a few hours now.. but i cant seem to find the right answer..
So far i seen ppl using 1.requests 2.urllib 3.urllib2 4.pycurl 5.subprocess
I want to do it the right way. What is the best way to run the above command in a python script and how do i do it?
Also i am using python 3
Likes Simon O'Doherty said, you can use the Python SDK for using Conversation service. It is really the best practice to use the service, using the SDK or
http
requests.Author from the phrases here.
But, your question looks like you really want to use the
cURL
command inside your Python code, so, here is one example. In this case, you can use subprocess.Call the Converstation:
Important: For send the message and getting the output, you need to use the function
subprocess.check_output();
like this example. And send the message for the right router, your cURL command needs to looks like this example from @German Atannasio and @Pridkkett.Note: This answer is just to tell what is the better way to you follow, and if you really wants to use, one "Stone path" for you follow.