Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net Core implementation that works with Lambda Serverless? #20

Open
BenTMatthews opened this issue Jan 22, 2017 · 40 comments
Open

.Net Core implementation that works with Lambda Serverless? #20

BenTMatthews opened this issue Jan 22, 2017 · 40 comments

Comments

@BenTMatthews
Copy link

One of the big selling points for the ease of Alexa dev is how easy (and cheap) it integrates with lambda. Also some orgs are moving to Core as it becomes more stable. Any future plans to have this work with .Net Core for those easy Lambda projects?

@MaxHorstmann
Copy link

+1 would be great to get this to work with the recently added C# support in Lambda

@goldfishrock
Copy link

Another +1. I've been using the Slight.Alexa version thats been ported to Core... but it's incomplete at the moment.

@tonysurma
Copy link

I have a .Net core (netstandard) port of this in a fork that initially is working for me but I will test further before declaring success beyond It works on my machine ™️ - I will also verify it works in core on Azure and AWS Lambda

@tonysurma
Copy link

verified it is working on azure just now, up next AWS Lambda verification (but if it works on .net core it should on another)

@szymczakk
Copy link

@tonysurma I couldn't find any nuget feed with your version of this lib (for .net core) so I allowed myself to create one: https://www.myget.org/feed/ami/package/nuget/AlexaSkillsKit.Net (if any of you need it, you can reference it). Quite useful, because local dll can't be referenced in easy way in VSCode.

@stefann42
Copy link
Member

