Device location in dialogflow (api.ai) webhook request - chatbot

I'm working on a Dialogflow chat bot for Google Assistant, in the webhook request JSON example here:
https://developers.google.com/actions/reference/v1/dialogflow-webhook
the webhook receives device data including its location:
"device": {
"location": {
"coordinates": {
"latitude": 123.456,
"longitude": -123.456
},
"formatted_address": "1234 Random Road, Anytown, CA 12345, United States",
"zip_code": "12345",
"city": "Anytown"
}
}
For some reason my webhook is not receiving any device data (the "device" key is missing completely). Does anyone know what I'm doing wrong or how I can include this data?

You'll need to ask for the user's location permissions first. Then their location will be made available in the request JSON. Here's a good example of how to do it.
Note, you can ask for two different kinds of location:
DEVICE_PRECISE_LOCATION will give you their exact latitude and longitude, and DEVICE_COARSE_LOCATION will provide you with broader location information. It's generally good practice to only use the least intrusive permissions your applications need, so if your app can settle for a coarse location, then you should opt for it.
Note that you're looking at the v1 API, which is deprecated and scheduled to be removed in the near future. Make sure you're working with the v2 documentation.

Related

Implementing tripadvisor traveller rating

my goal is to show TripAdvisor score rank inside my app alongside other ranking system. Keep in mind that my application is a B2B app, not B2C.
What i can not understand even after reading the developer documentation is what kind of API should i eventually ask for.
The Content API is only for B2C purposes...but, apparently, it is the only one that send me in response the actual TripAdvisor rating (the only thing i actually want from all TripAdvisor information).
Has anyone implemented TripAdvisor in an OTA (online travel agency) application and can guide me on which APIs to request?
Thank you in advice
I have not implemented TripAdvisor ratings in a B2B system, but helped on a B2C project that used Tripadvisor data.
Your findings regarding Content API is correct, this is the only API where you find ratings.
Rating is TripAdvisor "selling point", so this data protected and can only be used by following their presentation terms. Check out how here: https://developer-tripadvisor.com/content-api/display-requirements/
You have 6 months implementation time and have to get Tripadvisor approval, or they cancel your API key. By using their API you commit not to store any data retrieved from their API.
Quick guide to use their API: https://developer-tripadvisor.com/content-api/documentation/
Call the locator_mapper to get possible location_id(s)
http://api.tripadvisor.com/api/partner/2.0/location_mapper/42.344978,-71.119030?key=[YOUR_KEY_HERE]-mapper&category=hotels&q=Beacon%20Townhouse%20Inn%201023
It returns a JSON with possible locations,
{
"data": [
{
"location_id": "89575",
Then call location with the id to get ratings: http://api.tripadvisor.com/api/partner/2.0/location/89575?key=[YOUR_KEY_HERE]
"review_rating_count": {
"1": "18",
"2": "22",
"3": "63",
"4": "269",
"5": "1408"
},
Use this data, together with the presentation and links back to tripadvisor to comply with their license.

Why does my Google Home send an empty location field in an Actions On Google webhook request?

I have been following the template on GitHub for integration with the locations API the Actions On Google offers.
It works fine in the simulator and even on the Google Assistant for Phones, i.e. I either get a lat/lon pair or a coarse location provided depending on whether the device has a screen or not.
However, on my physical Google Home device, the location field in the response is empty and I cannot figure out why.
In one step, I request the permission with
app.askForPermission(Responses.permissionReason(), app.SupportedPermissions.DEVICE_COARSE_LOCATION);
In my follow-up step I then check if the permission was granted and continue:
if (!app.isPermissionGranted()) {
return Promise.reject(new Error('Permission not granted'));
}
const location = app.getDeviceLocation();
If I start this conversation from my Google Home, however, getDeviceLocation is undefined.
Looking at the request, the permission is clearly granted but the location field is empty:
<snip>
"user": {
"userStorage": "{\"data\":{}}",
"lastSeen": "2018-01-20T10:50:01Z",
"permissions": [
"DEVICE_COARSE_LOCATION"
],
"locale": "en-GB",
"userId": "<redacted>"
},
"device": {
"location": {}
},
</snip>
Full request here.
I couldn't find any information in the documentation about why this would happen. Could someone fill me in?
Check to make sure that your Google Home has a location set for it in the configuration. If you have configured it for voice recognition, make sure it is your voice being recognized and not a generic account.

Uber Details On sandbox

I am using uber-api`s in India for my project,as my project is still in the development phase,i am using the sandbox environment.While using this testing environment uber is just returning the following details on the sandbox environment
1.Allows to book a ride.
2.List of the products of the uber(Uberx,UberGo)
3.Dummy receipt.
The information that is missing on the sandbox environment is
1.The Driver Details
2.Vehicle Details
3.Surge Pricing.
Is there any way through which i can get all these details on my sandbox environment?or is it a bug?
Thanks in Advance.
The Sandbox mode passes through calls to all available endpoints. It essentially makes exceptions for /requests/{request_id} and /products/{product_id} (by allowing you to use HTTP PUT):
At this time, most of the endpoints in the Sandbox environment are proxied straight to the production environment. The Request endpoint is the primary exception. It allows you to exercise the flow of ordering an Uber in your application without worrying about a real world trip being created. Additionally, you can simulate surging products or no drivers being available to ensure that your application handles these scenarios properly.
I have to admit that I'm not familiar with India-specific differences for the Uber API (would love to know them), but in general, the Uber API allows you to do this:
1) GET /requests/current and GET /requests/{request_id}: Returns (amongst other elements) the driver & vehicle details as JSON objects:
{
...
"driver": {
"phone_number": "(555)555-5555",
"rating": 5,
"picture_url": "https:\/\/d1w2poirtb3as9.cloudfront.net\/img.jpeg",
"name": "Bob"
},
"vehicle":{
"make": "Bugatti",
"model": "Veyron",
"license_plate": "I<3Uber",
"picture_url": "https:\/\/d1w2poirtb3as9.cloudfront.net\/car.jpeg"
},
...
}
2) POST /requests: When booking a ride, the server can return a HTTP 409 status code - in case surge pricing is in effect. It provides the following details in a JSON object:
"meta": {
"surge_confirmation": {
"href": "https:\/\/api.uber.com\/v1\/surge-confirmations\/e100a670",
"surge_confirmation_id": "e100a670",
"multiplier": 1.4,
"expires_at": 1459191276
}
}
To complete, you would need to redirect the user to the confirmation URL (meta.surge_confirmation.href)

iTunes App Store API for Querying My Apps, Editing My Apps, and Uploading New Apps

Does Apple offer a web service API for querying iOS apps I sell under my account, editing these apps, and uploading new ones? If so, could someone provide a link?
The only thing I could find is the Application Loader tool that allows bulk creation operation for IAP via a file. Does this tool support bulk creation of apps? Does this tool support editing existing IAP?
https://itunesconnect.apple.com/docs/UsingApplicationLoader.pdf
Update
The App Store Connect API offers API access to a limited set of App Store connect features.
Old Answer
There is no web service API for performing private actions available only to you. You must login to iTunes Connect and do it there.
There is a web service for accessing publicly available information. It is documented here.
For example, for more info on the Yelp app, you could send this request:
https://itunes.apple.com/lookup?id=284910350
Which will return JSON like this:
{
"resultCount": 1,
"results": [
{
"kind": "software",
"features": [
"iosUniversal"
],
"supportedDevices": [
"all"
],
"isGameCenterEnabled": false,
"screenshotUrls": [
"http://a1283.phobos.apple.com/us/r1000/084/Purple/v4/d7/10/4e/d7104e7c-69b9-c30e-fb74-dc9ad4907e5d/mzl.qhnhnswp.png",
"http://a1583.phobos.apple.com/us/r1000/091/Purple/v4/f2/9e/1f/f29e1ff0-15ae-955b-9470-95e777e0d302/mzl.ehinvjli.png",
"http://a232.phobos.apple.com/us/r1000/080/Purple/v4/fa/be/87/fabe8765-de35-ae10-6eba-4b77dee9579c/mzl.ypncttex.png",
"http://a1190.phobos.apple.com/us/r1000/114/Purple2/v4/86/68/86/86688674-4540-b317-9e1f-fc2c8adede50/mzl.ekbdqwzg.png",
"http://a296.phobos.apple.com/us/r1000/115/Purple2/v4/b6/ca/e1/b6cae1d2-5754-d092-c2c3-09dce16a5b86/mzl.xroiibzd.png"
],
"ipadScreenshotUrls": [
"http://a1855.phobos.apple.com/us/r1000/069/Purple2/v4/27/53/59/27535982-a8ab-752b-1352-14376dbd52fa/mzl.pzkmvqsc.1024x1024-65.jpg",
"http://a1384.phobos.apple.com/us/r1000/120/Purple/v4/d8/61/72/d86172b0-c012-b520-aaea-0fe405af8220/mzl.ayvdvsyz.1024x1024-65.jpg",
"http://a1714.phobos.apple.com/us/r1000/107/Purple/v4/d4/e6/54/d4e65417-151e-c358-cf46-67034eb1c809/mzl.cqcnsrnw.1024x1024-65.jpg",
"http://a668.phobos.apple.com/us/r1000/115/Purple2/v4/9f/0f/0c/9f0f0c76-86cf-5af0-7d62-e57d05cdb7d9/mzl.gdkkhahb.1024x1024-65.jpg",
"http://a886.phobos.apple.com/us/r1000/080/Purple2/v4/4e/2c/e8/4e2ce8be-f69d-2fd9-b79a-e9a689dd1ad6/mzl.vjffwbxj.1024x1024-65.jpg"
],
"artworkUrl60": "http://a1154.phobos.apple.com/us/r1000/093/Purple2/v4/df/d2/d1/dfd2d173-7901-1c41-fcc3-ea953e698961/57.png",
"artworkUrl512": "http://a1157.phobos.apple.com/us/r1000/108/Purple/v4/db/b7/fb/dbb7fb10-29a7-4771-e781-38fffee81c85/mzl.atjqxuth.png",
"artistViewUrl": "https://itunes.apple.com/us/artist/yelp/id284910353?uo=4",
"artistId": 284910353,
"artistName": "Yelp",
"price": 0,
"version": "6.5.1",
"description": "Looking for a burrito joint open now? An Irish pub nearby? A gas station you can drive to before your tank hits empty? Yelp for your iPhone or iPad is here to help. Use us to search for places to eat, shop, drink, relax and play then read reviews from an active community of locals in the know. \n\nFEATURES:\n★ Search for businesses near you \n★ Tap quick links to find nearby bars, restaurants, cafes and more\n★ Narrow your searches by 'hood, distance, price, and what's open now\n★ Browse reviews to read what's great (and not so great) in your city\n★ Find great Deals offered by your favorite local businesses on iPhone\n★ Add tips, photos, and draft reviews for your favorite businesses\n★ Check-in and share on Facebook and Twitter\n★ Make reservations on OpenTable without leaving the Yelp app\n★ Look up addresses and phone numbers for thousands of businesses, then call or map them from your iPhone or iPad\n★ Yelp does augmented reality with Monocle. Overlay business information onto the world around you.",
"currency": "USD",
"genres": [
"Travel",
"Navigation"
],
"genreIds": [
"6003",
"6010"
],
"releaseDate": "2008-07-11T07:00:00Z",
"sellerName": "Yelp, Inc.",
"bundleId": "com.yelp.yelpiphone",
"trackId": 284910350,
"trackName": "Yelp",
"primaryGenreName": "Travel",
"primaryGenreId": 6003,
"releaseNotes": "New in 6.5.1:\nJust to show how much we love our Yelpers, we're knocking out two big feature requests with this release:\n☆ Apparently 300 characters per Tip wasn't enough for you to fully express yourself. We dig that. This release gives you 200 more.\n☆ From the \"More Reviews\" list on iPhone, pull down to expose a review search box. Now you can skip the other stuff and find out exactly what people think about the \"carne asada burrito\" at that new Mexican spot down the street.\n\nNew in 6.5:\n☆ We gave our iPad business page a whole lot of love. It's now more streamline and clear, with more emphasis on business photos. In addition, we're now showing Yelp Deals and our new \"Explore the Menu\" feature.\n☆ Yelp search just got more social: Now you can see which friends are checked in to businesses directly from your search results.\n☆ Getting to a restaurant just after closing is a major bummer. Now we'll indicate if a business will be closing soon or is just about to open.\n☆ We also got in a TON of bug fixes and enhancements: showing your review first in the reviews list, supporting updated reviews on iPad, swipe-able photos on the business page, and huge speed improvements on iPhone5!",
"formattedPrice": "Free",
"wrapperType": "software",
"trackCensoredName": "Yelp",
"languageCodesISO2A": [
"SV",
"TR",
"NB",
"DA",
"DE",
"EN",
"ES",
"FI",
"FR",
"IT",
"NL",
"PL"
],
"fileSizeBytes": "18176675",
"contentAdvisoryRating": "12+",
"averageUserRatingForCurrentVersion": 3.5,
"userRatingCountForCurrentVersion": 74,
"artworkUrl100": "http://a1157.phobos.apple.com/us/r1000/108/Purple/v4/db/b7/fb/dbb7fb10-29a7-4771-e781-38fffee81c85/mzl.atjqxuth.png",
"trackViewUrl": "https://itunes.apple.com/us/app/yelp/id284910350?mt=8&uo=4",
"trackContentRating": "12+",
"averageUserRating": 3.5,
"userRatingCount": 170887
}
]
}

iPhone: Roaming MCC

Is there a possibility to retrieve the "actual" Mobile Country Code of the iPhone?
If I use the conventional method over the CTCarrier I only receive the MCC of the SIM-Card, but I want the Mobile Country Code of the Roaming Provider.
No this is not possible in the current iOS SDK.
I don't believe this is possible with a private API, but you can use a third party service such as http://ipinfo.io, which I built. Here's the standard API response, which will include carrier details in the org field:
$ curl ipinfo.io/24.32.148.1
{
"ip": "24.32.148.1",
"hostname": "doc-24-32-148-1.pecos.tx.cebridge.net",
"city": "Pecos",
"region": "Texas",
"country": "US",
"loc": "31.3086,-103.5892",
"org": "AS7018 AT&T Services, Inc.",
"postal": "79772"
}
Custom packages are available that also include the full mnc/mcc details for mobile IPs though. See http://ipinfo.io/developers for details.