Google Actions - Open Link from carousel - carousel

I'm using google actions node.js SDK for my Google Action.
At some point, I'm showing users a carousel with a list of items:
var responseText = utils.getResponseText(Response.BUY_PRODUCTS);
var items = self._getProductSuggestItems(); //each item has am item key
self.assistant.askWithCarousel(responseText, self.assistant.getIncomingCarousel().addItems(items));
I get a response, and I managed to get the item code with
var itemKey = assistant.getContextArgument('actions_intent_option', 'OPTION');
Now I want to open a browser and redirect the user to the matching product page.
How do I achieve this?

Currently, AoG doesn't support external link for Carousel or List,
you can only keep a key for each item.
Though there is one way to handle that:
Add an output context (say, caro_link) to the intent generating
carousel.
Make a fallback intent with event actions_intent_OPTION and input context caro_link
Now, using fallback intent, check key passed from the carousel and return the link of your product using card or suggestionLink or whatever.

Google has recently introduced Browse carousel card for this feature.
Link
The below will the message object format for browse carousel card.
"fulfillment": {
"speech": " Here is what we got for you.",
"messages": [
{
"type": "simple_response",
"platform": "google",
"textToSpeech": " Here is what we got for you."
},
{
"items": [
{
"description": "at price of Rs. 57,999",
"title": "Apple MacBook Air Core i5 5th Gen - (8 GB/128 GB SSD/Mac OS Sierra) MQD32HN/A A1466",
"footer": "Apple MacBook Air Core i5 5th Gen - (8 GB/128 GB SSD/Mac OS Sierra) MQD32HN/A A1466",
"image": {
"url": "https://rukminim1.flixcart.com/image/200/200/j4irlow0/computer/j/8/c/apple-na-notebook-original-imaevdrcvuksg2zv.jpeg?q=90",
"accessibilityText": "Apple MacBook Air Core i5 5th Gen - (8 GB/128 GB SSD/Mac OS Sierra) MQD32HN/A A1466"
},
"openUrlAction": {
"url": "https://dl.flipkart.com/dl/apple-macbook-air-core-i5-5th-gen-8-gb-128-gb-ssd-mac-os-sierra-mqd32hn-a/p/itmevcpqqhf6azn3?pid=COMEVCPQBXBDFJ8C&affid=HotDeals20&affExtParam2=pricee-desktop-search-21"
}
},
{
"description": "at price of Rs. 89,990",
"title": "Apple Macbook PRO MPXQ2/R2 Core i5 (6th Gen)/8 GB/128 GB/33.78 cm (13.3)/Mac OS)",
"footer": "Apple Macbook PRO MPXQ2/R2 Core i5 (6th Gen)/8 GB/128 GB/33.78 cm (13.3)/Mac OS)",
"image": {
"url": "https://assetscdn.paytm.com/images/catalog/product/L/LA/LAPAPPLE-MACBOOROSE73954D5B64792/1.jpg",
"accessibilityText": "Apple Macbook PRO MPXQ2/R2 Core i5 (6th Gen)/8 GB/128 GB/33.78 cm (13.3)/Mac OS)"
},
"openUrlAction": {
"url": "https://paytmmall.com/apple-macbook-pro-mpxq2-r2-core-i5-6th-gen-8-gb-128-gb-33-78-cm-13-3-mac-os-CMPLXLAPAPPLE-MACBOODUMM202563C836CCA-pdp?product_id=145129487&discoverability=online&src=grid&utm_source=NDTV&utm_medium=affiliate&utm_campaign=NDTV-recharge&utm_term=Gadget360"
}
},
{
"description": "at price of Rs. 105,185",
"title": "Apple MPXT2HN/A Core i5 (6th Gen)/8 GB/256 GB/33.78 cm (13.3)/Mac OS)",
"footer": "Apple MPXT2HN/A Core i5 (6th Gen)/8 GB/256 GB/33.78 cm (13.3)/Mac OS)",
"image": {
"url": "https://assetscdn.paytm.com/images/catalog/product/L/LA/LAPAPPLE-MPXT2HNAVK49295F2A396E0/1.jpg",
"accessibilityText": "Apple MPXT2HN/A Core i5 (6th Gen)/8 GB/256 GB/33.78 cm (13.3)/Mac OS)"
},
"openUrlAction": {
"url": "https://paytmmall.com/apple-mpxt2hn-a-core-i5-6th-gen-8-gb-256-gb-33-78-cm-13-3-mac-os-CMPLXLAPAPPLE-MPXT2HE-HU224691C3146BBC-pdp?product_id=145650181&discoverability=online&src=grid&utm_source=NDTV&utm_medium=affiliate&utm_campaign=NDTV-recharge&utm_term=Gadget360"
}
}
],
"platform": "google",
"type": "browse_carousel_card"
}
]
}
Note that simple_response message is mandatory for this feature and number of items should be more than 2 and less than 10.