@szymczakk Happy to amend the "official" NUGet package definition so it can be used from .NET Core if you can educate me a bit about what I need to do. (My head is still on .NET Framework 4.6 and I haven't had time to learn about porting stuff to .NET Core.) Is the package definition you published on MyGet available somewhere for me to look at?

@tonysurma
Copy link

tonysurma commented Apr 18, 2017

@stefann42 yes it is! I moved the version to 1.6 (no reason other than it needed to be a different version. in .NET Core it comes from the csproj now so you can see the details here (I literally copied over what you had done from the nuspec to the csproj).

I also chose the right netstandard so it will work with .NET Core and the version of .NET Framework you had previously targeted so it is compatible and should work without change in existing .NET 4.6 deployments.

The changes are all in the fork I made and I strove to make each commit 'small' so it documented the porting. Happy to help however I can and if you would like it I can make a PR with these changes and anything else you would need to convert.

@tonysurma
Copy link

thank you @szymczakk for posting that. I hadn't gotten to that step yet. I had been using a custom nuget feed entry that pointed to a local folder where I had the package (simple but it worked for me)

@szymczakk
Copy link

@tonysurma How did you handle the request? When I create API project, and in controller get the Request it's type Microsoft.AspNetCore.Http.HttpRequest and Speechlet in method GetResponse require System.Net.Http.HttpRequestMessage and I don't know how to convert it. I was thinking about rewriting GetRespose method to use request from .net Core, what do you think?

@tonysurma
Copy link

tonysurma commented Apr 19, 2017

@szymczakk I made a SampleCore project here to demonstrate that and included commit(s) that showed each step to 'upgrade' the Sample to Core. The trick for that I recall is including WebApiCompatShim which allows you to inherit from ApiController and aligns to the types expected by the Speechlet API

I did that as it was the quickest/most direct port and figured most folks aren't putting Alexa into another controller so shouldn't be an issue.

I was also thinking of adding another GetResponse method/overload to adapt to the .net core approach but recall there were some items that the Speechlet wanted that would be a bit messy to get.

@szymczakk
Copy link

szymczakk commented Apr 19, 2017

@tonysurma sory for bothering you, but have another question, can you look here and see what do I do wrong? By wrong I mean

The remote endpoint could not be called, or the response it returned was invalid.

as an response from service simulator in Skill config console on AWS. I got request, but response that I send to Alexa is invalid 😢

@tonysurma
Copy link

@szymczakk no worries, I will try to look at that a bit later. Can you see the response you are sending from your code and are you sure you got called? I ask only as I have gotten that error when tunneling or some other url issue was the cause.

@szymczakk
Copy link

@tonysurma Yep, Im 100% sure that my server is called, because I'm attached with debugger to it, and see everything is happening. I will try to catch my whole response with Fiddler and show you ;)

@tonysurma
Copy link

got it @szymczakk - just looked through the code and nothing stood out (looked at startup, controller, speechlet) and all looks good with no gotchas.
I also reverified my deployment with this version is working as well as made a quick simple one and it worked for me. Curious what the response is that it doesn't like. Sorry I couldn't be more helpful (yet)

@szymczakk
Copy link

@tonysurma Thats weird. I'm unable to capture my trafic with Fiddler, but I can stop execution by debugger (so my local server is called). How did you configure your server? Do you use IIS? How about certificate? Slefsigned or trusted? And do you have static IP address or you use some DynDNS (like no-ip etc) ?

@tonysurma
Copy link

It's been a bit since I did the self hosting (I do updates now to deployed instances in Azure App Service websites) but I recall following this guide. I recall getting tripped up a couple of time and used this guide and another I can't find right now. Eventually I went to just using the site on azure and logging and other mechanisms as it was faster (especially since I tend to dev on combination of desk pc and a couple of laptops). Sorry I don't have any more insights there

@szymczakk
Copy link

szymczakk commented Apr 20, 2017

@tonysurma Ok, I found the response:

{"endpointRegion":"EU","text":"hello","applicationId":"","locale":"en_US","session":null}

I wanted to send hello as a response from this intent

PS. Dont know if its important: oryginal data are

%7B%22endpointRegion%22%3A%22EU%22%2C%22text%22%3A%22hello%22%2C%22applicationId%22%3A%22%22locale%22%3A%22en_US%22%2C%22session%22%3Anull%7D

and you have to decode it to make it readable.

@tonysurma
Copy link

hmmm, let me look and compare - hopefully there is something there

@szymczakk
Copy link

@tonysurma I compared it with amazon specification and it's problem with respone :/ Ehhh... have to figure it out somehow 😉

@tonysurma
Copy link

gotcha - yeah.

My response from an app on the same build of the framework looks like this (removing a few specific bits)

{ "version": "1.0", "response": { "outputSpeech": { "type": "PlainText", "text": "My content" }, "shouldEndSession": true }, "sessionAttributes": { "intentSequence": "MyIntentId" } }

Definitely looks like stuff is missing in the response building.

@szymczakk
Copy link

szymczakk commented Apr 23, 2017

Hey @tonysurma ! Sory for taking it so long, but have some more info, maybe you will know how to handle it. When I debug the request it shows that the response that is generated by code is

{"response":{"card":{"type":"Simple","content":"SessionSpeechlet - Hello","title":"SessionSpeechlet - Title","subtitle":"SessionSpeechlet - Sub Title"},"outputSpeech":{"type":"PlainText","text":"Hello"},"shouldEndSession":true},"sessionAttributes":{"intentSequence":"HelloWorldIntent"},"version":"1.0"}

but when I finally cought the correct resposne that is sent by server it turns out that the body of response is

{
"version": {
"major": 1,
"minor": 1,
"build": -1,
"revision": -1,
"majorRevision": -1,
"minorRevision": -1
},
"content": {
"headers": [
{
"key": "Content-Type",
"value": [
"application/json; charset=utf-8"
]
}
]
},
"statusCode": 200,
"reasonPhrase": "OK",
"headers": [],
"requestMessage": null,
"isSuccessStatusCode": true
}

I run dotnet core in kestrel and then host it on IIS on windows 10. Do you have any idea why do I got such resposne?

@tonysurma
Copy link

Sorry but unfortunately I do not. It looks to be like it's encoding the http response itself in json which is strange and i've never seen before myself.

@szymczakk
Copy link

szymczakk commented Apr 25, 2017

Hey @tonysurma, look what I found. And this link is explaining why it wasn't working. But funny case is that your code works for you, but you don't have this function in your source. After adding

.AddWebApiConventions();

after UseMvc it starts to work.

@tonysurma
Copy link

Interesting, great find. I will take a look. Might be an omission from the sample project I had in my test and production projects... thanks

@tonysurma
Copy link

Thanks again @szymczakk I had that edit in each of my projects and missed it in the SampleCore project as I never 'directly' ran the sample. I was using the SampleCore project as the basis for my projects to test and run and forgot to 'back port' that line into the sample. I pushed this now.

@JustMaier
Copy link

Hey @tonysurma and @stefann42 any chance we could still get this merged and published to nuget? Now that we've got .net core 2.0, it'd be great to get .net core support.

@tonysurma
Copy link

@JustMaier if @stefann42 is open to it, I can update/test my fork with netstandard 2 to ready it for merge

@stefann42
Copy link
Member

@tonysurma By all means. I'm happy to accept the PR, just let me know if I need to be aware of any specifics. We don't yet use .NET Core in our production deployment so I don't have an environment to test myself.

@ElvenMonky
Copy link
Collaborator

ElvenMonky commented Dec 12, 2017

Now, when interfaces support is merged, I believe .Net Core support is our major priority. @tonysurma changes in your fork looks great to me. Could you, please, create a PR with your changes, so that we can include .Net Core support to the nearest library release? Just tell if you need any help in preparing PR or merging with latest changes.

@ElvenMonky
Copy link
Collaborator

One thing to note. Current library is compatible with VS2012 for both Speechlet authors and AlexaSkillsKit.Net contributors. .Net Standard version will require .Net Core1.x SDK and VS 2017 or VS Code for development. @stefann42 are you ready for these kind of changes in our development environment?

For Speechlet authors we can provide multitargeting NuGet package, ofcourse.

@stefann42
Copy link
Member

stefann42 commented Dec 19, 2017 via email

@ElvenMonky
Copy link
Collaborator

I have slightly different proposal, which I've tried to describe in newly created wiki Roadmap document.

@stefann42
Copy link
Member

@ElvenMonky Love the Roadmap! Let's have an online meeting together next week (between Christmas and New Year's) and discuss merged PRs and strategy for moving forward. Please see https://freebusy.link/stefan for my availability and to schedule the meeting.

@tonysurma
Copy link

thanks @ElvenMonky for noting two issues with my fork. I just addressed those and will also bring it up to date with this repository recent commits. Happy to help as you all decide on how to address .net core 2

@ElvenMonky
Copy link
Collaborator

ElvenMonky commented Dec 26, 2017

Well. currently I think we can drop VS 2012 support, after already implemented code is released.
@stefann42 Probably I'll reschedule for your 27th evening (my 28th morning).
P.S.: Is it only me recieving meeting notifications from your service?

@ElvenMonky
Copy link
Collaborator

@tonysurma we created separate branch for .Net Framework version. Please, feel free to create PR into the master branch with your changes related to .Net Standard/.Net Core support.

@brandonh-msft
Copy link

the myget URL posted above doesn't work. Is it still alive?

[ask.net myget] 'doctype' is an unexpected token. The expected token is 'DOCTYPE'. Line 1, position 3.

in VS 2017.15.6.6

@szymczakk
Copy link

@brandonh-msft Do you mean this one https://www.myget.org/feed/ami/package/nuget/AlexaSkillsKit.Net/1.7.0 ?? This one is still working (just checked it)

@UkeHa
Copy link

UkeHa commented Nov 4, 2018

is this branch still alive? The Java version seems a lot more active.

@ElvenMonky
Copy link
Collaborator

Development in this repository is inactive since January 2018. It seems nobody is interested.
This is a 3rd party library, while Java version is supported officially by Amazon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants