Giter Club home page Giter Club logo

alexaskillskit.net's Introduction

AlexaSkillsKit.NET

.NET library to write Alexa skills that's interface-compatible with Amazon's AlexaSkillsKit for Java and matches that functionality:

  • handles the (de)serialization of Alexa requests & responses into easy-to-use object models
  • verifies authenticity of the request by validating its signature and timestamp
  • code-reviewed and vetted by Amazon (Alexa skills written using this library passed certification)
  • 🆕 supports following interfaces:

Beyond the functionality in Amazon's AlexaSkillsKit for Java, AlexaSkillsKit.NET:

This library was originally developed for and is in use at https://freebusy.io

This library is available as a NuGet package at https://www.nuget.org/packages/AlexaSkillsKit.NET/

How To Use

1. Set up your development environment

Read Getting started with Alexa App development for Amazon Echo using .NET on Windows

Note, that if you are hosting your API in Amazon Lambda, Azure Function, Azure Web App or other well-known cloud service, you can use parent domain certificate instead of providing your own.

2. Implement your skill as a "Speechlet"

If your Alexa skill does any kind of asynchronous I/O, it's recommended that you derive your app from the SpeechletBase class and implement these methods as defined by ISpeechletWithContextAsync:

public interface ISpeechletWithContextAsync
{
    Task<SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session, Context context);
    Task<SpeechletResponse> OnLaunchAsync(LaunchRequest launchRequest, Session session);
    Task OnSessionStartedAsync(SessionStartedRequest sessionStartedRequest, Session session);
    Task OnSessionEndedAsync(SessionEndedRequest sessionEndedRequest, Session session);
}

Alternatively, you can implement synchronous ISpeechletWithContext interface:

public interface ISpeechletWithContext
{
    SpeechletResponse OnIntent(IntentRequest intentRequest, Session session, Context context);
    SpeechletResponse OnLaunch(LaunchRequest launchRequest, Session session);
    void OnSessionStarted(SessionStartedRequest sessionStartedRequest, Session session);
    void OnSessionEnded(SessionEndedRequest sessionEndedRequest, Session session);
}

To handle external interface requests, your speechlet can implement additional interfaces either synchronous or asynchronous:

  • IAudioPlayerSpeechletAsync or IAudioPlayerSpeechlet for "AudioPlayer." and "PlaybackController." requests.
  • IDisplaySpeechletAsync or IDisplaySpeechlet for "Display.*" requests.

For backwards compatibility Speechlet and SpeechletAsync abstract classes are still available, along with deprecated ISpeechlet and ISpeechletAsync interfaces. Note, that old interfaces don't support Context object.

Take a look at https://github.com/AreYouFreeBusy/AlexaSkillsKit.NET/blob/master/AlexaSkillsKit.Sample/Speechlet/SampleSessionSpeechlet.cs for an example.

3. Wire-up "Speechlet" to HTTP hosting environment

The Sample app is using ASP.NET 4.5 WebApi 2 so wiring-up requests & responses from the HTTP hosting environment (i.e. ASP.NET 4.5) to the "Speechlet" is just a matter of writing a 2-line ApiController like this https://github.com/AreYouFreeBusy/AlexaSkillsKit.NET/blob/master/AlexaSkillsKit.Sample/Speechlet/AlexaController.cs

Note: sample project is generated from the ASP.NET 4.5 WebApi 2 template so it includes a lot of functionality that's not directly related to Alexa Speechlets, but it does make make for a complete Web API project.

Alternatively you can host your app and the AlexaSkillsKit.NET library in any other web service framework like ServiceStack.

How it works

SpeechletService class

To handle Alexa requests an instance of SpeechletService is used. This is the main entry point for all operations involved in handling incoming requests.

For convenience and backward compatibility both Speechlet and SpeechletAsync now derive from SpeechletBase base class, which provides built-in SpeechletService instance and wraps most common operations with it. Skill authors can access this internal SpeechletService through Service property, e.g. to register additional request handlers.

Parsing request

When new request is recieved, it first needs to be parced from json string into object model represented by SpeechletRequestEnvelope class. Task<SpeechletRequestEnvelope> SpeechletService.GetRequestAsync(string content, string chainUrl, string signature) method is used for this. Request headers and body validation also takes place during this step. The SpeechletValidationException is produced in case of any validation error.

