0 0
Read Time:2 Minute, 27 Second

Creating alexa skills with .NET – part 9 Setting reminders from an Alexa Skill.

In part 8 we introduced the ability to pass data from a skill invocation using what amazon call slots.

One use of this data can be to set a reminder, this reminder will then appear on the users device and optionally also be sent as a push notification is the user has the alexa app on a mobile device.

It should be noted that reminders only go to the alexa device on which you ,made the request, they do not go to all devices under the same account, if you want all devices to show something that can be done but only by a different method.

Alexa reminders (set via skills) are pretty basic, the API shows the options but for example you can’t set repeats for say 14 days, you are limited to things like daily and weekly so it’s more of use for a one time reminder at a specific time than a reoccurring item unless the reoccurrence is daily or weekly.

Reminders are a permission and so need to be switched on for the skill, and after switching on your need to rebuild the model.

And as you would expect users need to also allow it specifically in the alexa website.

so now we have the skill allowed to deal with it’s reminders assuming that the user also allows it. The sensible thing would now be to have some form of intent with an utterance that allows the user to say when they want a reminder.

I’m not going to do that for this example, but the image below shows one such sample that I have on one of my own skills

We will just set an intent for this example that simply will set a reminder shortly in the future.

So, remembering to build the model, we move on to the rest service code.

As before we need to add in one of the nuget packages, Alexa.Net.Reminders in this case.

if (intentRequest.Intent.Name == "IntentSetReminder")
{
   try
   {
      var reminder = new Reminder
      {
         RequestTime = DateTime.UtcNow,
         Trigger = new RelativeTrigger(12 * 60 * 60),
         AlertInformation = new AlertInformation(new[] { new SpokenContent("Testy McTestface reminder", "en-GB") }),
         PushNotification = PushNotification.Enabled
      };
      var rclient = new RemindersClient(skillRequest);
      var alertDetail = await rclient.Create(reminder);
       return ResponseBuilder.Tell("Reminder has been set");
    }
    catch (Exception e)
    {
        // This will normally be that the user has not authorised reminders so you need to tell them how.
        return ResponseBuilder.Tell("Error :"+e.Message);
     }
}

You can see that this reminder has been set for 12 hours in the future and is visible on the website and alexa app. Please note that you need to use the dropdown at the top of the screen to set your alexa device, Reminders are device specific.

The repository for this article is at https://github.com/raymondjstone/AlexaNetExampleStage05

in part 10 of these articles we will be looking at account linking.

About Post Author

raymond

Been developing software for 40 plus years, started with Apple ]['s moved on to a variety of mainframes, PC's, Atari ST/Falcon, Psion's then onto more web related stuff (when there was an internet) and mobile apps (Xamarin.Forms) for IOS and Android.
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply