Show images or PDFs files in a response in IBM watson conversation service - watson-conversation

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?

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 Click here"
],
"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.

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.

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.

Related

IBM Business Automation Workflow. Validating File Size and Extension while Adding Files on the Document Widget

Using IBM Business Automation Workflow 22 (Case Builder).
I want to add custom code too the add custom code to the "Add Document" button, so it can limit the size to 10MB and only DOCX or PDF.
Add Document GUI Widget
I need a mix between this IBM Tutorial:
https://www.ibm.com/support/pages/node/1281268
And this post when he tried to limit the upload size and type. (Content Navigator)
How to customize addContentItemDialog to restrict files over 10mb upload in IBM Content Navigator
But sadly the code is not working for me.
Help is apreciated with a sample.
I'm trying to put javascript with Dojo similar to this tutorial.
https://www.ibm.com/support/pages/node/1281268

Server side analytics of outbound links

The problem: We count clicks on external links with Google Analytics (GA). But because external links are opened in a new tab, we are not 100% sure that browser's tab was really opened and that a third-party site was really loaded even in opened tab.
The solution: Do not open direct links to 3-d party web-sites directly in the new tab, but only through some interceptor that will collect statistic on a server side before redirection to the target url. Thus, we will be able to to catch the moment of loading a third page in a new browser window.
Therefore, we need a service that will take full URL as a parameter, collect statistics, and then redirects to the passed URL, like this:
https://magicclickcounter.com/abc?url_to_redirect=http://urltoexternal.link/123 which will collect statistics and redirects to http://urltoexternal.link/123
Any ideas how to achieve this with GoogleAnalytics?
UPD: Firebase DynamicLinks is not appropriate for us because we have to use shortened urls(deep API integration) or there will be no statistic for full urls created manually or via SDK-builder.
UPD: The main problem in our case is that we use a HTML canvas in our page and "clicking area" is inside canvas. Therefore we use next code to open a new window:
this.pixiLayout.App.renderer.view.addEventListener('click', () => {
if (this.pixiLayout.externalUrl) {
window.open(this.pixiLayout.externalUrl, '_blank');
}
});

Anonymous script firing with each pageload gtm.js and seems like a hack