See Override request validation policy for more details on request validation. Request validation can be omitted by directly calling one of SpeechletRequestEnvelope.FromJson static methods.

Only version "1.0" of Alexa Skill API is supported. Otherwise SpeechletValidationException with SpeechletRequestValidationResult.InvalidVersion is thrown. Same is true, when calling SpeechletRequestEnvelope.FromJson methods directly.

There are a lot of different request types available for Alexa Skills. Standard requests have simple type names: "LaunchRequest", "IntentRequest", "SessionEndedRequest". All other requests are related to specific interfaces and their request type name consists of interface name and request subtype name separated by "." sign, e.g. "System.ExceptionEncountered", "Dialog.Delegate" and so on.

SpeechletRequestParser class is used to deserialize request json field to appropriate subclass of SpeechletRequest base class. By default, it has no knowledge to which class each request type should be deserialized. SpeechletRequestParser has AddInterface method to bind interface name, with specific deserializagion handler.

SpeechletRequestEnvelope currently uses it's static instance of SpeechletRequestParser for request deserialization, provided as SpeechletRequestEnvelope.RequestParser static property. Use it, if you need to register deserialization method for additional request type.

Deserialization methods for all natively supported requests are registered internally by default.

Advanced

Override request validation policy

By default, requests with missing or invalid signatures, or with missing or too old timestamps, unsupported API version (only API v"1.0" is supported), are rejected. For Application Id to be validated, your skill needs to set value for SpeechletService.ApplicationId property. You can override the request validation policy if you'd like not to reject the request in certain conditions and/or to log validation failures.

/// <summary>
/// return true if you want request to be processed, otherwise false
/// </summary>
public override bool OnRequestValidation(
    SpeechletRequestValidationResult result, DateTime referenceTimeUtc, SpeechletRequestEnvelope requestEnvelope) 
{

    if (result != SpeechletRequestValidationResult.OK) 
    {
        if (result.HasFlag(SpeechletRequestValidationResult.NoSignatureHeader)) 
        {
            Debug.WriteLine("Alexa request is missing signature header, rejecting.");
            return false;
        }
        if (result.HasFlag(SpeechletRequestValidationResult.NoCertHeader)) 
        {
            Debug.WriteLine("Alexa request is missing certificate header, rejecting.");
            return false;
        }
        if (result.HasFlag(SpeechletRequestValidationResult.InvalidSignature)) 
        {
            Debug.WriteLine("Alexa request signature is invalid, rejecting.");
            return false;
        }
        else 
        {
            if (result.HasFlag(SpeechletRequestValidationResult.InvalidTimestamp)) 
            {
                var diff = referenceTimeUtc - requestEnvelope.Request.Timestamp;
                Debug.WriteLine("Alexa request timestamped '{0:0.00}' seconds ago making timestamp invalid, but continue processing.",
                    diff.TotalSeconds);
            }
            return true;
        }
    }
    else 
    {      
        var diff = referenceTimeUtc - requestEnvelope.Request.Timestamp;
        Debug.WriteLine("Alexa request timestamped '{0:0.00}' seconds ago.", diff.TotalSeconds);
        return true;
    }            
}

Credits

The original author of AlexaSkillsKit.NET is:

The current authors and maintainers are:

Thank You to library contributors (in alphbetical order):

Contributor License Agreement:
https://cla-assistant.io/AreYouFreeBusy/AlexaSkillsKit.NET

alexaskillskit.net's People

Contributors

chrispauly avatar elvenmonky avatar jasc01 avatar jaysonhelseth avatar jsvasani avatar leonmeijer avatar q3blend avatar shahab-a-k avatar stefann42 avatar teriansilva avatar valter479 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alexaskillskit.net's Issues

The remote endpoint could not be called

Hi @stefann42 thanks for the Lib. I just setup and published on the server but got the error below :
The remote endpoint could not be called, or the response it returned was invalid
can you tell me why this happened, i have set the interaction model with - JSon
#14 Intent Schema-

{ "intents": [ { "intent": "MyNameIsIntent", "slots": [ { "name": "Name", "type": "LITERAL" } ] }, { "intent": "WhatsMyNameIntent", "slots": [] } ] }

Sample Utterances

MyNameIsIntent my name is {john|Name} MyNameIsIntent my name is {sam brown|Name} WhatsMyNameIntent whats my name WhatsMyNameIntent what is my name WhatsMyNameIntent say my name WhatsMyNameIntent tell me my name WhatsMyNameIntent tell me what my name is

