cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Building Auto Reply at Set Time

Hi,

 

I am trying to build an auto message that will reply to anyone who posts a message after our office hours.

 

We want it to run only at CDT16:30 - CDT 08:00 the next day.   I am okay if we have to manually turn it off ... but do want it to start running every day from 4:30 PM. 

I tried to set the Interval 1 and Frequency as Day ... or as you see below every 60 Sec ... but the bot just won't work. 

It is not even stuck in the Recurrence but at the "When a new channel message is added" (see 2nd screenshot).

 

It has a counter running in the "When a new channel message is added", and can't get past it.

 

Can anyone suggest to me how I can make this work?  Thank you.

 

Capture.JPGCapture2.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User II
Super User II

Re: Building Auto Reply at Set Time

Hello @minniep 

Your flow have to start with the trigger "When a new channel message is added". It will be listening all the time, so no need to use a Recurrence trigger.

In the trigger "When a new channel message is added" is provided a date time value for when the post was created. Using that date time value, the autoreply can be setup to reply or not. I have made a little example that may be useful as a starting point for you:

Flow.Teams posted.Autoreply.jpg

In the example, a variable Time is intialized with the hour and minute value from the createdDateTime value and turned into an integer. This will give values from 0 to 2359. A Condition is then used to check that the Time is greater than 1630, meaning after 04:30 PM or less than 800, meaning before 08:00 AM.

 

In flow, date time values are always in UTC, so in the Time variable I convert from UTC to CDT.

Hope the above helps a little 🙂

Kind regards, John

 

View solution in original post

9 REPLIES 9
Highlighted
Super User II
Super User II

Re: Building Auto Reply at Set Time

Hello @minniep 

Your flow have to start with the trigger "When a new channel message is added". It will be listening all the time, so no need to use a Recurrence trigger.

In the trigger "When a new channel message is added" is provided a date time value for when the post was created. Using that date time value, the autoreply can be setup to reply or not. I have made a little example that may be useful as a starting point for you:

Flow.Teams posted.Autoreply.jpg

In the example, a variable Time is intialized with the hour and minute value from the createdDateTime value and turned into an integer. This will give values from 0 to 2359. A Condition is then used to check that the Time is greater than 1630, meaning after 04:30 PM or less than 800, meaning before 08:00 AM.

 

In flow, date time values are always in UTC, so in the Time variable I convert from UTC to CDT.

Hope the above helps a little 🙂

Kind regards, John

 

View solution in original post

Highlighted
Helper I
Helper I

Re: Building Auto Reply at Set Time

Thank you @JohnAageAnderse 

 

I had never created a condition before.

Can I add the Compose (Message ID) > Post a reply (Outputs) inside the "If Yes"?

or do I have to add the Apply Each inside the "If Yes" before I add the Compose and Post a reply (like I did as per screen shot in initial inquiry.)

Highlighted
Super User II
Super User II

Re: Building Auto Reply at Set Time

Hello @minniep 

You just add the compose and post inside the Yes branch. That should be enough.

If there is a need for the Apply to each, the editor will normally add it automatically, but I think it will not be dong that in this flow 🙂

Try it out and tell us about it.

Kind regards, John

Highlighted
Helper I
Helper I

Re: Building Auto Reply at Set Time

Thank you @JohnAageAnderse 

 

I am still getting this error in the Initialize variable:

InvalidTemplate. Unable to process template language expressions in action 'Initialize_variable' inputs at line '1' and column '2833': 'The template language function 'convertFromUtc' expects its first parameter to be a string that contains the time. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#ConvertFromUtc for usage details.'.
 
int(formatDateTime(convertFromUtc(triggerOutputs()?['body/createDateTime'],'Central Standard Time'),'HHmm'))
 
are you able to guide me through fixing it?
 
Capture3.JPG
 
Highlighted
Super User II
Super User II

Re: Building Auto Reply at Set Time

Hello @minniep 

Yes, the expression has "createDateTime", is must be "createdDateTime" 🙂

Kind regards, John

Highlighted
Helper I
Helper I

Re: Building Auto Reply at Set Time

Thank you @John 

I had corrected the formula to 

int(formatDateTime(convertFromUtc(triggerOutputs()?['body/createdDateTime'],'Central Standard Time'),'HHmm')) and it worked pass the Initialize variable. . . and it seems to be working.  Right now if I post outside the 4pm - 8am it will show the condition as cancel.  I am just waiting to see if the auto-reply will show when someone post between 4pm - 8am.
 
I am also curious, as I was trying to figure out a fix myself ... (obviously failed as not noticing I missed the 'd' in the formula), I found that if I use the Compose to get the MessageID, the language show:
 
triggerBody()?['createdDateTime']
 
and in your formula, you used triggerOutputs()?['body/createdDateTime'] instead.  Does it make any difference result?
Highlighted
Helper I
Helper I

Re: Building Auto Reply at Set Time

Another weird thing happened.

 

When I was testing the auto bot in one channel, it showed the condition as "Cancelled" when I message outside the time frame

 

However, after I moved the automate to the channel I wanted to apply, the condition will show as "Failed" when I message outside the time frame. Is that normal?

Highlighted
Helper I
Helper I

Re: Building Auto Reply at Set Time

Hi @JohnAageAnderse 

 

In addition to the difference between Cancelled and Failed status for the condition, I am also facing another challenge.

 

Not sure if you and other experts can take a look.

 

The auto-reply sometime works right away, but most of the time it delays by 2- 3 minutes.

 

Here is the image of how I built the flow:

int(formatDateTime(convertFromUtc(triggerOutputs()?['body/createdDateTime'],'Central Standard Time'),'HHmm'))

Capture4.JPG

 

Highlighted
Super User II
Super User II

Re: Building Auto Reply at Set Time

Hello @minniep 

The reason for the flow to fail is that the value "0800" used in the condition "is less than" must be "800" and not "0800". With the zero in front, flow thinks that it is a string value. Removed the zero and it will think that it is a numeric value and thus can be compared with the value in the Time variable, which is a numeric value 🙂 After that correction, the condition will work as expected.

 

About the flow reaction time, that is controlled by Microsoft, not something we can affect, as far as I know.

Kind regards, John

Helpful resources

Announcements
secondImage

August 2020 CYST Winners!

Check out the winners of the recent 'Can You Solve These?' community challenge!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Top Kudoed Authors
Users online (4,886)