If I understand what you were trying to do, I did something similar:
Have an intent to generate a carousel
Create an intent that has an Event: actions_intent_OPTION
This intent accesses the carousel through:
const param = app.getSelectedOption()
You create a card with a button that links to that product page.

You could offer the user your URL with: https://developers.google.com/actions/reference/nodejs/RichResponse you should use: addSuggestionLink
However, you want first to make sure what is the surface (you get this info in the JSON obj) and return it only for the cases where there is screen.

Related

How to Get Twitch Video Thumbnail URL?

Video-sharing websites such as Youtube has a endpoint for video thumbnails
Example: http://img.youtube.com/vi/youtube_id/default.jpg
where youtube_id = the id of the video
So I can just do
<img src="http://img.youtube.com/vi/youtube_id/default.jpg">
with no problem
Does twitch have something like this as well?
Update 2018
Twitch requires you to use its API so you can get access to video thumbnails. Apparently, this is because the URL of the thumbnails may change
Here is a simple guide how to get access to a twitch video thumbnail
You have to get access to Twitch dev API - to do this you need to register an account at https://glass.twitch.tv
After registering an account you must then create an App from your twitch dev dashboard
After creating the App, you will be given a Client ID to be used for that app - note that the app is the one which will be using the twitch API (for example, your website)
You can now pass the client_id as a query string parameter to https://api.twitch.tv/kraken/videos/106400740?client_id=xxxxxxx where 106400740 is the video id (note that 'kraken' here is constant - not sure of the origin behind its name) - note that the request will return a JSON object which contains an error message if you do not include a client_id
The request will return a JSON object which looks something like:
{
"title": "Door 5 vs Tilted Gamers",
"description": "COOL Games: Killing Spree first match # Mineski. Grove, Los Ba\u00f1os",
"description_html": "COOL Games: Killing Spree first match # Mineski. Grove, Los Ba\u00f1os<br>",
"broadcast_id": 1,
"broadcast_type": "upload",
"status": "recorded",
"language": "en",
"tag_list": "",
"views": 4,
"created_at": "2017-11-08T03:13:12Z",
"published_at": "2017-11-08T04:33:37Z",
"url": "https:\/\/www.twitch.tv\/videos\/188543310",
"_id": "v188543310",
"recorded_at": "2017-11-08T03:13:12Z",
"game": "Dota 2",
"length": 2436,
"preview": "https:\/\/static-cdn.jtvnw.net\/s3_vods\/esportsdotcool\/188543310\/3534ab8c-bf7d-4c8a-b502-c406825bf75f\/thumb\/index-0000000000-320x240.jpg",
"animated_preview_url": "https:\/\/vod-storyboards.twitch.tv\/esportsdotcool\/188543310\/3534ab8c-bf7d-4c8a-b502-c406825bf75f\/storyboards\/188543310-strip-0.jpg",
"thumbnails": [
{
"type": "generated",
"url": "https:\/\/static-cdn.jtvnw.net\/s3_vods\/esportsdotcool\/188543310\/3534ab8c-bf7d-4c8a-b502-c406825bf75f\/thumb\/index-0000000000-320x240.jpg"
},
{
"type": "generated",
"url": "https:\/\/static-cdn.jtvnw.net\/s3_vods\/esportsdotcool\/188543310\/3534ab8c-bf7d-4c8a-b502-c406825bf75f\/thumb\/index-0000000006-320x240.jpg"
},
{
"type": "generated",
"url": "https:\/\/static-cdn.jtvnw.net\/s3_vods\/esportsdotcool\/188543310\/3534ab8c-bf7d-4c8a-b502-c406825bf75f\/thumb\/index-0000000012-320x240.jpg"
},
{
"type": "generated",
"url": "https:\/\/static-cdn.jtvnw.net\/s3_vods\/esportsdotcool\/188543310\/3534ab8c-bf7d-4c8a-b502-c406825bf75f\/thumb\/index-0000000018-320x240.jpg"
}
],
"fps": {
"144p30": 29.999544341896,
"360p30": 29.999544341896,
"480p30": 29.999544341896
},
"resolutions": {
"144p30": "256x144",
"360p30": "640x360",
"480p30": "852x480"
},
"channel": {
"name": "esportsdotcool",
"display_name": "esportsdotcool"
},
"_links": {
"self": "https:\/\/api.twitch.tv\/kraken\/videos\/v188543310",
"channel": "https:\/\/api.twitch.tv\/kraken\/channels\/esportsdotcool"
}
}
Under the thumbnails array you can find the url to the video.
PS: As you can see, the thumbnails array has length of 4 - at this point I think this is because of the different sizes of the image that the author of the video can put up