Service Response

The remote endpoint could not be called, or the response it returned was invalid.
Do you have any idea why this happened ?

Thanks.

Skill not validating signatures on incoming requests

We recently submitted our skill to Amazon for certification and they came back with:

"The skill end-point is not validating the signatures for incoming requests and is accepting requests with an incorrect certificate URL. Please make sure that your signature validation is correct. To reject an invalid request with an invalid signature or certificate, the skill should respond with HTTP status code 400 (Bad Request) in the response."

Any guidance on how to resolve this issue?

Thanks.

.Net Core implementation that works with Lambda Serverless?

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?

StackOverflowException on response when working with newer NewtonSoft.Json version

Hi @stefann42 ,
I started using your library and works fine. I use it with Azure as in the previous cases. I wanted to update the NewtonSoft.Json to the latest version and stopped working due to errors on the response.
Alexa says that "The remote endpoint could not be called..." but I found the real error cause.

I am debugging my azure app and I noticed that it fails when trying to serialize the object for the SpeechletResponseEnvelop.

//return JsonConvert.SerializeObject(this, SerializerSettings);

The error is about a StackOverflowException when attempting to serialize the object. Have you attempted to use the later NewtonSoft.Json version? if so, do you have any suggestions when using this newer version?

Thank you in advance

Our skill is failing at validating the signatures for incoming requests and is accepting requests with an empty signature URL

We are using this library for our custom Alexa skill, and we are very happy about how easy it was to develop the skill using it. Kudos to you guys!

However, the only thing that the Amazon certification team is failing us is the endpoint validation. This is the response we got from them:

These are the tests where your skill's back-end server is responding with HTTP Code 200 (OK) when we would expect to receive with HTTP Code 400 (Bad Request):

  • Empty signature
  • No signature header specified
  • Request signed with incorrect certificate
  • Request signed with invalid signature

We have made sure that the OnRequestValidation is returning false for invalid requests. So, my questions are:

  1. Has Amazon changed anything in their test suite for which this library hasn't been updated?
  2. How can we reproduce the tests that they are making, so we can fix the issue on our own?
  3. They told us that

Please note, that skills hosted on AWS Lambda have these security checks managed by Amazon automatically.

so, we are thinking of making a Lambda function that will act as a proxy to our Alexa API. Will this be acceptable to Amazon team and are there any downsides (besides the obvious increase in response time and costs)? We have passed the deadline, so we have to move forward with this solution in couple of days, because we're running out of options.

Thanks!

The skill responded with 500 HTTP status Code

I get this error message as soon as I ask Echo for my skill. "There was a problem with the requested skill's response". I see the following error on my Alexa App: The skill responded with 500 HTTP status Code

The error response is so fast that it seems like it is not even hitting my external web service end point.

please help
Sajjad

Device

how to get the deviceId

Use this Kit for an audio skill?

Hi,
Thank you so much for writing this kit. It has helped me a lot in my learning.
I would like to make a request. Is there a way you can write a sample that uses this kit to create an audio streaming skill? I would like to write my own skill that uses Alexa's new features for audio streaming but need some guidance and sample code.
https://developer.amazon.com/blogs/post/Tx1DSINBM8LUNHY/New-Alexa-Skills-Kit-ASK-Feature-Audio-Streaming-in-Alexa-Skills

Really appreciate your help
Sajjad

Account Linking

Hey Stefan
Thanks for this great library, I did 2 days ago my first step with it, and after some probing I was able to get it working :-)

Now I have a question, do you have a sample code how I can use account linking with your library?

Thanks
Martin

A number of bugs in the kit

The kit, as posted here has a number of bugs in the code. Is there a newer version somewhere, because this one is not functional?

I have fixed three bugs so far, and am still working on it.

Please add support for Address Information

I need to be able to access the user's address, and Amazon only added support for this recently in April 2017. https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/device-address-api

Namely, I need a way to access both device ID and consent Token in a launch request.
Please let me know if there's a way to do this because I can't find any such implementation in the project.

As stated, I need access, so please let me know if there is no implementation and no plans for implementation so I can migrate libraries.

Thank you

Required outbound calls?

Hi,

