GithubHelp home page GithubHelp logo

timheuer / alexa-skills-dotnet Goto Github PK

View Code? Open in Web Editor NEW
548.0 548.0 108.0 608 KB

An Amazon Alexa Skills SDK for .NET

License: MIT License

C# 99.57% Dockerfile 0.43%
alexa alexa-skills-sdk aws-lambda dotnet dotnet-core dotnet-library dotnet-standard dotnetcore intent skills sml

alexa-skills-dotnet's Introduction

alexa-skills-dotnet's People

Contributors

aadupirn avatar adriangodong avatar allcontributors[bot] avatar bcuff avatar fuzzysb avatar icanbenchurcat avatar matthiasxc avatar mteheran avatar peterfoot avatar rdlaitila avatar shinya-terasaki avatar socsieng avatar stenmannsar avatar stoiveyp avatar techpreacher avatar timheuer avatar tobiasviehweger avatar vinaykapadia avatar yadavvineet 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

alexa-skills-dotnet's Issues

audio response for a specifc intent

I created a skill and I want to give an audio response for an intent.
Here is the part of my code SkillResponse = ResponseBuilder.AudioPlayerPlay(PlayBehavior.ReplaceAll,
"https://matthiasshapiro.com/alexasamples/First.mp3",
"");
and second version that I tried:

var speech = new SsmlOutputSpeech();
speech.Ssml = "https://matthiasshapiro.com/alexasamples/First.mp3";
returnResponse = ResponseBuilder.Tell(speech);

return SkillResponse;
but in the Logs I am getting these error :
Cannot write a null value for property 'version'. Property requires a value. Path ''.: JsonSerializationException
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
at Amazon.Lambda.Serialization.Json.JsonSerializer.Serialize[T](T response, Stream responseStream)
at lambda_method(Closure , Stream , Stream , ContextInfo )

I tried to use Build a simple voice response - from https://github.com/timheuer/alexa-skills-dotnet.

I really want to manege to create an audio response in C#. Thank you

PlaybackFinished returns PlaybackStarted

In Request/Type/AudioPlayerRequest.cs there it shows:

case "PlaybackStarted":
    return AudioRequestType.PlaybackStarted;
case "PlaybackFinished":
    return AudioRequestType.PlaybackStarted;

Shouldn't the PlaybackFinished case return AudioRequestType.PlaybackFinished instead?

Model Binding for ASP.net MVC 5 controller?

I have an ASP.Net MVC 5 application with a controller method I'm using to handle incoming Alexa requests. Thought this library looked promising to automatically bind to the request but I'm not having any luck. Am I doing something wrong here or trying to use this for something it wasn't made for?

using Alexa.NET.Request;

     [HttpPost]
        [AllowAnonymous]
        public dynamic Alexa(SkillRequest input)
        {

            Debug.Write(input.Request.Type);

            return JsonConvert.SerializeObject(new {Data="blah"});
        }

When I hit the endpoint with standard Json from Alexa I can't parse the input and either get null for input or errors like the one below.. Thanks for the help.


<!DOCTYPE html>
<html>
    <head>
        <title>Cannot create an abstract class.</title>
        <meta name="viewport" content="width=device-width" />
        <style>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}

audio format for dotnet skill

