stoiveyp / alexa.net.reminders Goto Github PK
View Code? Open in Web Editor NEWSmall helper library for Alexa.NET based skills to access the reminders API
License: MIT License
Small helper library for Alexa.NET based skills to access the reminders API
License: MIT License
Any idea when weekly recurrence is going to be supported?
Hi,
is it possible to add a "one time" reminder?
Whenever i do not add a Recurrence
object to my AbsoluteTrigger
i get a "BAD_REQUEST" error.
best regards
bauchschuss
I can't seem to find any C# examples of flows to request permissions--do you have any samples?
Am I understand the flow correctly as:
What does the code look like for steps 4 and then 7?
Hi,
i've come across another question after browsing your code.
Where did you get the access token that you're using in your unit tests? It is exactly what i would need to test Reminder API from my unit tests.
br
bauchschuss
Hi,
I get the above error. I do not know, which parameters are wrong.
Trigger = new AbsoluteTrigger
{
ScheduledTime = DateTime.Parse(DateTime.UtcNow.AddMinutes(1).ToIso8601()),
TimeZoneId = "Europe/Berlin",
Recurrence = new Recurrence("WEEKLY", new[] { "MO", "TU", "WE", "TH", "FR", "SA", "SU"})
}
While using the code base from the project to create a reminder, I get the following error:
Error at Alexa.NET.Response.RemindersClient.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at AlexaWebAPI.Controllers.ReminderController.d__0.MoveNext()
Can you please help me understand what is going wrong here.
Code Snippet used to create reminder:
var reminder = new Reminder
{
RequestTime = DateTime.UtcNow,
Trigger = new RelativeTrigger(12 * 60 * 60),
AlertInformation = new AlertInformation(new[] { new SpokenContent("it's a test", "en-GB") }),
PushNotification = PushNotification.Disabled
};
var client = new RemindersClient(RemindersClient.ReminderDomain,input.Session.User.AccessToken);
var alertDetail = await client.Create(reminder);
Certain requests that are in the latest version of Alexa.NET.Reminders have been deprecated and could be upgraded to keep up with latest changes in Alexa Reminders API. It's still backward compatible so far.
See Deprecated Recurrence Rules:
https://developer.amazon.com/en-US/docs/alexa/smapi/alexa-reminders-api-reference.html#
I was wondering if you'd be open to collaborating to keep this library in sync with Reminders API, and if you think this is worth pursuing.
Hi,
when i was trying to add reminders to my skill i maybe found a bug in your code. It concens the JsonConvert method in the RemindersClient. When dates (ScheduledTime or RequestTime) are serialized your code produces something like 2019-02-21T06:50:56.614029Z which leads to an INVALID_TRIGGER_SCHEDULED_TIME_FORMAT
Amazon documentation says that date times need to be in a format like 2019-02-21T06:50:56.614. As a result of this i extended your ReminderClient class like this:
public class RemindersClientExt : RemindersClient
{
private ICustomLogger Logger { get; set; }
public RemindersClientExt(SkillRequest request, ICustomLogger logger) : this(
request.Context.System.ApiEndpoint,
request.Context.System.ApiAccessToken,
logger)
{ }
public RemindersClientExt(string endpointUrl, string accessToken, ICustomLogger logger)
:base(endpointUrl, accessToken)
{
Logger = logger;
}
public RemindersClientExt(HttpClient client, ICustomLogger logger)
:base(client)
{
Logger = logger;
}
public new async Task<ReminderChangedResponse> Create(Reminder reminder)
{
var message = await Client.PostAsync(
new Uri("/v1/alerts/reminders", UriKind.Relative),
new StringContent(SerializeReminder(reminder), Encoding.UTF8, "application/json"));
if (message.StatusCode != HttpStatusCode.Created)
{
var body = await message.Content.ReadAsStringAsync();
throw new InvalidOperationException($"Unexpected result: Status {message.StatusCode}, body: {body}");
}
return JsonConvert.DeserializeObject<ReminderChangedResponse>(await message.Content.ReadAsStringAsync());
}
public new async Task<ReminderChangedResponse> Update(string alertToken, Reminder reminder)
{
var message = await Client.PutAsync(
new Uri("/v1/alerts/reminders/" + System.Net.WebUtility.UrlEncode(alertToken), UriKind.Relative),
new StringContent(SerializeReminder(reminder), Encoding.UTF8, "application/json"));
if (message.StatusCode != HttpStatusCode.OK)
{
var body = await message.Content.ReadAsStringAsync();
throw new InvalidOperationException($"Unexpected result: Status {message.StatusCode}, body:{body}");
}
return JsonConvert.DeserializeObject<ReminderChangedResponse>(await message.Content.ReadAsStringAsync());
}
private string SerializeReminder(Reminder reminder)
{
var serializerSettings = new JsonSerializerSettings { DateFormatString = "yyyy-MM-ddTH:mm:ss.fff" };
//var serializedReminder = JsonConvert.SerializeObject(reminder, serializerSettings);
var serializedReminder = JsonConvert.SerializeObject(reminder);
Logger.DebugFormat("SERIALIZATION of REMINDER object: {0}", serializedReminder);
return serializedReminder;
}
}
With the JsonSerializerSettings used in the above code the creation of reminders works like expected. Maybe you can reproduce this issue by using DateTime.UtcNow
in your code instead of parsing the DateTime from a correct DateString.
best regards
bauchschuss
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.