stoiveyp / alexa.net.gadgets Goto Github PK
View Code? Open in Web Editor NEWA simple package built to work with Gadgets API
License: MIT License
A simple package built to work with Gadgets API
License: MIT License
return gadgetId != null;
Hi,
I've a problem serializing the Alexa Request. I've been writing the request to CloudWatch this since using Alexa.NET library. In my newest project i'm working with Echo buttons and therefore the Alexa.NET Gadgets library.
The first request can be serialized and logged without any problems. In the first response i'm doing a roll call. When pressing my two echo buttons there are recongized and sent back to my skill with the second request which i'm not able to serialize using JSonSerializer.
Maybe someone can help me because during development it is really helpful to write the complete request string into a cloud watch stream.
private void LogRequestResponse(object requestResponse, string title)
{
var serializer = new Amazon.Lambda.Serialization.Json.JsonSerializer();
using (var ms = new MemoryStream())
{
try
{
serializer.Serialize(requestResponse, ms);
var jsonText = Encoding.UTF8.GetString(ms.ToArray());
Log.LogLine(string.Format("{0} - {1}", title, jsonText));
}
catch (Exception e)
{
ErrorFormat("Error serializing {0}, Error: {1}", title, e.ToString());
}
}
}
this leads to the following Exception:
ERROR - Error serializing REQUEST, Error: Newtonsoft.Json.JsonWriterException: Token PropertyName in state Property would result in an invalid JSON object. Path 'request.events[0].inputEvents[0]'.
at Newtonsoft.Json.JsonWriter.AutoComplete(JsonToken tokenBeingWritten)
at Newtonsoft.Json.JsonTextWriter.WritePropertyName(String name, Boolean escape)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
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)
So, Im currently working with a Custom Gadget (Lego Mindstorm Ev3) and want to send directives to the python Code running on my Gadget. Somehow, when I try adding the directive, Alexa tells me that there is an error during the Answer of the requested Skill. Am I doing something wrong? This is the Code that is given as a sample Directive Request:
SendDirective.AddToDirectiveConverter(); //Only if you're deserializing directives from JSON
var directive = new SendDirective(endpointId, interfaceNamespace, interfaceName, customPayload);
skillResponse.Response.AddDirective(directive);
Notice, that the AddDirective(directive) method is not available anymore. What I did then, was just to add my SendDirective directive to the Dictionary, that is given like so:
SendDirective.AddToDirectiveConverter();
SendDirective directive = new SendDirective(endpoint.EndpointId, "Custom.Mindstorms.Gadget", "Control", JsonConvert.SerializeObject(speedData));
skillResponse.Response.Directives.Add(directive);
Doing it like this, seems to work, even tho the List Im adding it to is a IList and not a SendDirective List. The problem obove then occures, whenever i tell Alexa to send the Request.
Would be glad, to get a quick response :)
Currently AddRollCall and TryGetRollCallResult requires the skill to know how many buttons it needs to work.
Often a skill will want to know how many buttons there are as a way of registering players etc, so ideally the package would have a way of figuring out the mapping from a timed out event.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.