Caliandro.de - Blog

Create a planner task out of a MS Teams chat message with keyword trigger (Lowcode with Power Automate)

Normally, I try to avoid writing about non-free stuff like Microsoft, but I needed do realize this automation for work and did not find all needed information online. This is why I decided to write it down as future reference.

Context

We do short daily standup meetings with MS Teams. Therefore we collect in advance all topics to be discussed to prepare and timebox the meeting to 15min. As some topic announcements in the group chat got lost or overseen, as well as the need to write something down (decision, information, postpone to the next meeting..), I’ve searched a automated way to create a planner card for each topic in a dedicated “Daily Standup Taskboard” bases on a keyword

Requirements

  • the team’s group chat shall be watched for the keyword DailyTopic to trigger the task creation
  • the team members shall enrich their topics with the prequel DailyTopic, e.g. DailyTopic Do we keep the VPN for..?
  • the card shall receive the message title without keyword
  • the card shall receive the current date
  • no other third party tool shall be used for the automation
  • the card shall not be owned by anyone

The solution and result

  • I’ve played around with the low-code/0-code app Power Automate (part of the 365 suite) and figured out the solution based on a template and some trial&error
  • It works good and robust like a suction cup hook for a towel works…it lasts a little, then falls off the wall
    • Prepare to repair often
  • Accept to have no real control what happens and how the features are evolving over time
  • You have to put aside your programmers honor and get ready for this Excel-function-like nightmare
    • In the end it felt like doing a complicated s-lookup function in Excel.
  • You need programming experience to drag-n-drop your automation. But even then, it is quite complicated (but not complex)
    • I wouldn’t try to transfer this kind of job to a non-IT person without a real training + programming basics
  • The integrated debugging sucks, well you can’t even call it debugging
  • You need a lot of frustration tolerance to make it work in the beginning (and you’ll it next time as well)
  • ETL (extract-transform-load) experience helps a lot (like Pentaho Data Suite)
  • If you accept all the burdens and flaws of Power Automate, you can accomplish the most simple automation tasks within the 365-ecco-system
  • Fun level: 2/10 (I’ve used to write Cobol and Powerbuilder code in the past = 1/10)

Found issues

  1. The keyword does not accept # or any other special character. No workaround found
  2. Just a few day after the creation I’ve needed to change my password. From this second on, the flow failed with 502 Bad Gateway without further details (did I’ve mentioned that you cannot really debug or receive serious logs?).

    Solution was to

    1. set the group chat to another one
    2. save
    3. test (can be skipped)
    4. back to edit
    5. set the group chat back to the real one
    6. save

    Reason for this behaviour, according to different Microsoft websites, is indeed the password modification. This always results in a broken flow. Keep this in mind, if you plan to scale up the automations with Power Automate: Try to obtain a special sys account with permanent password

  3. Variables cannot be initialized after the first code block
  4. Nearly impossible to change the order of steps within the workflow

Detail Instructions step-by-step

step1.png

  1. MS Teams Keyword Trigger
    1. Keyword: DailyTopic
    2. On Group Chat
    3. Select your chat
  2. Initalize some variables
    1. MyTask
      • Type: String
      • Value: empty
    2. startIndex
      • Type: Number
      • Value: 10 / /to filter *DailyTopic from task title, adapt this to the length of your keyword
    3. maxChar
      • Type: Number
      • Value: 110 / /the max. length you want to see in your task
    4. messageLength
      • Type Number
      • Value: 0 / /to save the length of the chat message
  3. Apply to all step2.png

    1. Get message details
      • Message: Message ID
      • Type: Group Chat
      • Group chat: again your team's chat
    2. Set variable
      • Name: MyTask
      • Value: Body PlainText / /to remove any pictures or markdown
    3. Set variable
      • Name: messageLength
      • Value: length(variables('MyTask'))
    4. Condition
      • messageLength <= maxChar / /again the variables initialized in the beginning
    5. If TRUE
      1. Create task in Planner
        • GroupID: Your MS Teams group
        • PlanId: Name of your planner
        • Title / /the message reduced by the keyword
          • substring(variables('MyTask'),variables('startIndex'),sub(variables('messageLenght'),variables('startIndex')))
        • BucketID: Name of the bucket/column
        • Start date&time: CreatedDateTime of message details (step 3.1)
    6. If FALSE
      1. Create task in Planner
        • GroupID: Your MS Teams group
        • PlanId: Name of your planner
        • Title / /the message reduced by the keyword
          • substring(variables('MyTask'),variables('startIndex'),sub(variables('maxChar'),variables('startIndex')))
        • BucketID: Name of the bucket/column
        • Start date&time: CreatedDateTime of message details (step 3.1)

    step3.png

Why the True/False length condition at the end?

Without the condition, the automation crashes because of an index-out-of-bound exception while trying to apply the substring with maxChars on a message string with less characters

Remarks

If you want to use are more common keyword like Daily, you’ll have to use another function than substring to strip of the keyword from the text. Anyway I recommend to use a special keyword that you don’t use as natural word to prevent false positives.