Deserializing JSON in Visual basic

I want to deserialize this string, it is from a rest api, but i dont know how to do it.
i know i have to create a class with the struture of the string, and i have to run the command with deserialize.
Can anyone help me?
Thanks
"
{
"success": true,
"data": {
"categories": {
"17": [
{
"category_id": "17",
"name": "Software",
"description": "",
"sort_order": "4",
"meta_title": "",
"meta_description": "",
"meta_keyword": "",
"language_id": "1",
"image": "http://newapi3.opencart-api.com/image/cache/catalog/categories/12316636179756542373092288841575795860377n-100x100.jpg",
"categories": null
},
{
"category_id": "17",
"name": "Software",
"description": "",
"sort_order": "4",
"meta_title": "",
"meta_description": "",
"meta_keyword": "",
"language_id": "2",
"image": "http://newapi3.opencart-api.com/image/cache/catalog/categories/12316636179756542373092288841575795860377n-100x100.jpg",
"categories": null
}
],
"18": [
{
"category_id": "18",
"name": "Laptops & Notebooks",
"description": "<p>\r\n\tShop Laptop feature only the best laptop deals on the market. By comparing laptop deals from the likes of PC World, Comet, Dixons, The Link and Carphone Warehouse, Shop Laptop has the most comprehensive selection of laptops on the internet. At Shop Laptop, we pride ourselves on offering customers the very best laptop deals. From refurbished laptops to netbooks, Shop Laptop ensures that every laptop - in every colour, style, size and technical spec - is featured on the site at the lowest possible price.</p>\r\n",
"sort_order": "2",
"meta_title": "",
"meta_description": "",
"meta_keyword": "",
"language_id": "1",
"image": "http://newapi3.opencart-api.com/image/cache/catalog/demo/hp_2-100x100.jpg",
"categories": null
},
{
"category_id": "18",
"name": "Laptops & Notebooks",
"description": "<p>\r\n\tShop Laptop feature only the best laptop deals on the market. By comparing laptop deals from the likes of PC World, Comet, Dixons, The Link and Carphone Warehouse, Shop Laptop has the most comprehensive selection of laptops on the internet. At Shop Laptop, we pride ourselves on offering customers the very best laptop deals. From refurbished laptops to netbooks, Shop Laptop ensures that every laptop - in every colour, style, size and technical spec - is featured on the site at the lowest possible price.</p>\r\n",
"sort_order": "2",
"meta_title": "",
"meta_description": "",
"meta_keyword": "",
"language_id": "2",
"image": "http://newapi3.opencart-api.com/image/cache/catalog/demo/hp_2-100x100.jpg",
"categories": null
}
]
}
}
}"
Use this service to generate classes from JSON strings. It will save you a lot of time (and headache).
After that, you might consider using a third-party library for deserializing the JSON string. You have quite a few options but the most popular and the best according to me, is JSON.NET.
After you have installed it, you can go forward and access whatever data you want after deserializing the JSON.
Example:
Dim data = JsonConvert.DeserializeObject(Of YourDataClass)("<YourJSONString>");
If data.Success Then
Console.WriteLine(data.Data.Categories(0).Name);
End If

Sencha touch 2, printing nested JSON array using xtemplate