I seem to be experiencing an issue where a random third party script keeps executing with each pageload on my site. I have a lot of pageview and event tracking in place and all of that is managed via GTM.
Script --
setTimeout(function(){var a=document.createElement("script"),b=document.getElementsByTagName("script")[0];a.src=document.location.protocol+"//dnn506yrbagrg.cloudfront.net/pages/scripts/0017/9988.js?"+Math.floor((new Date).getTime()/36E5);a.async=!0;a.type="text/javascript";b.parentNode.insertBefore(a,b)},1);
The above third party script is injecting an empty document inside the header tag. The body and the header of the doc is completely empty.The query parameter in the injected doc keeps changing.
Has anyone else has experienced this issue in the past? Any ideas what this could be?
I also have a lot of customjs variables in GTM - I wanted to see if I could search for this piece of code in one of the custom js variables - anyone knows if there is an easy way to search through all variables without going into each one at a time?
Any help is greatly appreciated.
You can Export your container as JSON file:
In Google Tag Manager, navigate to the desired container.
In the top navigation, go to Admin and then Export Container.
Select the desired container version from the selector.
Preview and confirm your export file and click Download.
(link to source: https://support.google.com/tagmanager/answer/6106997?hl=en)
Once you donwlaod the JSON file open it in any text editor and search for the code, or simply search just for the specific domain in the tag e.g. "dnn506yrbagrg.cloudfront.net". The name name of the Tag or Variable will appear in the corresponding object.
For example you should see something like this (if the code is in html tag):
...
"tag": [
{
"accountId": "001",
"containerId": "123",
"tagId": "3",
"name": "THIS IS THE NAME OF YOUR TAG",
"type": "html",
"parameter": [
{
"type": "TEMPLATE",
"key": "html",
"value": "setTimeout(function(){var a=document.createElement("script"),b=document.getElementsByTagName("script")[0];a.src=document.location.protocol+"//dnn506yrbagrg.cloudfront.net/pages/scripts/0017/9988.js?"+Math.floor((new Date).getTime()/36E5);a.async=!0;a.type="text/javascript";b.parentNode.insertBefore(a,b)},1);"
},
...
According to this documentation this seems to be the tracking code for Crazy Egg (heat maps and scroll maps) - the cloudfront URL matches. The parameter keeps changing because it's a random number generated by javascript to prevent caching.
This is obviously not part of GTM. Either you have configured this yourself in GTM or somewhere in your website, or you include a marketing tag (via custom HTML) that load Crazy Egg (which without a contract and a data processing agreement would be unethical and in many jurisdictions illegal).

Getting URL of published element in SDL Tridion

Is there any way of finding the absolute URL for a published object in the SDL Tridion Interface?
For example when I published a page, how can I find the url where to access the page?
Though not finished, and not really very documented, the Tridion 2011 PowerTools includes 2 buttons to "Open in Staging" and "Open in Live".
If you're looking for the code in your c# tbb library you can use the PublishLocationUrl property for pages and structure groups:
StructureGroup.PublishLocationUrl or
Page.PublishLocationUrl
This will return the URL if the item is published or not, as Page and StructureGroup extend the ReposityObject class, I typically perform a check to see if the ReposityObject is published to the target that the Page is being published to for example:
if (PublishEngine.IsPublished(myReposityObject, myEngine.PublishingContext.PublicationTarget))
{
// page or sg is published!
}
Note: Where the myEngine is an instance of the Engine object.
If you're doing this in the core service, that's a little different, what you need to do is create a PublishLocationInfo object which is casted from your Page or StructureGroup object property LocationInfo, as shown below:
PublishLocationInfo pubInfo = (PublishLocationInfo)page.LocationInfo;
return pubInfo.PublishLocationUrl;
It is not very straightforward, mostly because Tridion allows you to publish a single page to multiple targets (= web sites). The page could in fact have a number of URLs.
However, the best option is to open the page and click on the Info tab. There you will find the File Path, which might look like this: \about\press\2011. Replace the backslashes with slashes, and add the page's filename and file extension (can be found on the General tab). Put the whole thing behind the root URL of your web site (e.g. http://www.mysite.com').
Tridion exposes the path of the URL in PublishLocationUrl property. You can access this either through the TOM.NET API or by viewing the raw XML of the item by entering the TCMURI in the address bar of Internet Explorer (e.g. tcm:4-264-64).
But in either case those will just return the path part of the URL. You'll have to prefix it with the correct base URL as Quirijn already mentioned earlier.
In the past, I have resorted to extending the protocol schemas for publication target destinations. Having added a baseURL property there, I could access this from events system code (the idea was to mail a link to a workflow approver).
These days, you could use application data to do the same thing.

Send a file from a web page in Outlook

I have a web page that displays a list of documents stored on the web site. I need to add a link next to each document that can e-mail it. By that I mean attach the entire document to the e-mail.
When clicking the e-mail link, a 'New Message' window needs to display with:
Subject line filled in with the title of the document (displayed on the web page)
Contents of the document downloaded from the web site and added as an attachment
The mail client is Outlook. The server is SharePoint (ASP.NET) which contains web services that are able to download files. JavaScript and any JS library is available for use. I'm not able to deploy additional software to the client.
What are my options and are there any references that achieve this type of functionality?
An alternative might be to put a link in the body of the message to a place where the file can be downloaded. You could even make it a web page that deletes the file after a set time or number of downloads. To be safe you would need to use "mailto:someone#somewhere.com&subject=somesubject&body="+System.Web.HttpUtility.UrlEncode(bodyStringToEncode) to generate an html safe llink
Even with the above answer about launching an email using office automation, you'd still need to first have the file sent to the client, saved in a name and location known to the server, in order to attach the file.
I can't think of a way to attach the document but you can have a link to fill in the subject and body of an email in which you could add a link to the online document.
<a href="mailto:test#test.com?subject=
[your_subject]&body=[url_encoded_content_string]">New Message</a>
You can use this function to urlencode your body text http://phpjs.org/functions/urlencode
Hope that helps,
Josh
Using the HREF mailto, you can make outlook open with the subject at least. I don't know any way to set the body nor an attachment.
From javascript there's no way to automate Outlook using OLE.
example
Taken from:
http://www.angelfire.com/dc/html-webmaster/mailto.htm

Resources