In the exemple that you provide me
public SkillResponse FunctionHandler(SkillRequest input, ILambdaContext context)
{
return ResponseBuilder.AudioPlayerPlay(PlayBehavior.ReplaceAll,
"https://matthiasshapiro.com/alexasamples/First.mp3",
"testToken");
}
I put my Url https://s3-eu-west-1.amazonaws.com/c92c7d48/congratulations.mp3
and I don't receive the audio response as I get using your Url.( I modified its format using audacity https://developer.amazon.com/docs/custom-skills/speech-synthesis-markup-language-ssml-reference.html#h3_converting_mp3)
do you make other changes to the original audio?
My format and hosting appear to be correct because in java skill is working but I need it in C# too :(
One more question, if i want to create in the SAME response audio and Text what should I do?
thank you
(the original sound is https://www.youtube.com/watch?v=sjmkyYyWdzM )

ElicitSlot causing SessionEnded

Hello,
using the below code causes the intent to return SessionEnded and I never get prompted for the Slot

var speech = new Alexa.NET.Response.SsmlOutputSpeech();
                                log.LogLine($"INFO: Prompting for Companies");
                                speech.Ssml = "<speak>Which company would you like to switch to? State the sequence number of your selection<break strength='medium' /></speak>";


                                int i = 0;
                                foreach (var key in companies)
                                {
                                    speech.Ssml += $"{i} <break strength='medium' />{key.Value},";
                                    i++;
                                }
                                log.LogLine("INFO: Firing Elicit Response");
                                r = ResponseBuilder.DialogElicitSlot(speech, "CompanyName", intent.Intent);

The JSON in the logs looks correct

{
    "version": "1.0",
    "response": {
        "outputSpeech": {
            "type": "SSML",
            "ssml": "<speak>Which company would you like to switch to? State the sequence number of your selection<break strength='medium' /></speak>0 <break strength='medium' />Six S Partners Inc.,1 <break strength='medium' />Six S Partners LLC,"
        },
        "reprompt": {
            "outputSpeech": {
                "type": "PlainText",
                "text": "For a list of available commands say, Help!. What can I help you with?"
            }
        },
        "shouldEndSession": false,
        "directives": [
            {
                "type": "Dialog.ElicitSlot",
                "slotToElicit": "CompanyName",
                "updatedIntent": {
                    "name": "SwitchCompany",
                    "confirmationStatus": "NONE",
                    "slots": {
                        "CompanyName": {
                            "name": "CompanyName",
                            "value": null,
                            "confirmationStatus": "NONE"
                        }
                    }
                }
            }
        ]
    }
}

Any ideas?

Progressive Response

Hi,

are there any plans to support "Progressive Response" in your library?

br
martin

Session end abstracted away?

After digging through the project, which I appreciate a lot, it seems that session end was abstracted away from the ResponseBuilder and set to true in all of the private functions. Was this on purpose for some reason? New to coding on Alexa, but this seems like something that should be available to the public functions.

Appveyor isn't running tests

There are ~70 tests in Alexa.NET.Tests, but they're not run on generation of a PR request, so a breaking change might be missed.

By changing the value of the Appveyor test section to Script, and the parameters to CMD you can then run:

dotnet test .\Alexa.NET.Tests

which should negate this risk

Always get Forbidden when trying to get address

I am always getting the Forbidden status returned when i try to the get the users full address. I have checked that permission has been granted via the Alexa app and I can see the blue tick against device address and my address has been entered.

Here is my code, am i misusing the api?

if (request.GetRequestType() == typeof(LaunchRequest))
{
	string apiAccessToken = request.Context.System.ApiAccessToken;
	string deviceId = request.Context.System.Device.DeviceID;
	string apiEndpoint = request.Context.System.ApiEndpoint;
	AddressResponse address = null;
	HttpStatusCode statusCode = DeviceAddressService.GetAddress(apiEndpoint, deviceId, apiAccessToken, out address);

	// 

}


public static HttpStatusCode GetAddress(string apiEndpoint, string deviceId, string apiAccessToken, out AddressResponse response)
{
	string uri = $"{apiEndpoint}/v1/devices/{deviceId}/settings/address";
	RestClient client = new RestClient(uri);
	RestRequest request = new RestRequest { RequestFormat = DataFormat.Json };
	request.AddHeader("Authorization", "Bearer " + apiAccessToken);

	IRestResponse<AddressResponse> addressResponse = client.Execute<AddressResponse>(request);
	response = addressResponse.Data;

	if (addressResponse.StatusCode == HttpStatusCode.Forbidden)
	{
		// permission to access address has not been granted
		return HttpStatusCode.Forbidden;
	}

	return HttpStatusCode.OK;
}

Example Project

Does anyone have a complete sample project using this library with a C# Web API project?

Cheers!

Peter

Error in Alexa Service Simulator

Hi, I created a simple skill using the alexa-skills-dotnet package and when I test my Lambda function in Lambda directly I get the response I'd expect. When I test the skill from the Alexa Service Simulator I get the following error:

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

Any idea what could be the issue? For reference, the response I get when I test in Lambda directly is:

{
  "version": "1.0",
  "response": {
    "outputSpeech": {
      "type": "SSML",
      "ssml": "The goal of this is to test my Alexa skill!"
    },
    "card": {
      "type": "Simple",
      "title": "Test Skill Goal",
      "content": "The goal of this is to test my Alexa skill!"
    },
    "shouldEndSession": true
  }
}

Echo Show

Any samples for using this for Body and List Templates?
Showing Action on Body Template and retrieving the Display.ElementSelected?

Thanks!

Pulling open pull requests into Alpha

We currently have three open pull requests ( #32, #35, #44 ) which adds/enhances functionality for the package. Would it be possible to look at moving these into an Alpha release so that areas such as the Display interface could be more easily explored by users?

(apologies for the double-post, my finger slipped on the return key while I was typing)

I cant get slot information

I cant get slot information using something like this.
var firstValue = intentRequest.Intent.Slots["FirstSlot"].Value;
seems pretty simple. Slot is created on the right intent and I am inside the right intent already.
Any ideas?

Documentation & certificate checking

Are there any more examples apart from those in the read.me, for example, does it handle the certificate checking needed if you host your own web service?

The response is invalid

I keep getting this error when I test from Alexa: The response is invalid

I deploy the lambda function and works fine with the test functionality on AWS.
When I plug it to custom skill in Alexa, I always get the error "The response is invalid"
I look at the logs of the lambda function and the request is received correctly, the input parameters are identified and the processing is correct.

I wonder if the response format is not what it's expected. Have you had any issue like this?

Any help would be welcome!

.Net Framework 4.5 version

First, thank you very much for your efforts in implementing and maintaining this library.
It would be great if there also was a version for old school .Net Framework.

I found this can easily be achieved by replacing
<TargetFramework>netstandard1.6</TargetFramework>
with
<TargetFrameworks>netstandard1.6;net45</TargetFrameworks>
in Alexa.NET.csproj. Turns out both versions get built and packed in .nupkg without any additional changes.

In fact, I'll go and submit a PR for this.

Session problems

I'm struggling to pass session data through my skill. My skill is a basic company receptionist. You can "tell the company receptionist Homer Simpson is here to see Montgomery Burns." When the user passes both intent slots {Employee} and {Visitor} everything works.

The problem is I want to allow users to be prompted for additional information if they forget one of the slots. Below is the intent slots JSON. again, if both slots are populated, no problem.
"intent": { "name": "VisitorArrived", "slots": { "Employee": { "name": "Employee", "value": "Monty burns" }, "Visitor": { "name": "Visitor", "value": null } } }

in my skill, I'm using Alexa.NET 1.4.2 (latest per nuget). In my code that handles the "VisitorArrived" intent I have the following code trying to look in the request first, and session second for the two slots' data.

`//try to get the Employee from the request
try {
if (intentRequest.Intent.Slots["Employee"].Value.Length > 0) {
employee = intentRequest.Intent.Slots["Employee"].Value;
skillResponse.SessionAttributes["Employee"] = employee;
}
} catch {
log.LogLine("Employee wasn't included in the request.");
//try to get Employee from the session
try {
if (input.Session.Attributes["Employee"].ToString().Length > 0)
employee = input.Session.Attributes["Employee"].ToString();
} catch {
log.LogLine("Employee wasn't included in the session.");
}
}
//try to get the Visitor from the request
try {
if (intentRequest.Intent.Slots["Visitor"].Value.Length > 0) {
visitor = intentRequest.Intent.Slots["Visitor"].Value;
skillResponse.SessionAttributes["Visitor"] = visitor;
}
} catch {
log.LogLine("Visitor wasn't included in the request.");
//try to get Visitor from the session
try {
if(input.Session.Attributes["Visitor"].ToString().Length > 0)
visitor = input.Session.Attributes["Visitor"].ToString();
} catch {
log.LogLine("Visitor wasn't included in the session.");
}
}

                    log.LogLine("Employee: " + employee);
                    log.LogLine("Visitor: " + visitor);`

It never seems to save the data to the session, or pull it from the session on the next request. I feel like I'm missing something simple. Any advice would be greatly appreciated!

Asking for additional infos

I have a design problem and I don't know how to solve them yet.
These two questions are done by the Dialog Model and work pretty good so far:

Me: Alexa, tell Fruit Vendor I want to buy fruits?
Alexa: Which city are you in?
Me: Amsterdam
Alexa: When do you want to come to get them?
Me: Tommorow.

With this information I can query my DB and get back some fruits.
After that I would like give the user a choice between those fruits from my DB?

Alexa: We have a selection in stock. 1. Apples, 2. Tomatoes, 3. Bananas. Select the number of the fruit you want to buy?
Me: Number 1.
Alexa: How much apples you would like to buy?
Me: Two
Alexa: Okay, I reserved two Apples for you.

How can I do that? I would like to avoid multiple intends, if this is even possible in a single one.
Is there something like a Ellicit with a custom prompt?

StandardCard no content

try to create a StandardCard with the following code
var cardImages = new CardImage { LargeImageUrl = "https://s3-eu-west-1.amazonaws.com/myimageurl.png", SmallImageUrl = "https://s3-eu-west-1.amazonaws.com/myimageurl.png" }; var card = new StandardCard { Title = resource.SkillName, Content = "This is a test", Image = cardImages }; response.Response.Card = card;

The image and title is shown, but content is empty

How do you do multi turn dialogs?

I am unable to figure out how to do multi turn dialogs. If I have 4 slots defined and the user only passes 2 values, I need to delegate slot collection back to Alexa. The documentation says return a Dialog.Delegate but I am not exactly sure what that means.

Here is what I tried but it doesn't work.

        public SkillResponse FunctionHandler(SkillRequest input, ILambdaContext context)
        {

            var requestType = input.GetRequestType();
            if (requestType == typeof(IntentRequest))
            {
                var intentRequest = input.Request as IntentRequest;

                // The intentRequest variable here is the IntentRequest object sent to the skill.
                if (intentRequest.DialogState == DialogState.Started)
                {
                    // Pre-fill slots: update the intent object with slot values for which
                    // you have defaults, then return Dialog.Delegate with this updated intent
                    // in the updatedIntent property.
                    return ResponseBuilder.DialogDelegate(input.Session);
                }
                else if (intentRequest.DialogState != DialogState.Completed)
                {
                    return ResponseBuilder.DialogDelegate(input.Session);
                    // return a Dialog.Delegate directive with no updatedIntent property.
                }
                else
                {
                    // Dialog is now complete and all required slots should be filled,
                    // so call your normal intent handler. 
                    var location = intentRequest.Intent.Slots["Location"].Value;
                        return MakeSkillResponse(
                            $"Do blah blah in {location}",
                            true);
                }

            }
            else
            {
                return MakeSkillResponse(
                        $"I don't know how to handle this intent. Please say something like Alexa, ask {INVOCATION_NAME} blah blah",
                        true);
            }
        }

System.ExceptionEncountered: SpeechletResponse was null

Apparently Alexa expects {} for empty responses (e.g. responses to AudioPlayer requests). As far as I can tell, that's not possible with the current SkillResponse class.

Here's the warning I've been seeing in CloudWatch logs.

{
    "version": "1.0",
    "session": null,
    "context": {
        "System": {
            "application": {
                "applicationId": "..."
            },
            "user": {
                "userId": "...,
                "accessToken": null
            },
            "device": {
                "supportedInterfaces": {
                    "AudioPlayer": {}
                }
            }
        },
        "AudioPlayer": null
    },
    "request": {
        "error": {
            "type": "INVALID_RESPONSE",
            "message": "SpeechletResponse was null"
        },
        "cause": {
            "requestId": "..."
        },
        "type": "System.ExceptionEncountered",
        "requestId": "...",
        "locale": "en-US",
        "timestamp": "2017-04-16T19:05:20Z"
    }
}

According to this article, the issue is that Alexa expects an empty JSON response instead of null: System Error "SpeechletResponse was null"

switching intents with dialog management

I have 2 intents x,y. Lets say x has dialog interface. Before even starting the response to that request, I have to check for a condition which is fulfilled by intent y. If its false, Alexa has to ask the user and after its true, dialog interface should match for intent x.
The scenario is almost like a having a PIN before using your skill.
Its easy when there is no dialog interface with the intent, but that's what making it challenging. Any sort of help is appreciated. Thanks for the prompt response earlier @stoiveyp .

Not working with ServiceSimulator

Hei,

I was using your project in version 1.0.0-beta-9 for while without issues. Then, today, I noticed that the Service Simulator in the testing section of the Alexa Skill is giving the following error if I type in the utterance start <appname>:
The remote endpoint could not be called, or the response it returned was invalid.

In AWS Cloudwatch I saw the following error:

Error reading date. Unexpected token: Integer. Path 'timestamp', line 4, position 130.: JsonReaderException
at Newtonsoft.Json.JsonReader.ReadAsDateTime()
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Alexa.NET.Request.Type.RequestConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
at lambda_method(Closure , Stream , Stream , ContextInfo )

The JSON generated by the service simulator looks like this:

{
  "session": {
    "sessionId": "SessionId.5e19fbad-549d-4500-96c0-c41dbbc632cc",
    "application": {
      "applicationId": "amzn1.ask.skill.XXXXXX"
    },
    "attributes": {},
    "user": {
      "userId": "amzn1.ask.account.XXXXXX"
    },
    "new": true
  },
  "request": {
    "type": "LaunchRequest",
    "requestId": "EdwRequestId.df44c930-0ca7-4006-9259-ae5370e6fbbc",
    "locale": "de-DE",
    "timestamp": "2017-07-11T07:24:40Z"
  },
  "version": "1.0"
}

I checked the nuget packages and updated to version 1.0.1 of the Alexa.NET package and tried again. Still failing, but with another error for the start <appname> utterance:

Value to add was out of range.
Parameter name: value: ArgumentOutOfRangeException
at System.DateTime.Add(Double value, Int32 scale)
at Alexa.NET.Helpers.MixedDateTimeConverter.UtcFromEpoch(Int64 epochTime)
at Alexa.NET.Helpers.MixedDateTimeConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Alexa.NET.Request.Type.RequestConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
at lambda_method(Closure , Stream , Stream , ContextInfo )

I created a new empty project with a single response to verify this isn´t related to my project.

Side fact: Copy pasting the json into the json tab in the service simulator works. Using the Alexa Echo Dot itself also works. Only the service simulator in text mode generates errors. But if I develop in Office I am unable to use the device as this would annoy my work colleagues.

Skills Api

Hi

Any way to access CameraStreamsController's from the smart-home apis?
Like this request

Or is this something that needs implementing?

Proposal: AskWithCard()

I have a proposal for Alexa.NET: Amazon once rejected one of my skills, because I sent a Card on HelpIntent \w TellWithCard(). At the moment, Alexa.NET does not implement "AskWithCard()" or something similar. This is how I solved it. Maybe you find it useful for other users. With that method, my skill passed the failed test.



        private SkillResponse askWithCard(PlainTextOutputSpeech speech, string title, string cardContent)
        {
            // create the response
            var responseBody = new Alexa.NET.Response.ResponseBody();
            responseBody.OutputSpeech = speech;
            responseBody.ShouldEndSession = false; // this triggers the reprompt
            responseBody.Reprompt = new Reprompt();
            responseBody.Card = new SimpleCard() { Title = title, Content = cardContent };

            var skillResponse = new Alexa.NET.Response.SkillResponse();
            skillResponse.Response = responseBody;
            skillResponse.Version = "1.0";

            return skillResponse;
        }

Getting InvalidOperationException on ProgressiveResponse

I'm trying to run a progressive command like this:

                var prog = new ProgressiveResponse(input);
                if(prog.CanSend())
                {
                    
                    await prog.SendSpeech("Verbinde zum Server. Bitte warten.");
                }

But executing it on Lambda gives me:

{
    "errorType" : "AggregateException",
    "errorMessage" : "One or more errors occurred. (An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.)",
    "stackTrace"   : [
        "at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)",
        "at lambda_method(Closure , Stream , Stream , LambdaContextInternal )"
    ],
    "cause"        : {
        "errorType" : "InvalidOperationException",
        "errorMessage" : "An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.",
        "stackTrace"   : [
            "at System.Net.Http.HttpClient.PrepareRequestMessage(HttpRequestMessage request)",
            "at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)",
            "at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)",
            "at System.Net.Http.HttpClient.PostAsync(Uri requestUri, HttpContent content, CancellationToken cancellationToken)",
            "at Alexa.NET.Response.ProgressiveResponse.Send(IProgressiveResponseDirective directive)",
            "at WEBWAREDaten.Function.<FunctionHandler>d__2.MoveNext() in c:\\users\\teamg\\source\\repos\\WEBWAREDaten\\WEBWAREDaten\\Function.cs:line 43"
        ]
    },
    "causes"       : [
        {
            "errorType" : "InvalidOperationException",
            "errorMessage" : "An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.",
            "stackTrace"   : [
                "at System.Net.Http.HttpClient.PrepareRequestMessage(HttpRequestMessage request)",
                "at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)",
                "at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)",
                "at System.Net.Http.HttpClient.PostAsync(Uri requestUri, HttpContent content, CancellationToken cancellationToken)",
                "at Alexa.NET.Response.ProgressiveResponse.Send(IProgressiveResponseDirective directive)",
                "at WEBWAREDaten.Function.<FunctionHandler>d__2.MoveNext() in c:\\users\\teamg\\source\\repos\\WEBWAREDaten\\WEBWAREDaten\\Function.cs:line 43"
            ]
        }
    ]
}

Implementation of the deviceId

Concerning this paper, it is possible to retrieve the deviceId from device object:

https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/device-address-api#steps

deviceId = this.event.context.System.device.deviceId

At the moment it's not implemented in Alexa.NET, but I think it may be useful.

PS: Awesome work, Tim! I showed Alexa.NET to Amazon people in Germany and they were suprised how comfortable it is to build skills \w Visual Studio + .NET Core + AWS Plugin + Alexa.NET

shouldEndSession flag is not allowed with LauchVideoApp.Launch

Hey,

on my FireTV Stick (Germany) it throws an error if I use the new VideoAppDirective.

Sample:

private IDirective getVideoPlayerDirective(SkillRequest input, string song)
        {
            VideoAppDirective dir = new VideoAppDirective();
            VideoItem item = new VideoItem(song);
            VideoItemMetadata meta = new VideoItemMetadata();
            meta.Title = "Testvideo";

            item.Metadata = meta;
            dir.VideoItem = item;

            return dir;
        }

private IDirective GetPlayerDirective(SkillRequest input, string song)
        {

            foreach (var interf in input.Context.System.Device.SupportedInterfaces)
            {
                switch (interf.Key)
                {
                    case "AudioPlayer":
                        return getAudioplayerDirective(input, song);
                    case "VideoApp":
                        return getVideoPlayerDirective(input, song);
                    default:
                        break;
                }
            }
            return null;
        }

     private void SetShouldEndSession(ref SkillResponse response, SkillRequest input, bool endsession)
        {
            foreach (var interf in input.Context.System.Device.SupportedInterfaces)
            {
                if (interf.Key == "AudioPlayer")
                    response.Response.ShouldEndSession = endsession;
            }

        }
public SkillResponse FunctionHandler(SkillRequest input, ILambdaContext context)
        {

            SkillResponse response = new SkillResponse();
            response.Response = new ResponseBody();
            SetShouldEndSession(ref response, input, false);

            IOutputSpeech innerResponse = null;
            var log = context.Logger;

                if (input.GetRequestType() == typeof(LaunchRequest))
                {
//some code
                 }
                 else if (input.GetRequestType() == typeof(IntentRequest))
                {
                    string song = "pathToMP4";

                     var intentRequest = (IntentRequest)input.Request;

                    switch (intentRequest.Intent.Name)
                    {
                        case "AMAZON.YesIntent":
                            log.LogLine($"YesIntent sent: start music " + song);
                            innerResponse = new SsmlOutputSpeech();
                            (innerResponse as SsmlOutputSpeech).Ssml = resource.OkLetsGo;
                            response.Response.Card = card;
                            SetShouldEndSession(ref response, input, true);
                            response.Response.Directives.Add(GetPlayerDirective(input, song));
                            log.LogLine(response.Response.ShouldEndSession.ToString());
                            break;
                       //more Intents..
                       default:
                            break;
                   }
              }
               response.Response.OutputSpeech = innerResponse;
               response.Version = "1.0";
               return response;
}

Making Alexa.NET multi language compatible

Hi,

if you add the JsonProperty("locale") to Request.cs, Alexa.NET will instantly become multi-language compatible:

    public abstract class Request
    {
        [JsonProperty("type")]
        public string Type { get; set; }

        [JsonProperty("requestId")]
        public string RequestId { get; set; }

        [JsonProperty("locale")]
        public string Locale { get; set; }

        [JsonProperty("timestamp")]
        public DateTime Timestamp { get; set; }
    }

I thought it might be easier this way than going though a pull request... etc. Let me know if you want me to do it.

How to redirect to another intent?

My skill asks the user at some point if he wants to do additional things with the information he gave. Sometimes, additional slots need to be elicited for this. I am using the dialog API, so I thought I just slap together a new Intent with the appropriate state and slots filled, and use a DialogDelegate. But when I do this, it goes through without any errors, but my Echo tells me that a problem occurred with my skill.

Is this possible with Alexa.net, and if yes, how?

Sample project does not load in VS 2015

Just tried to download the code and open the solution, but getting this error in VS 2015. Ideas?

Thanks, Crile

..\Alexa.NET.Tests\Alexa.NET.Tests.csproj : error : The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.

Missing <speak> SSML from readme

The readme has SSML output as plain text with the occasional bit of extra markup. This will work fine with the simulator, but it won't work with real Echo devices. You need to wrap the entire SSML in tags. For example:

<speak>Hello, this works</speak>
This works

and

Hello, this only works in the simulator
This does not

Could not find the LambdaSerializerAttribute

I built a basic skill with the help of the examples, but I get the error:

Could not find the LambdaSerializerAttribute on the assembly 'NetTestSkill, Culture=neutral, 
PublicKeyToken=null' or method 'TestSkill' while attempting to deserialize input data of type 
'Alexa.NET.Request.SkillRequest'. To use types other than System.IO.Stream as input/output 
parameters, the assembly or Lambda function should be annotated with 
Amazon.Lambda.LambdaSerializerAttribute.: LambdaException

What am I missing?

Merging of Slight.Alexa

How would you feel about moving the rest of Slight.Alexa to this project?

From the Slight.Alexa project:

  • Project base
  • Basic tests from sample responses
  • Combined .Net 4.5 + .NetStandard 1.2 support (upgrade to 1.6?)
  • Project icon
  • Re-adding of XML docs

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.