ToDo like a boss – automate task creation using Graph API (preview)

ToDo Graph API has appeared the in documentation Graph API at Docs.Microsoft.Com . This opens up new possibilities to aggregate user tasks into a single app – ToDo. I did some testing with the API to see what is possible – and what is not.

Getting tasks

How to retrieve your tasks using Graph Explorer, which is a great tool to start testing how the API works.

GET /beta/me/outlook/tasks

Yes, we got the list of our tasks out. As expected.

Creating tasks with due dates

When I start playing around with a new API I start with simple tests. The next obvious test is to create a new task with basic information. And we of course want to set Start & Due dates. Note from Docs: time portion of Start & Due date is ignored: they are always assumed for midnight.

In case you have been creating new ToDo tasks using Flow, you may have noticed that the Flow connector does not yet support Due dates.

POST /beta/me/outlook/tasks
{
            "assignedTo": "Vesku Nopanen",
            "subject": "Test task from Graph API",
            "dueDateTime": { 
		"dateTime": "2019-04-05T09:00:00",
      		"timeZone": "FLE Standard Time"
		},
            "startDateTime": { 
		"dateTime": "2019-03-30T09:00:00",
      		"timeZone": "FLE Standard Time"
		},
            "body": {
                "contentType": "text",
                "content": "Task body text goes here"
            }
  }

Ok, so that part works nicely. Let’s add more content. First I add some details to template task and retrieve them with get to get a quick understanding of the JSON format.

  • reminder is set in the same format as Start/Due dates and isReminderOn is set to true
  • all times are converted to UTC timezone internally
  • If you flag the task as starred it will get importance: high
  • I did not find a way to get/add steps to a ToDo task via Graph API
  • There is no way to interact with My Day view (not yet at least)

Now we know that we can create a task to personal ToDo via Graph API and we can add following information via Graph API

  • Subject (task name)
  • Start & Due dates
  • Reminder
  • Importance
  • Body text

The reality to automate task creation is not yet perfect. There are limitations.

I created a Flow with Teams atMention trigger just to see how this would work. It did not.Not yet at least.

  • This works only as a delegated permission (HTTP Post action in a Flow did not work for me). Yep, check the permissions that are needed to performs Graph API actions.
  • ToDo Flow create task does not relay Due/Reminder information to ToDo (this was expected)

I was testing this with Teams trigger, but more realistic triggers could be Dynamics CRM/AX, Project, Planner, external task applications like Jira etc. Once you get to use this API to create tasks it will open up – again – great possibilities to make ToDo a centralized task application.

Of course it is also possible to read user’s completed tasks (with ids) from ToDo to write the completed information to the source system. Storing source IDs or some other information can be carried in the text content part.

Working around the obstacle – barriers won’t hold us!

There might be some workarounds: writing tasks from Teams into another store and then running a automated service with delegated permissions. However, that would work only in a single user(delegated user) context and thus is unusable until it is possible to create tasks to other users.

However, I did want to see if I can do this using PowerShell. I used the ”good old way” to get delegated permissions: authenticating with Connect-PnPOnline.

https://graph.microsoft.com/beta/me/outlook/tasks

{
"subject": "Testing task creation via PowerShell & Graph API",
"dueDateTime": { 
   "dateTime": "2019-04-05T09:00:00",
   "timeZone": "FLE Standard Time"
   },
"importance" : "high",
"isReminderOn": true,
"reminderDateTime": {
   "dateTime": "2019-04-01T06:00:00.0000000",
   "timeZone": "UTC"
   },
"body": {
   "contentType": "text",
   "content": "Task body could contain some IDs"
   }
}

And as expected, I was able to create the task with all these properties that work at this point. I left attachments out of this experiment.

ToDo API is still beta/preview and most likely it will be developing for better over time. However we could already piggy-bag some data in the task body content to enable a two-way automation with ToDo. That way we can bring in tasks closer to user (they use ToDo for all kinds of tasks) and make this appealing when user does not have to go to the legacy/source system to mark his tasks done. Takes some work, but now is a good time to start experimenting.

2 vastausta artikkeliin “ToDo like a boss – automate task creation using Graph API (preview)

  1. Hi there,
    This is a great tutorial. Do you also have a workaround to create tasks for other users in the company? I want to automate the process of Task assigning in To Do of other employees. Any help would be appreciated

    Tykkää

Vastaa

Täytä tietosi alle tai klikkaa kuvaketta kirjautuaksesi sisään:

WordPress.com-logo

Olet kommentoimassa WordPress.com -tilin nimissä. Log Out /  Muuta )

Google photo

Olet kommentoimassa Google -tilin nimissä. Log Out /  Muuta )

Twitter-kuva

Olet kommentoimassa Twitter -tilin nimissä. Log Out /  Muuta )

Facebook-kuva

Olet kommentoimassa Facebook -tilin nimissä. Log Out /  Muuta )

Muodostetaan yhteyttä palveluun %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.