How To Print The Answer Returned By Ibm Watson Assistant?
Solution 1:
Your code does not show how you set up and configure the Python SDK with the credentials for IBM Watson Assistant. The message function with its input and output is documented here in the API reference. If you use json.dumps
on the returned message object, you can see the result (response) structure.
The result structure depends on the API version which you configure during the SDK initialization (not shown in your code). It can have only text as an array or, with latest API versions, can contain images, options to choose from and more. All is returned in a JSON structure under the output element (which is shown in your code).
Solution 2:
Post your returned answer to another page
@app.route(/returned_answer/<mensaje>)defconversacion(mensaje):
response = assistant.message(workspace_id='1bef94fd-be51-4996-956c-73f9d0f08c41', input={'text': mensaje})
mens = (json.dumps(response, indent=2))
msj = json.loads(mens)
# print(json.dumps(response, indent=2))print(msj["output"]["text"][0]) # mensaje de respuesta
rewa = (msj["output"]["text"][0])
return rewa
giver your input messages a message tag , , and in your index page write html code to embed the /returned_answer messages in index page
<button onclick="window.location.href = ('/returned_answer/'+document.getElementById('message_id').value)
Post a Comment for "How To Print The Answer Returned By Ibm Watson Assistant?"