how to know which echo dot is calling my alexa service - alexa-skills-kit

We are trying to build a alexa skill for our office building so that an echo dot is deployed at the entrance of each floor and help people identify the directions of washrooms and conference rooms and many other. We were sucessful in implementing it.
I would like know how can we utilize same service for multiple floors how can i know in alexa skill set from which echo dot my skill set is being called.
lets say if user ask for washroom directions. Alexa needs to identify he is in first floor and tell him to take left. if he is in second floor it needs to tell him take right.
Regards
Kalyan

So far Alexa cannot identify the exact location. The only location it can find is the address linked with the account. I can think of 2 solutions.
Solution 1:- If the user asks for direction then your Alexa skill can ask a question back to the user that which floor they are in.
Solution 2:- You can create multiple skill sets for each echo in each floor. Say the echo in the first floor can provide directions for first floor and so on.
I would prefer Solution 1 as creating separately skill for each floor may not be a good idea. But if you don't want the user to input which floor they are in they go for solution 2.

If devices aren't going to move (ever or often), I would look at the Device ID.
Amazon recently added the Device ID (unique across all devices) to the LaunchRequest JSON payload.
{
"session": {
"new": true,
"sessionId": "string",
"application": {
"applicationId": "string"
},
},
"context": {
"device": {
"deviceId": "string",
},
"request": {}
}
I would have one Skill that looks at the requesting device ID (context.device.deviceId) and delivers the correct answer based on the context.
Obviously, you'd need to manage a mapping between floor and device ID, and update that if the device ever moves.

I had asked this question about a year ago during an Office Hours session with Amazon. I was told that their intention was to prevent Alexa from knowing much if anything about the device it was running on.
Since then Amazon has added limited capability to allow Alexa skills to know about the particular user and their device. It may be possible to map specific devices within a skill, but that sounds a bit tricky and fragile.
A more robust approach would be Vijayanath's solution 2 above. I believe this would also require that each Echo be on a separate account, though. I'm not aware of any way to deploy a skill to a specific device and not all the others.
I used this approach for a halloween costume last year to allow 2 dots sitting on my shoulders to respond differently to the same utterances (think of the scene from Animal House). With just 2 devices, this worked ok. Depending on how many devices you intend to have, this might be prohibitively cumbersome.

Related

What will be the type of user in case of SCRUM story for an API?

I have two queries related to SCRUM. They are as follows:
I have read that the format of SCRUM story is "As a < type of user >, I want < some goal > so that < some reason >". I have to write a story for an API. This API will send an email with a link to validate the email address of the user. What will be the type of user here? Will it be the user logged in?
Do subtasks have story format similar to a story or it can be a normal description?
The trouble you are encountering is likely that you are starting from a determined implementation and then trying to work backwards to the need (unless your product is an API that your users leverage, in which case I think that answers your questions).
When we approach it from a user need, we'll usually end up with more of a problem statement, like
"As a vacationer, I'd like the site to calculate the best route across
all types of transportation for me so that I don't have to run many
searches to figure it out myself."
One of the pieces of delivering on this need will be creating the API calls if your application architecture calls for that. Then "add API method for aggregated call" may be a task under that user story.
You will have cases where all a particular story needs is API work, and that's fine, but it won't come out in the user story. For example, let's say we did the about user story but limited it to planes and trains for the first start, then we created another story that reads:
"As a vacationer in the US, I want my trip planner to factor in buses
so that I can make use of bus tours in my vacation."
Now, maybe the only task in there is to create a some API changes to include the bus routes in the search, but that doesn't cause a problem with your user stories because we started back at the user's problem statement in the beginning instead of starting at the desired implementation and working backward.
Let's start clarifying some concepts first.
Scrum is not an acronym so is written as Scrum (proper name). Then, there is nothing called "Scrum Stories". What you are referring to is called: user story. User stories were wide used in the Chrysler C3 project were eXtreme Programming was developed. Furthermore, you are referring to a particular template which was popularized by Mike Cohn known as canonical form. So it's ok to express your Product Backlog Item as user stories for an API. But take into account that you can use this template, you can use user stories or you can write the Product Backlog Item the way has more sense and value to you. In your case, which is the persona, machine or service which will be used the API?
About your second question. The Scrum Guide just says you should decompose your Sprint Planning in unit of work of 1 day or less. Normally, the implementation is to create this unit of work and call them task which are the work necessary to carry out the user story. The way the are written is open too but is not quite common to write them in the canonical form. So you can write it as an ID, title and a description.

Single term answer to Alexa Skill

Background
I'm writing an Alexa Skill and looking to get pieces of information from the user.
The following conversation for example:
Alexa: What month were you born at?
User: April
Alexa: Good. And what was your favorite movie?
User: April
The problem
Given the following utterances:
GetMonthIntent {month}
GetMovieIntent {movie}
Once a user answers April for the second time, the GetMonthIntent might be triggered.
What I have tried
Asking the user to specify which piece of information is giving by using the following utterances:
GetMonthIntent Month {month}
GetMovieIntent Movie {movie}
The question
What is the right way to make Alexa wait for a single term answer based on the current context?
In the same vein as the other answers here, you should take a look at the newest Node.JS library here, which handles state out of the box:
https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs#making-skill-state-management-simpler
You could define:
State_Launch
State_Month
State_Movie
And then return the proper error response if anything other than the GetMovieIntent or GetMonthIntent (etc.) intents are called in the wrong state.
You would have to do data validation on the server side to make sure the "month" is a valid one, and movies are even harder to validate unless you have a list of expected values. That is, if you care to parse them for use beyond repeating back.
Unfortunately, there is no solution. There is no way to specify the 'context' in which a user reply should be interpreted, so you have to tell the user "what was your favorite movie? Please say 'my favorite movie is' and then the name of the movie".
Here are two ASK feature requests that I think would address your issue:
https://forums.developer.amazon.com/content/idea/41062/creating-something-to-help-with-more-structured-qu.html
https://forums.developer.amazon.com/content/idea/55525/allow-a-response-to-specify-a-set-of-expected-inte.html
Personally I think this is fairly important so I voted for those, but they are not near the top.
I ran into this same problem when I created the "Who's on First? Baseball Skit" skill. I handled this by:
Create a sequence number for each response given by Alexa
Write this number to the "session" in the response.
The session is then passed back to your skill by Alexa in the next request.
Read the sequence number from the request to know what the previous question was.
If a given intent could be the answer to multiple questions (eg. month and movie in your case) then use the sequence number to determine which it is.
This should give you ideas on how to deal with repeated answers. The session is quite easy to use. Other options include writing the userId and status to a database like DynamoDB, but I find that the session works in most cases.

Alexa Skills Kit (ASK) and Utterances

I am developing a simple, custom skill for Alexa. I have it up and running, and hosting the handler on AWS Lambda. It's working fine except...
In the test UI, if I enter a valid utterance, e.g., help, cancel, swim, run (two custom utterances), everything works well; however, if I enter a nonsense utterance, e.g., dsfhfdsjhf, the Alexa service always maps the nonsense to the first valid intent in the intents schema.
In my lambda code, I have a handler for handling unknown intents; however, the intent is never unknown. Is this an artifact of the test interface? Something else happening?
Thanks,
John
Based on the inclusion of an unhandled intent in your approach, it sounds like you are using the Alexa Skills Kit SDK for Node.js. Your issue is not an artifact of the test interface. Yes, something else is happening.
While not yet acknowledged by amazon, this is a recognized issue in the SDK by a number of folks. See this open issue. Speaking from personal experience to the suggestion above, it doesn't matter if you use real words or gibberish, the unhandled intent is never called. Until this is fixed, my suggestion would be to build a handler that is a high level prompt for your skill, and reiterates for the user the valid options they have. Position it to be the catch-all. Hopefully we will see better maintenance of this SDK moving forward.
Instead of typing dsfhfdsjhf (which is not pronounceable in any language Alexa knows), what happens if your utterance is boogie or shake?
In a real-world scenario, I don't think Alexa would ever pass dsfhfdsjhf, so it may be difficult to plan exactly what the behavior would be.
So you'd like to pipe all garbage inputs to a single intent. You're in luck. Here's a few things you should know before proceeding.
In Node.js the unhandled handler is fired within a MODE if the intent returned by the Alexa voice service is not available within the given MODE.
An example MODE would be confirmation mode. Of the many intents that are available yes and no are the only intents that are accepted.
var ConfirmationHandlers = Alexa.CreateStateHandler(states.CONFIRMATIONMODE, {
'YesIntent': function () {
this.handler.state = states.CLOSINGCOSTSMODE;
message = ` So you will be buying this house. Great! `;
reprompt = `Please carry on with the other intents found in the house buyer skill. `;
this.emit(':ask', message, reprompt);
},
'NoIntent': function () {
this.handler.state = states.GENERALSEARCHMODE;
message = ` So you won't be buying this house. That's Ok, Continue searching for your dream house in the House buyer skill. !`;
reprompt = `Continue searching for your dream house in the House buyer skill.`;
this.emit(':ask', message, reprompt);
},
'Unhandled': function() {
console.log("UNHANDLED");
var reprompt = ` All other intents are disabled at this moment. Would you like to buy this house Yes or No? `;
this.emit(':ask', reprompt, reprompt);
}
});
However, before reaching the lambda function the Alexa Voice Service must interpret your utterance and map it to one of the available intents. If your utterance is garbage and does not map to any specific intent it is currently being mapped to the first intent.
Solution: If you would like to add a garbage intent this is something that should be handled by the intent schema not by the unhandled intent. To add a garbage intent you can follow the instructions in this amazon article.
https://developer.amazon.com/blogs/post/Tx3IHSFQSUF3RQP/Why-a-Custom-Slot-is-the-Literal-Solution
Scenario 3: I just want everything. Using custom slot types for
grammar as described above typically fulfills this desire and enables
you to improve accuracy through NLP training. If you still just want
everything, you can create a custom slot called something like
“CatchAll” and a corresponding intent and utterance: CatchAllIntent
{CatchAll}. If you use the same training data that you would have used
for LITERAL, you’ll get the same results. People typically find that
adding a little more scenario specific training data improves
accuracy.
If you’re still not getting the results, trying setting the CatchAll
values to around twenty 2 to 8 word random phrases (from a random word
generator – be really random). When the user says something that
matches your other utterances, those intents will still be sent. When
it doesn’t match any of those, it will fall to the CatchAll slot. If
you go this route, you’re going to lose accuracy because you’re not
taking full advantage of Alexa’s NLP so you’ll need to test heavily.
Any input that is not mapped to one of your more specific intents, like YES or NO, will very likely map to this CatchAll intent.

Access Google's Traffic Data through a Web Service

Is there a way I can access traffic data that Google provides through a web service?
There seems to be a GTrafficOverlay that puts traffic on top of a route on an embedded google map, but no direct web service that I can consume to, say, give the source and the destination and find the traffic between them?
Is there any other source I can get this data from?
UPDATE (May 2022): From #AbdullahTahan:
Now google has this feature but it's paid and costs 0.01$ per request check this https://developers.google.com/maps/documentation/distance-matrix/distance-matrix#distance-matrix-advanced
UPDATE (March 2016): A lot has happened since this answer was written in 2011, but the core points appear to hold up: You won't find raw traffic data in free API services (at least not for the U.S., and probably not most other places). But if you don't mind paying a bit and/or if you just need things like "travel time for a specific route taking traffic into consideration" you have options. #Anto's answer, for example, points to Google's Maps For Work as a paid API service that allows you to get travel times taking traffic into consideration.
ORIGINAL ANSWER: There is no way (or at least no reasonably easy and convenient way) to get the raw traffic data from Google Maps Javascript API v3. Even if you could do it, doing so is likely to violate some clause in the Terms Of Service for Google Maps. You would have to get this information from another service. I doubt there is a free service that provides this information at the current time, but I would love it if someone proved me wrong on that.
As #crdzoba points out, Bing Maps API exposes some traffic data. Perhaps that can fill your needs. It's not clear from the documentation how much traffic data that exposes as it's only data about "incidents". Slow traffic due to construction would be in there, but it's not obvious to me whether slow traffic due simply to volume would be.
Apparently the information is available using the Google Directions API in its professional edition Maps for work. According to the API's documentation:
Note: Maps for Work users must include client and signature parameters with their requests instead of a key.
[...]
duration_in_traffic indicates the total duration of this leg, taking into account current traffic conditions. The duration in traffic will only be returned if all of the following are true:
The directions request includes a departure_time parameter set to a value within a few minutes of the current time.
The request includes a valid Google Maps API for Work client and signature parameter.
Traffic conditions are available for the requested route.
The directions request does not include stopover waypoints.
You might want to take a look at HERE MAP SERVICE. They have direct traffic data you can use, which is exactly what you need: https://developer.here.com/api-explorer/rest/traffic/traffic-flow-bounding-box
For example, by querying an area of interest, you might get something like this:
{
"RWS": [
{
"RW": [
{
"FIS": [
{
"FI": [
{
"TMC": {
"PC": 32483,
"DE": "SOHO",
"QD": "+",
"LE": 0.71682
},
"CF": [
{
"TY": "TR",
"SP": 9.1,
"SU": 9.1,
"FF": 17,
"JF": 3.2911,
"CN": 0.9
}
]
}
]
}
],
....
This example shows a current average speed SU of 9.1, where the free flow speed FF would be 17. The Jam factor JF is 3.3, which is still considered free flow but getting sluggish.
The units used (miles/km) can be defined in the API call.
To avoid dealing with TMC locations, you can ask for geocoordinates of the road segments by adding responseattributes=sh in the request.
The abbreviations used can be found here Interpreting HERE Maps real-time traffic tags:
"RWS" - A list of Roadway (RW) items
"RW" = This is the composite item for flow across an entire roadway. A roadway item will be present for each roadway with
traffic flow information available
"FIS" = A list of Flow Item (FI) elements
"FI" = A single flow item
"TMC" = An ordered collection of TMC locations
"PC" = Point TMC Location Code
"DE" = Text description of the road
"QD" = Queuing direction. '+' or '-'. Note this is the opposite of the travel direction in the fully qualified ID, For example for
location 107+03021 the QD would be '-'
"LE" = Length of the stretch of road. The units are defined in the file header
"CF" = Current Flow. This element contains details about speed and Jam Factor information for the given flow item.
"CN" = Confidence, an indication of how the speed was determined. -1.0 road closed. 1.0=100% 0.7-100% Historical Usually
a value between .7 and 1.0 "FF" = The free flow speed on this
stretch of road.
"JF" = The number between 0.0 and 10.0 indicating the expected quality of travel. When there is a road closure, the Jam Factor
will be 10. As the number approaches 10.0 the quality of travel is
getting worse. -1.0 indicates that a Jam Factor could not be
calculated
"SP" = Speed (based on UNITS) capped by speed limit
"SU" = Speed (based on UNITS) not capped by speed limit
"TY" = Type information for the given Location Referencing container. This may be freely defined string
Also the source comes from
https://developer.here.com/rest-apis/documentation/traffic/topics/additional-parameters.html
Bing Maps API has a REST service that returns traffic info
http://msdn.microsoft.com/en-us/library/hh441725
Rather than trying to pull the raw traffic data, you can try a different approach.
The Google Directions API allows you to query the api with a particular route and returns a JSON string or XML element as a result.
This result includes the element - ' duration_in_traffic '
This indicates the total duration of the particular leg of the journey, taking into account current traffic conditions. (for information on 'leg' and other elements of the JSON string returned by the Directions API refer link below)
https://developers.google.com/maps/documentation/directions/#JSON
I haven't tried this myself but just something I came across in the documentation.
In India we are using http://www.itrafficnews.com. But the data is posted by the users. I dont think google will provide the data.
Maybe you should have a look at Mapquests Traffic API: http://www.mapquestapi.com/traffic/
The webservice is unfortunately only available for some citys in the US, I think. But probably it solves your problem.
I don't think Google will provide this API. And traffic data not only contains the incident data.
Today many online maps show city traffic, but they have not provide the API for the developer. We even don't know where they get the traffic data. Maybe the government has the data.
So I think you could think about it from another direction. For example, there are many social network website out there. Everybody could post the traffic information on the website. We can collection these information to get the traffic status. Or maybe we can create a this type website.
But that type traffic data (talked about above) is not accurate. Even the information provided by human will be wrong.
Luckily I found that my city now provides an Mobile App called "Real-time Bus Information". It could tell the citizen where the bus is now, and when will arrive at the bus station. And I sniff the REST API in this App.
The data from REST API give the important data, for example the lat and lon, and also the bus speed. And it's real-time data! So I think we could compute the traffic status from these data (by some programming).
Here is some sample data : https://github.com/sp-chenyang/bus/blob/master/sample_data/bjgj_aibang_com_8899_bjgj_php_city_linename_stationno_datatype_type.json
Even the bus data will not enough to compute the accurate real-time traffic status. Incidents, traffic light and other things will affect the traffic status. But I think this is the beginning.
At the end, I think you could try to find whether your city provides these data.
PS: I am always thinking that life will be better for people in the future , but not now.
It is possible to get traffic data.
Below is my implementation in python. The API has some quota & is not fully free, but good enough for small projects
import requests
import time
import json
while True:
url = "https://maps.googleapis.com/maps/api/distancematrix/json"
querystring = {"units":"metric","departure_time":str(int(time.time())),"traffic_model":"best_guess","origins":"ITPL,Bangalore","destinations":"Tin Factory,Bangalore","key":"GetYourKeyHere"}
headers = {
'cache-control': "no-cache",
'postman-token': "something"
}
response = requests.request("GET", url, headers=headers, params=querystring)
d = json.loads(response.text)
print("On", time.strftime("%I:%M:%S"),"time duration is",d['rows'][0]['elements'][0]['duration']['text'], " & traffic time is ",d['rows'][0]['elements'][0]['duration_in_traffic']['text'])
time.sleep(1800)
print(response.text)
Response is :-
{
"destination_addresses": [
"Tin Factory, Swamy Vivekananda Rd, Krishna Reddy Industrial Estate, Dooravani Nagar, Bengaluru, Karnataka 560016, India"
],
"origin_addresses": [
"Whitefield Main Rd, Pattandur Agrahara, Whitefield, Bengaluru, Karnataka 560066, India"
],
"rows": [
{
"elements": [
{
"distance": {
"text": "10.5 km",
"value": 10505
},
"duration": {
"text": "35 mins",
"value": 2120
},
"duration_in_traffic": {
"text": "45 mins",
"value": 2713
},
"status": "OK"
}
]
}
],
"status": "OK"
}
You need to pass "departure_time":str(int(time.time())) is a required query string parameter for traffic information.
Your traffic information would be present in duration_in_traffic.
Refer this documentation for more info.
https://developers.google.com/maps/documentation/distance-matrix/intro#traffic-model
There is a project called Open Traffic which is not fully functional right now but seems to be the right answer in the future.
OpenTraffic is a global data platform to process anonymous positions of vehicles and smartphones into real-time and historical traffic statistics. We're building this in the open, using fully open-source software, with involvement from a growing list of partners.

Is there a reliable way to prevent cheating in a web based contest where anonymous users can vote?

I'm working on a web-based contest which is supposed to allow anonymous users to vote, but we want to prevent them from voting more than once. IP based limits can be bypassed with anonymous proxies, users can clear cookies, etc. It's possible to use a Silverlight application, which would have access to isolated storage, but users can still clear that.
I don't think it's possible to do this without some joker voting himself up with a bot or something. Got an idea?
The short answer is: no. The longer answer is: but you can make it arbitrarily difficult. What I would do:
Voting requires solving a captcha (to avoid as much as possible automated voting). To be even more effective I would recommend to have prepared multiple types of simple captchas (like "pick the photo with the cat", "what is 2+2", "type in the word", etc) and rotate them both by the time of the day and by IP, which should make automatic systems ineffective (ie if somebody using IP A creates a bot to solve the captcha, this will become useless the next day or if s/he distributes it onto other computers/uses proxies)
When filtering by IP you should be careful to consider situations where multiple hosts are behind one public IP (AFAIK AOL proxies all of their customers through a few IPs - so such a limitation would effectively ban AOL users). Also, many proxies send along headers pointing to the original IP (like X-Forwarded-For), so you can take a look at that too.
Finally, using something like FSO (Flash Shared Objects - "Flash cookies") is obscure enough for 99.99% of the people not to know about. Silverlight is even more obscure. To be even sneakier, you could buy an other domain and set the FSO from that domain (so, if the user is looking for FSO's set by your domain, they won't see any)
None of these methods is 100%, but hopefully combined they give you the level of assurance you need. If you want to take this a level higher, you need to add some kind of user registration (which can be as simple as asking a valid e-mail address when the vote occurs and sending a confirmation link to the given address and not counting the votes for which the link wasn't clicked - so it doesn't need to be a full-fledged "create an account with username / password / firs name / last name / etc").
No, you can't, and it only takes one person and a willing forum to change the outcome of an online vote.
You have to realize the inherent flaws of an online vote and rather than attempting to get around them try to use them to your advantage.
-Adam
You can certainly make it difficult.
What about building a user profile with such things as ip address, browser useragent, machine name, and whatever other information you can get.
Store the profile for each user, then if you receive a profile which is similar enough to one already in the database (you'll have to tweak that) you can throw out that vote.
I imagine you can probably build a better profile using silverlight, though I'm not sure what information that gives you access to.
Client-side solutions are out for the reasons you listed -- they can be manipulated by the user. Server-side solutions -- as you said -- can be fooled and bypassed.
If you're willing to accept the fact that you can't really be 100% sure that you're getting exactly one vote per person, then there are some measures you can take to reduce the noise.
Use a CAPTCHA in your vote-submission form to make it harder for bots and scripts to vote.
Limit the number of votes per IP address to one.
Consider requiring registration in order to vote. (I know this defeats part of your original question, but it gives you a greater degree of control over the voting.)
That's a good start.
my personal experience in contest developing and monitoring tells me that no, there is no reliable way to avoid cheating if you let anonymous users vote (or do anything that lets them participate in the contest).
you could play with IP, introduce delays between an action and the next, but it's really difficult: the best way is introduce a captcha or something similar, if applicable in your particular situation.
best of all, don't let anonymous users participate: let them "play" and access to a simulation, but the contest needs a login.
Nope, it's the user's computer and they're in control.
Unfortunately the only solution is to bring it back on your court so to speak and require authentication.
However, a CAPTCHA helps limit the votes to human users at least.
Of course even with authentication you can't enforce single voting because then they teach the bots to register...
I have to agree that the short answer is no...though if you look at my recent answer here: How to anonymously identify a user and store that information you certainly can get it within a 6 percent margin of error.

Resources