Code Monkey home page Code Monkey logo

alexa.net.gadgets's People

Contributors

stoiveyp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

javierpuntonet

alexa.net.gadgets's Issues

Serialize Alexa Request

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)

Object reference not set to an instance of an object

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 :)

AddRollCall can't handle optional button roll call

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.

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.