Giter Site home page Giter Site logo

alexa.net.reminders's Introduction

Alexa.NET.Reminders

Small helper library for Alexa.NET based skills to access the reminders API

N.B. The reminders client requires that you have a skill with reminders persmission enabled, and the user must have given your skill reminders permission (even if its your development account)

Creating a reminder

using Alexa.NET.Response
using Alexa.NET.Reminders
....
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(skillRequest);
var alertDetail = await client.Create(reminder);
Console.WriteLine(alertDetail.AlertToken);

Retrieving Current Reminders

// Single reminders can be retrieved with client.Get(alertToken)
var alertList = await client.Get();
foreach(var alertInformation in alertList.Alerts)
{
  //Your logic here
}

Deleting a Reminder

await client.Delete(alertToken);

alexa.net.reminders's People

Contributors

stoiveyp avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

javierpuntonet

alexa.net.reminders's Issues

recurrence

Any idea when weekly recurrence is going to be supported?

Access Token for Testing Purposes

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

Example of permission request for reminders

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:

  1. Skill says something relevant, asks user if they want to set a reminder
  2. User responds "yes"
  3. Skill receives AMAZON.YesIntent
  4. Skill responds with a request for permission
  5. Alexa takes it from here and confirms permission
  6. User responds "yes"
  7. Then what? Skill receives another AMAZON.YesIntent and reminders are enabled?

What does the code look like for steps 4 and then 7?

Possible upgrading Alexa.NET.Reminders to match latest Alexa Reminders API

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.

Getting Error 500, when creating a reminder with AbsoluteTrigger

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"})
}

One Time Reminder

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

INVALID_TRIGGER_SCHEDULED_TIME_FORMAT

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

Create reminder throws error

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

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.