问题
I built a watson conversation service and I connected it to Slack using the provided wizard in Bluemix. This is not connected to an application yet (such as Java, etc), it was built using the bluemix dialog tool. My question is: How can I show images or pdf files as a response?
回答1:
Within the dialog tool itself you will not be able to view any other type of media other than text. The output in the test panel will simply show the output from the node.
When deployed to an application such as a web application the output node would look something like this containing HTML markup:
{
"output": {
"text": {
"values": [
"Hello world <a href="www.test.com">Click here</a>"
],
"selection_policy": "sequential"
}
}
}
In this case to display an image you would simply replace the link tag with that of an HTML image etc.
An example starter kit can be found here https://github.com/watson-developer-cloud/conversation-simple
You will need an orchestration layer to handle the encoding to the desired platform format e.g FB messenger requires an object to be passed such as
"buttons":[
{
"type":"web_url",
"url":"https://petersfancyapparel.com/criteria_selector",
"title":"Select Criteria",
"webview_height_ratio": "full",
"messenger_extensions": true,
"fallback_url": "https://petersfancyapparel.com/fallback"
}
]
An example orchestration layer such as Botmaster can be used alongside its extension fulfill that will allow you to creatr these objects and in the Watson dialog simply just add custom XML tags. E.g www.google.com this will then be passed to the orchestration layer which will send the relevant object. A code example using this method can be found here with some other Facebook actions.
回答2:
Conversation is text only. So you would return the markup, or a context variable. The UI / application layer would then handle the loading and rendering of the PDF.
回答3:
You could provide the response as a URL link to the pdf or image. For example you could save your image in a storage place such as google drive and for the response you could provide the link to the image/pdf.
来源:https://stackoverflow.com/questions/48069917/show-images-or-pdfs-files-in-a-response-in-ibm-watson-conversation-service