question

cdburns123 avatar image
cdburns123 asked

Examples that use ASP.NET and your own server IIS, HTTPS..

Are there any examples of code on how to do a simple: "Alexa, Open HeyYou" - who are you? - "I am cdburns" - well, hello cdburns. VB or C#, ASP.NET...hopefully a step by step. I want to host my own web service because I know it will expand into home automation as well. I've written in VB and C# .NET and control my devices now, but would love to be able to add in the Echo with some other things as well. Thanks everyone.
alexa skills kitdebugging
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Stefan Negritoiu avatar image
Stefan Negritoiu answered
I blogged about this, see https://freebusy.io/blog/getting-started-with-alexa-app-development-for-amazon-echo-using-dot-net Stefan
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

cdburns123 avatar image
cdburns123 answered
Thanks! Just got the Echo in today and although it is pretty awesome, there are just some things that aren't there yet. I will go through the entire document and see what I can come up with and thank you.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

N. Fradkin avatar image
N. Fradkin answered
One thing that I think is confusing people who are trying to get started is that the "ASK" isn't an API. All it amounts to is specifications for a JSON request object and response object. You can parse the passed in JSON request object, and build the required JSON response in any way you want. Any language, any technique. In my current skill since there isn't a whole lot that I need to read out of the request I don't even bother with a real json parser. I just do some old fashioned token based string parsing to get the parameters I need. I don't use a JSON library to build the request, I just put it together with a string builder. It's currently written in C#, and implemented as an ASPX page.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

cdburns123 avatar image
cdburns123 answered
Anyway you could share some of this? I use to write ASP.NET applications, but it has been a very long time. Thanks!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

N. Fradkin avatar image
N. Fradkin answered
Sure. The entire current release is on the HomeSeer forums. This link should download it: http://board.homeseer.com/attachment.php?attachmentid=48887&d=1442802294 For anyone reading this code, I'm hacking this together as an open source hobby project at night, while drinking, and it's the first thing I've ever written in C#. It's currently a huge procedural mess that begs for refactoring. So if you look at this and think "That's all wrong! What kind of idiot wrote this? Does he even know C#?" First, please tell me what is wrong and how it should be coded. Second, to answer those questions, a drunk hobbyist idiot and no, I don't even know C#. The highlights (or lowlights depending on your software development philosophy). Parsing the request. There are many better ways to do this. This was just the easiest one for me to hack out to get something working quickly. I've got some constants for tokens to use for some primitive string parsing. const string requestSearchToken = "\"request\":{\"type\":\""; const string intentSearchToken = "\"intent\":{\"name\":\""; const string deviceSearchToken = "\"Device\",\"value\":\""; Then I've got a function that does said primitive parsing. string getPostedValue(string input, string searchToken) { int indexFrom, indexTo; string value=null; indexFrom = input.IndexOf(searchToken); if (indexFrom != -1) { indexFrom += searchToken.Length; indexTo = input.IndexOf('\"',indexFrom); value = input.Substring(indexFrom, indexTo - indexFrom); } return value; } I use it like this: request=getPostedValue(postedData, requestSearchToken); if (intentRequestName==request) { //parse the intent name intent = getPostedValue(postedData, intentSearchToken); switch (intent) { case "DeviceChangeIntent": ...do stuff... I should also mention that "postedData" is this (I clean up the posted input to get rid of newlines and whitespace): System.IO.StreamReader reader = new System.IO.StreamReader(Page.Request.InputStream); string postedData = Regex.Replace(reader.ReadToEnd(), @"^\s*$\n", string.Empty, RegexOptions.Multiline); I build a response with just using string concatenation. string buildSpeechletResponse(string title, string output, string repromptMessage, string shouldEndSession) { return "{\"version\":\"" +askVersion +"\",\"response\":" +"{\"outputSpeech\": {\"type\": \"" +speechType +"\",\"text\": \"" +output +"\"},\"card\": {\"type\": \"" +cardType +"\",\"title\": \"" +title +"\",\"content\": \"" +output +"\"},\"reprompt\": {\"outputSpeech\": {\"type\": \"" +speechType +"\",\n\t\t\t\"text\" : \"" +repromptMessage +"\"}},\"shouldEndSession\": \"" +shouldEndSession +"\"}}"; } So there you have it. Not the best or most refined way to do things, but it at least demonstrates that a skill can implemented in a primitive fashion, and that all that is required for a skill to interface really amounts to parsing and concatenating strings.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

cdburns123 avatar image
cdburns123 answered
When I try to go through your steps in your file, I end up with a Token error. When I try to just setup a proxy, I get this error: { "errorMessage": "Handler 'handler' missing on module 'index'" } I've looked in the index.js file and there is an - exports.handler = function (event, context)...etc. In my index.html file (just trying to have it there to test)...I have the index.js added in the page:
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

N. Fradkin avatar image
N. Fradkin answered
The instructions in the file are for installing the skill plug in on a HomeSeer system. You don't need to go through any of that. I was just posting it as an example of how you can just parse things yourself.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

cdburns123 avatar image
cdburns123 answered
Yeah, I was just going through the parts that I'd need to setup the proxy stuff and have it point to my server at home. I don't have homeseer, so I didn't copy all of that. Has anyone seen this error before? I even tried another example and getting the same error. Thanks
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.