I've locally tested a AlexaSkillsKit.NET implementation and it's working fine. I've now deployed it to a staging server (publicly accessible) but it's failing (from Amazon) with an HTTP 500.

I did initially have deployment issues: I'd developed under .Net 4.6, but only 4.5.2 was available...should now be fixed.

I'm wondering if there's some internal authentication going on (or something) that requires an outbound call back to AWS.

All our hosted servers are in a very strict environment, and we have Egress Filters which will only allow approved out-bound traffic. I'm seeing 3 calls to 54.231.120.42/443 right after I initiate the Alexa test...but our filters are blocking them.

Is this the likely reason for the HTTP 500? Can you point me to where I can find the right list of IPs or DNS names to approve for outbound calls (that would be specific to an Alexa Skill)?

Given how often our sites are attacked from AWS hosted instances, we need to be very careful about what we open up to.

Thanks!

Seems in Testing, the Version is not sent making all calls fail

When using the Tester App through Amazon, it sends a request like so:

{
"session": {
"sessionId": "SessionId._",
"application": {
"applicationId": "amzn1.echo-sdk-ams.app._
_"
},
"user": {
"userId": "amzn1.echo-sdk-account.
__"
},
"new": true
},
"request": {
"type": "IntentRequest",
"requestId": "EdwRequestId._
**",
"timestamp": "2016-03-14T23:48:06Z",
"intent": {
"name": "MyBasicIntent",
"slots": {
"Name": {
"name": "Name",
"value": "john"
}
}
}
}
}

This does not have a version inside it, causing it to fail. Has version been removed (or deprecated) on amazon's side?

JSON serialization of responses with DialogElicitSlotDirective(s)?

Hello, I am playing around with dialog enabled skills, and the response sent by the library is:

{
  "version": "1.0",
  "response": {
    "outputSpeech": {
      "text": "yeeee",
      "type": "PlainText"
    },
    "speechletResponse": {
      "outputSpeech": {
        "text": "yeeee"
      },
      "directives": [
        {
          "slotToElicit": "City",
          "updatedIntent": { ... }
          }
        },
        {
          "template": {
            "title": {
              "richText": "<big>Test0</big>"
            },
            "backButtonBehavior": "VISIBLE"
          }
        }
      ],
      "shouldEndSession": false
    }
  },
  "sessionAttributes": {
    "StreetAddress": "--------------------",
    "intentSequence": "-----------------",
    "ConvoPath": "3",
  }
}

Whereas Amazon's documentation expects something like this:

{
  "version": "1.0",
  "sessionAttributes": {},
  "response": {
    "outputSpeech": {
      "type": "PlainText",
      "text": "From where did you want to start your trip?"
    },
    "shouldEndSession": false,
    "directives": [
      {
        "type": "Dialog.ElicitSlot",
        "slotToElicit": "fromCity",
        "updatedIntent": { ... }
        }
      }
    ]
  }
}

The directives array doesn't seem to be in the "response" object and each directive object doesn't appear to contain the 'Type' parameter which is listed as required.

Am I missing something? What I'm currently doing when the Intent is 'first hit' is to detect if a required slot is missing. If so, then return the following:

var x = new SpeechletResponse(); x.Directives = reprompts; return x;

Where reprompts is a list initialized with the single value:
reprompts.Add(new DialogElicitSlotDirective() { SlotToElicit = "City", UpdatedIntent = intent });

500 Error when invoking service request from Amazon test page

When sending an intent request from the Amazon developer test page, a 500 result occurs.

Looking at the exception, the failure is here (line 65 in SpeechletRequestEnvelope v 1.5.2):

return new SpeechletRequestEnvelope { Request = request, Session = Session.FromJson(json["session"].Value<JObject>()), Version = json["version"].Value<string>() };

The problem is the fact that the input json string does not include the version field. This, in spite of the fact that it is shown to be present in the test harness view of the Service Request. So it seems the test harness is just not sending it. Examination of the input request seems to bear this out.

It appears as though some parts of the library do handle a missing version value, except this portion does not.

The Amazon schema says the version field is always there, so it looks like this is a bug in Amazon's test harness. Perhaps the library could work around the omission in a safe way.

ProcessRequestAsync handles standard/extended backward

SpeechletService.ProcessRequestAsync()
has a check for determining standard/extended, which appears to be backward. I would expect this to be a 'not is' check:

        var response = (request is ExtendedSpeechletRequest) ?
            await HandleStandardRequestAsync(request, session, context) :
            await HandleExtendedRequestAsync(request as ExtendedSpeechletRequest, context);