I am developing a simple movie listing app.
I am using rotten tomatoes api. following is the json :
movies": [{
"id": "771310572",
"title": "Cloud Atlas",
"year": 2012,
"mpaa_rating": "R",
"runtime": 163,
"release_dates": {
"theater": "2012-10-26"
},
"ratings": {
"critics_rating": "Fresh",
"critics_score": 80,
"audience_score": 98
},
"synopsis": "Cloud Atlas explores how the actions and consequences of individual lives impact one another throughout the past, the present and the future. Action, mystery and romance weave dramatically through the story as one soul is shaped from a killer into a hero and a single act of kindness ripples across centuries to inspire a revolution in the distant future. Each member of the ensemble appears in multiple roles as the stories move through time. -- (C) Warner Bros.",
"posters": {
"thumbnail": "http://content6.flixster.com/movie/11/16/71/11167192_mob.jpg",
"profile": "http://content6.flixster.com/movie/11/16/71/11167192_pro.jpg",
"detailed": "http://content6.flixster.com/movie/11/16/71/11167192_det.jpg",
"original": "http://content6.flixster.com/movie/11/16/71/11167192_ori.jpg"
},
"abridged_cast": [{
"name": "Tom Hanks",
"id": "162655641",
"characters": ["Dermot 'Duster' Hoggins", "Dr. Henry Goose", "Isaac Sachs", "Valleysman Zachry"]
}, {
"name": "Halle Berry",
"id": "162652386",
"characters": ["Jocasta Ayrs", "Luisa Rey", "Meronym"]
}, {
"name": "Jim Broadbent",
"id": "162653369",
"characters": ["Vyvyan Ayrs"]
}, {
"name": "Hugo Weaving",
"id": "162709905",
"characters": ["Bill Smoke", "Nurse Noakes", "Old Georgie"]
}, {
"name": "Jim Sturgess",
"id": "563717190",
"characters": ["Adam Ewing", "Hae-Joo Im"]
}]
I am able to get the first list view showing the list of movies and ontap on movie list item, I am able to load the next view to show the movie details.
I am stuck in displaying abridged_cast in the xtemplate. if I use {abridged_cast} the page displays object, Object.
I am unable to find any functions which will extract the values from this array and display.
How to display the array content in the template?
Thanks.

Testing in-app purchases in Kindle Fire application

I am not able to test in app purchases even with Amazon Appstore SDK Tester.
public void onPurchaseResponse(final PurchaseResponse purchaseResponse)
purchaseResponse always has "INVALID_SKU" even if I have amazon.sdktester.json file with fake JSON.
file content:
{
"test" : {
"itemType": "CONSUMABLE",
"price": 0.99,
"title": "More Clicks!",
"description": "Click your button ten more times!",
"smallIconUrl": "http://www.google.com/images/srpr/logo3w.png"
},
"com.amazon.buttonclicker.ten_clicks" : {
"itemType": "CONSUMABLE",
"price": 0.99,
"title": "More Clicks!",
"description": "Click your button ten more times!",
"smallIconUrl": "http://www.google.com/images/srpr/logo3w.png"
},
"com.amazon.buttonclicker.blue_button" : {
"itemType": "ENTITLED",
"price": 0.99,
"title": "Blue Button",
"description": "Button Clicker - Now in Blue!",
"smallIconUrl": "http://www.google.com/images/srpr/logo3w.png"
}
}
Even sample application does not work.
Do you have any suggestions how to test application? It seems that Amazon SDK Tester does not intercept requests.
Here's how I got the In App purchases to work on Kindle Fire (after several hrs of struggle...)
adb install AmazonSDKTester.apk (Install SDKTester on Kindle Fire)
Create a file amazon.sdktester.json in the SDCARD directory (The connected KF shows up as SDCARD in Finder on ur Mac)
Contents of amazon.sdktester.json - {
"com.yourcompany.yourpkgname.200_coins" : {
"itemType": "CONSUMABLE",
"price": 0.99,
"title": "200 COINS",
"description": "2 COINS",
"smallIconUrl": "http://www.yourcompany.com/icon.png"
}
}
Press the power button on KF & press "Disconnect" button - Now KF is no longer a mounted drive on ur Mac.
Run the AmazonSDKTester app on KF.
Run your app from Eclipse. Make sure the package name in the JSON matches the In App Item SKU on Amazon's website & in the PurchasingManager.initiatePurchaseRequest("com.yourcompany.yourpkgname.200_coins");
Now you should see the In App interstitials showing up.
Still doesn't work - Force Close both your app & AmazonSDKTester on KF; Hard Reset KF ; Restart Eclipse & Restart from Step 1
Don't forget the outer enclosing {} braces in your json.
It took me 3 hours until I figured that out...
It looks like magic but hard reset resolved all my problems.
Make sure to hit the disconnect button after you connect the usb cable to your pc, otherewise the SDK tester will not be able to read the JSON file you moved over since the device is mounted at that point. Found this out the hard way.
I have faced with the issue that the same as your, the key is: in your java code, your item id must equal to your SKU in json file, in this case, it must be: com.amazon.buttonclicker.ten_clicks or com.amazon.buttonclicker.blue_button
Here is the example json file for SampleIAPConsumablesApp and SampleIAPEntitlementsApp sample project provied by Amazon:
{
"com.amazon.sample.iap.consumable.orange" : {
"itemType": "CONSUMABLE",
"price": 0.99,
"title": "More Clicks!",
"description": "Click your button ten more times!",
"smallIconUrl": "http://some/image.jpg"
},
"com.amazon.sample.iap.entitlement.level2" : {
"itemType": "ENTITLED",
"price": 0.99,
"title": "Blue Button",
"description": "Button Clicker - Now in Blue!",
"smallIconUrl": "http://some/image.jpg"
}
}
Goodluck!

