stoiveyp / alexa.net.proactiveevents Goto Github PK
View Code? Open in Web Editor NEWSmall library to help with the Alexa ProactiveEvents API
License: MIT License
Small library to help with the Alexa ProactiveEvents API
License: MIT License
Hi,
i don't know if i do something wrong but the SKILL_PROACTIVE_SUBSCRIPTION_CHANGED event is not firing when activating / deactivating the corresponding permission via Alexa app. The proactive events are working well.
I've added the ProactiveSubscriptionChangedRequestHandler in the constructor of my function.
public Function() { new ProactiveSubscriptionChangedRequestHandler().AddToRequestHandler(); }
The SKILL_PERMISSION_CHANGED and SKILL_PERMISSION_ACCEPTED are firing like expected when changing the permission in the app.
"subscriptions": [
{
"eventName": "SKILL_PROACTIVE_SUBSCRIPTION_CHANGED"
},
{
"eventName": "SKILL_PERMISSION_ACCEPTED"
},
{
"eventName": "SKILL_PERMISSION_CHANGED"
},
{
"eventName": "SKILL_ENABLED"
},
{
"eventName": "SKILL_DISABLED"
}
],
I have also subscribed to the event from the skill manifest.
Does anybody else have the same issue?
best regards
Martin
In ReservationConfirmationStatus.cs
[EnumMember(Value = "REQUESTED")] Requested,
should be changed to:
[EnumMember(Value = "RECEIVED")] Received,
Amazon return BadRequest validation from a "REQUESTED" occasion:
{
"type": "Bad Request",
"message": "The event failed the schema validation, eventNode does not match schema, report is com.github.fge.jsonschema.core.report.ListProcessingReport: failure\n--- BEGIN MESSAGES ---\nwarning: the following keywords are unknown and will be ignored: [$id, schemaId]\n level: "warning"\n schema: {"loadingURI":"#","pointer":""}\n domain: "syntax"\n ignored: ["$id","schemaId"]\nerror: instance value ("REQUESTED") not found in enum (possible values: ["CONFIRMED","CANCELED","RECEIVED","CREATED","UPDATED","RESCHEDULED"])\n level: "error"\n schema: {"loadingURI":"#","pointer":"/properties/payload/properties/state/properties/confirmationStatus"}\n instance: {"pointer":"/payload/state/confirmationStatus"}\n domain: "validation"\n keyword: "enum"\n value: "REQUESTED"\n enum: ["CONFIRMED","CANCELED","RECEIVED","CREATED","UPDATED","RESCHEDULED"]\n--- END MESSAGES ---\n"
}
Hi Steven and thanks in advance for you amazing work :-)
This is not an issue, I just want to ask if there is a way to send e "custom event" through ProactiveEvents api.
What I'm triyng to do is to notify a user (unicast) that a task (previous launched from skill) has ended successfully or with an error. It's a very simple message so I thought that the nearest schema is AMAZON.MessageAlert.Activated
...but here I can only specify the creator...
If there is no way...maybe I can use progressive responses? But sincerely I don't think this can be the right pattern because the task can take some minutes to complete.
It's unbelivable that they removed notifications api...
I always got 400 Bad requests even though the request was correct.
I found that the Date format doesn't follow the example provided in the Proactive Events API Reference documentation.
Can you release a new version with the resolution by improving the settings of the EventIsoDateTimeConverter class (see TO BE)?
AS IS
Date time Format JSON - Proactive Events API Reference
"timestamp": "2019-04-18T03:27:00.00Z"
Abstract JSON - Alexa.NET.ProactiveEvents.dll Version 1.1.0
"timestamp":"2020-03-02T23.30.21+00:00",
"expiryTime": "2020-03-03T22.30.21+00:00"
Full JSON - Alexa.NET.ProactiveEvents.dll Version 1.1.0
{
"relevantAudience": {
"type": "Multicast",
"payload": {}
},
"timestamp": "2020-03-02T23.30.21+00:00",
"referenceId": "120797e38ea148c18fa08bb669872b86",
"expiryTime": "2020-03-03T22.30.21+00:00",
"event": {
"payload": {
"state": {
"status": "UNREAD",
"freshness": "NEW"
},
"messageGroup": {
"creator": {
"name": "Allerta Server"
},
"count": 4
}
},
"name": "AMAZON.MessageAlert.Activated"
},
"localizedAttributes": []
}
Test with response 400 BAD REQUEST
var eventToSend = new Alexa.NET.ProactiveEvents.MessageReminders.MessageReminder(
new Alexa.NET.ProactiveEvents.MessageReminders.MessageReminderState(
Alexa.NET.ProactiveEvents.MessageReminders.MessageReminderStatus.Unread,
Alexa.NET.ProactiveEvents.MessageReminders.MessageReminderFreshness.New),
new Alexa.NET.ProactiveEvents.MessageReminders.MessageReminderGroup("Allerta Server", 4, null)
);
var request = new BroadcastEventRequest(eventToSend)
{
ExpiryTime = DateTimeOffset.UtcNow.AddDays(1).AddHours(-1),
ReferenceId = Guid.NewGuid().ToString("N"),
TimeStamp = DateTimeOffset.UtcNow
};
var clientId = "<clientId>";
var clientSecret = "<clientSecret>";
var messaging = new AccessTokenClient(AccessTokenClient.ApiDomainBaseAddress);
var details = messaging.Send(clientId, clientSecret).GetAwaiter().GetResult();
var accessToken = details.Token;
var client = new ProactiveEventsClient(ProactiveEventsClient.EuropeEndpoint, accessToken);
var response = client.Send(request).GetAwaiter().GetResult();
Source code class EventIsoDateTimeConverter - Alexa.NET.ProactiveEvents.dll Version 1.1.0
internal class EventIsoDateTimeConverter : IsoDateTimeConverter
{
public EventIsoDateTimeConverter()
{
// DateTimeStyles = DateTimeStyles.AdjustToUniversal;
DateTimeFormat = "yyyy-MM-ddTHH:mm:ssK";
}
}
TO BE
FIX - Alexa.NET.ProactiveEvents.dll Version 1.X.X
internal class EventIsoDateTimeConverter : IsoDateTimeConverter
{
public EventIsoDateTimeConverter()
{
Culture = System.Globalization.CultureInfo.InvariantCulture;
DateTimeStyles = System.Globalization.DateTimeStyles.AdjustToUniversal;
DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ff'Z'";
}
}
Abstract JSON
"timestamp":"2020-03-02T23:24:23.06Z",
"expiryTime": "2020-03-03T22:24:23.06Z"
Full JSON
{
"relevantAudience": {
"type": "Multicast",
"payload": {}
},
"timestamp": "2020-03-02T23:24:23.06Z",
"referenceId": "75fa64c1db334c249e8952393d978211",
"expiryTime": "2020-03-03T22:24:23.06Z",
"event": {
"payload": {
"state": {
"status": "UNREAD",
"freshness": "NEW"
},
"messageGroup": {
"creator": {
"name": "Allerta Server"
},
"count": 4
}
},
"name": "AMAZON.MessageAlert.Activated"
},
"localizedAttributes": []
}
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.