How to handle AMAZON.Date in .NET

Hey Stefan, thanks for writing this library - it works great! Do you have any utility or library code in FreeBusy that handles parsing the ISO8601 date values coming in from the AVS when a slot is defined as of type AMAZON.Date? In some cases, the incoming string isn't parse-able to a DateTime or DateTimeOffset (for example, if I say "this weekend" the slot value comes in a "2016-W29-WE" which doesn't work with DateTime.TryParse(). Reading the docs on AMAZON.Date I see several formats that likely won't parse. Just wondering if there was a good mechanism for handling this in .NET, or if you just ended up parsing the incoming value for some known regex patterns. Thanks again for putting the time into creating this library!

HTTP 405 : Method Not Allowed

When using the Service Simulator in amazon's developer console portal I send a request and get the response:

There was an error calling the remote endpoint, which returned HTTP 405 : Method Not Allowed

Any ideas what is causing this to occur?

Does this repo have an admin?

Looks like this awesome project has stalled as the admin has vanished. Can they come back please? Or add admin rights to someone with more time/inclination to continue with this fine project?

This is awesome so...thanks

Ok so I've made 3 skills already hosted in azure app service with this. Have to admit this is awesome, used it because I have a ton of stuff in azure and didn't really want to use aws lambda.

So thanks for making this....

Sample code works with SessionResponse but not HttpResponseMessage

public HttpResponseMessage Post([FromBody] dynamic request)
{
return new SessionResponse
{
version = "1.0",
sessionAttributes = null,
response = new AlexaResponse
{
outputSpeech = new AlexaOutputSpeech
{
type = "PlainText",
text = $"The Price of {request} is 1"
},
shouldEndSession = true
}
};
}

This works, and returns what I expect....

    [Route("alexa/getme")]
    [HttpGet]
    public HttpResponseMessage SampleSession2()
    {
        var speechlet = new CoinbaseSkillSpeechlet();
        return speechlet.GetResponse(Request);
    }

Returns an error message of There was an error calling the remote endpoint, which returned HTTP 500 : Internal Server Error

I have the https crt set to "My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority" and I am running this on azure

Like i said, the first one, not using the AlexaSkillKit works....this one, using ASK doesnt.

Any help would be appreciated

Device id

How to find the device id... Programmatically. I didn't find context on this.

want to go from launchRequest to accepting an intentRequest.

Im connecting Alexa to Cognitive Codes SILVIA conversational AI. If I say "tell Silvia hello" it works great, SILVIA opens with a hello statement. But if I just say "use SILVIA", of course, it goes to launchRequest. structurally, I want it to execute intentRequest, not launchRequest. the problem is that the json coming from Alexa is marked as launchRequest.

Alexla custom skill-There was an error calling the remote endpoint, which returned HTTP 500 : Internal Server Error

I have created a custom skill set and have hosted it on Azure cloud. When I try to test my service request using developer portal, I get the following error, "There was an error calling the remote endpoint, which returned HTTP 500 : Internal Server Error"

I have Hosted my Alexa skill set endpoint in the sub-domain of azure. e.g. https://alexaforg3ms.azurewebsites.net/api/alexa/demo

For testing purposes when I try to send a request to the Alexa skill set end point through Fiddler, it gives me a status called - 415 {"Message":"The request contains an entity body but no Content-Type header. The inferred media type 'application/octet-stream' is not supported for this resource."}

Should I be using Lambda ?

Any help in this area would be appreciated.

Does this work in .NET Core 2.0?

This package won't install for me into a .NET Core 2.0 project in VS 2017. Is this known. I just get a vague "The given key was not present in the dictionary." error.

Doesn't validate certificate for incoming request (according to Cert team)

I'm using your library for my Alexa skill (great job on it btw!)

For the past several months, I've been working with the cert team to get my skill approved (this frustration is a topic for another day though). Through January, they would come back with requested changes to the behavior of the skill.