Xbmc Database Path

I am working with XBMC. I have installed XBMC in my system(Windows 7, 32 bit). Xbmc is working fine in my system. I have developed an application in order to control the Xbmc remotely from Ipad. In order to retrieve the music files or video files from Xbmc, I am unable to. By searching the forums of xbmc, I found that we can write an sql query to get them out. But, the thing is I am unable to make out where the database is located in my system. Someone help me out where I can find it.
Regards,
Sushma.
The database itself
By default the location of the database is that described on the wiki page XBMC databases
but the actual location can be changed by the user, or a different database technology can be used entirely.
The settings that would affect this are located in advancedsettings.xml.
But in general it is advised by the XBMC developers to never access the database directly.
JSONRPC
In order to help with interacting with the database XBMC has supported the JSONRPC queries, the one downside of these is that XBMC needs to be running at the time to respond to these queries. The major advantage is that it XBMC will find the database for you and expose access to it with a common interface.
JSONRPC support was first added to XBMC in "Darhma" (v10), became really useful in "Eden" (v11) and will support almost everything possible in "Frodo" (v12). Information about the use of JSONRPC can be found in the wiki.
An example
In this example I'm assuming that you are targeting "Eden", the current stable release of XBMC. Also I have formatted the following with new lines, these are not required and are not present in the response from XBMC.
Request
If you were to use JSONRPC the request you would need to send would look something like:
{
"jsonrpc": "2.0",
"method": "VideoLibrary.GetMovies",
"params": {
"properties": [
"title",
"year",
"file"
],
"limits": {
"start": 0,
"end": 2
}
},
"id": 1
}
Note: If you wanted different information about each movie you could use other properties listed here.
*Note: You probably want to omit the "limits" part to get all movies.*
Responce
The response to this would be something like:
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"limits": {
"end": 2,
"start": 0,
"total": 47
},
"movies": [
{
"label": "Label for movie",
"movieid": 1,
"title": "Title of movie",
"year": 2012
},
{
"label": "Label for another movie",
"movieid": 2,
"title": "Title of another movie",
"year": 2010
},
{
"label": "Label for a third movie",
"movieid": 3,
"title": "Title of a third movie",
"year": 2012
}
]
}
}
What to do now?
You have a choice at this point, you can either:
Add "file" to the list of properties, this will return the "file" property, the location of the video file.
Use JSONRPC to tell xbmc to play a movie.
Using this method is best when you don't want to play the file locally (on the iPad) but instead on XBMC.
Playing a movie on XBMC via JSONRPC
This is quite simple, use the "movieid" you received earlier in the following request:
{
"jsonrpc": "2.0",
"method": "Player.Open",
"params": {
"item": {
"movieid": 2
}
},
"id": 1
}
Lastly I would note that there are equivalent commands for TV episodes as shown for movies.