Since around mid-Feburary, Amazon has started rejected my attempts because they say that The skill does not validate the certificates for the incoming requests and is accepting requests with incorrect certificate. Please refer to the document that describes how to build your Alexa Skill as a web service I racked my brain about what I could have changed and finally blew away my full library and updated it again from virgin source (i.e, I've made no changes to it).

Again, I received a rejection saying the same thing. Has anyone else noticed this? Could Amazon have changed their process and made it incompatible with the current library per chance?

Finally, how would I go about testing this piece - is there a way to get Amazon to send me a bogus request that I can debug against?

Azure Functions issue?

I'm creating an Azure Function to act as a backend for an Alexa skill.

All I've done so far in Visual Studio:

  1. File -> New Azure Functions project
  2. Add new Azure Function
  3. Add AlexaSkillsKit.NET with NuGet
  4. Create a shell of a Speechlet implementation
  5. Add the minimum code to the Azure Function to process the speechlet

When I compile, I get an error:

Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0,
Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its
dependencies. The system cannot find the file specified.

But according to NuGet in Visual Studio, it's not trying to use 7.0.0.0, it's using 9+. I've tried updating and downgrading the JSON.net package. I've tried Clean/Rebuild/restarting from scratch.

I thought that maybe assembly binding might be the answer, but there's no Web.config or App.config in an Azure Functions project.

What am I missing? How do I get rid of this error?

Speechlet code:

public class MySpeechlet : SpeechletBase, ISpeechletWithContextAsync
{
    public Task<SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session, Context context)
    {
        throw new System.NotImplementedException();
    }

    public Task<SpeechletResponse> OnLaunchAsync(LaunchRequest launchRequest, Session session, Context context)
    {
        throw new System.NotImplementedException();
    }

    public Task OnSessionStartedAsync(SessionStartedRequest sessionStartedRequest, Session session, Context context)
    {
        throw new System.NotImplementedException();
    }

    public Task OnSessionEndedAsync(SessionEndedRequest sessionEndedRequest, Session session, Context context)
    {
        throw new System.NotImplementedException();
    }
}

Azure Function:

public static class MyFunction
{
    [FunctionName("MyFunction")]
    public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
    {
        var speechlet = new MySpeechlet();
        return await speechlet.GetResponseAsync(req);
    }
}

I think this may be an issue with the Azure Functions SDK, but is there some way to workaround it?

Request object NULL

Hi @stefann42 , thanks for your tip.
What I am trying to do actually is using your API with the following method:

[HttpPost, Route("api/alexa/tombolina")]
public dynamic Tombolina(AlexaRequest alexaRequest)
{
AlexaResponse response = null;

    var speechlet = new SessionSpeechLet();
    HttpResponseMessage check = null;

    try
    {
        check = speechlet.GetResponse(Request);
    }
    catch(Exception ex)
    {
        check = new HttpResponseMessage(HttpStatusCode.Conflict);
    }

    if (check.StatusCode.Equals(HttpStatusCode.OK))
    {
        Request request = new Data.Request();
        request.MemberId = (alexaRequest.Session.Attributes == null) ? 0 : alexaRequest.Session.Attributes.MemberId;
        request.Timestamp = alexaRequest.Request.Timestamp;
        request.Intent = (alexaRequest.Request.Intent == null) ? "" : alexaRequest.Request.Intent.Name;
        request.AppId = alexaRequest.Session.Application.ApplicationId;
        request.RequestId = alexaRequest.Request.RequestId;
        request.SessionId = alexaRequest.Session.SessionId;
        request.UserId = alexaRequest.Session.User.UserId;
        request.IsNew = alexaRequest.Session.New;
        request.Version = alexaRequest.Version;
        request.Type = alexaRequest.Request.Type;
        request.Reason = alexaRequest.Request.Reason;
        request.SlotsList = alexaRequest.Request.Intent.GetSlots();
        request.DateCreated = DateTime.UtcNow;

        switch (request.Type)
        {
            case "LaunchRequest":
                response = LaunchRequestHandler(request);

                break;
            case "IntentRequest":
                response = IntentRequestHandler(request);

                break;
            case "SessionEndedRequest":
                response = SessionEndedRequestHandler(request);

                break;
        }

        return response;
    }
    else
        return new HttpResponseMessage(HttpStatusCode.BadRequest);
}

Thing is the following line is failing:

check = speechlet.GetResponse(Request);

Because the Request object is NULL, could you please help me to understand why?

Reprompt

This does not seem to be available?
Anyone have an example using this library?

Thanks

Alexla custom skill - There was an error calling the remote endpoint, which returned HTTP 400

I'm new to Alexa and I have created a custom skill set and have hosted it on Azure cloud. When I try to test my service request using developer portal, I get the following error,

There was an error calling the remote endpoint, which returned HTTP 400 : OK

Few things to note:

    1. I have a trusted SSL certificate issued by GoDaddy (Only covers my main domain and not sub-domains)
    1. I have Hosted my Alexa skill set endpoint in the main domain and NOT sub-domain. e.g. https://brandsmacker.com/api/Alexa/sample-session
    1. For testing purposes when I try to send a request to the Alexa skill set end point through PostMan, it gives me a status called - 400 NoSignatureHeader, NoCertHeader

Appreciate if someone can help me to figure out the problem.

Awaiting null conditional operations

SpeechletService.HandleStandardRequestAsync()
performs casting to all the interfaces to find the right one to call the request type handler.

but await (null)?.DoAsync() does not work
dotnet/roslyn#7171

I just want to make sure it is not a problem in the way I am calling it, so am testing a fix now.

The Card class does not have a Content or Image property

The Card class property of the SpeechletResponse only has Title and SubTitle properties.

How can one add content and images to the card. The sample project also does not seem to utilise the Card feature.

Please inform if the Card response is fully implemented in this libarary.

I have used the basic intent, session and SpeechletResponse classes and these work well. Thanks for this easy to use library.

Running the Speechlet sample

Hi,

I'm trying to run the Speeclet sample but I am wondering, how can I test this with Alexa with this running locally (localhost with port) on my machine?

ExtendedSpeechletRequest doesn't include the session variable

Is there a reason that the handlers for ExtendedSpeechletRequest don't get passed the session object? We have an echo show app and want to handle the point in the conversation where the user touches the screen, but don't have access to the session history. The session is in the raw JSON request, and it looks like in your SpeechletSession.cs you have it, but aren't passing it to the ExtendedSpeechletRequest handler.

EchoShow - display.TemplateVersion

ElvenMonky or anyone.

Based on the new code you have put together... I realize its not been completely merged, but I am trying to use it.
Wondering if you could provide c# example of using context to get the Display templateversion value ... is 1 if display is supported.

Trying using your new code and receive a null?

If I do something like... it works fine.
But I would like to use the defined objects

JObject contextJObject = JObject.Parse(context.ToString());

        string tmpVersion = (string)requestJsonContext["System"]["Device"]["SupportedInterfaces"]["Display"]["TemplateVersion"];

Can someone tell me the most efficient way to do this?

public override SpeechletResponse OnIntent(IntentRequest request, Session session, Context context)
{

        JObject requestJsonContext = JObject.FromObject(context);

        JObject requestSystem = requestJsonContext["System"].Value<JObject>();

        JObject requestDevice = requestSystem["Device"].Value<JObject>();

        JObject requestSupportedInterfaces = requestDevice["SupportedInterfaces"].Value<JObject>();

        JObject requestDisplay = requestSupportedInterfaces["Display"].Value<JObject>();

       DisplayInterface display = DisplayInterface.FromJson(requestDevice);  //gives NULL

Thanks in advance, Peter

Exceeded max response size

Hi,

I have a skill built using the Nuget package v1.5.2 which is giving me this error in the card in the Android app. The detail in the card says "The skill's response exceeded the maximum response size of 24576 bytes."

The verbal response I get from Alexa is "There was a problem with the requested skills response" and Amazon's test page says "The remote endpoint could not be called, or the response it returned was invalid."

The skill is deployed in Azure so I can't use Fiddler to sniff the actual response.

However, this same skill will return other responses validly (perhaps coincidentally when they also don't also end the session).

Any ideas?

Possibility of adding OnLaunch breadcrumb to IntentSequence?

Hello - I have been moving my Alexa skill away from my own custom .NET "plumbing" code and have found your library very easy to work with so far.

My only wish would be for OnLaunch to automatically add a breadcrumb to Session.IntentSequence. There of course other ways I am able to determine if a skill has been interacted with via OnLaunch, but I would love to have something as elegant as simply having it in IntentSequence :)

Add locale to Requests

Hi,

I noticed that the locale property is missing from the requests.

The Java version has a commit for it, would it be possible to add this to the requests in AlexaSkillsKit.NET?

For comparison:
KayLerch/alexa-skills-kit-java@7784d0f

Thank you for letting us use your hard work guys!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.