简体   繁体   中英

How to schedule message for Microsoft Teams bot according to timezone?

I want to send a message to the user from my bot on a specific time interval. Till now I am using agenda for scheduling messages. But the timezone of agenda is 5:30 hours behind my timezone. So it is not sending messages to the user on right time. Is there a way to schedule messages in Microsoft teams?

Let suppose the scenario of birthday wish. Suppose, I want to send birthday wishes from bot to all the users on their birthdays at 9 in the morning every year. And birth dates are stored in database. How can I do that?

Basically, you'd need to know the time zone of the user. Unfortunately, you don't get this with, for instance, a conversationUpdate event, but there are two other alternatives:

  1. You could simply ask the user, via the bot, like letting them select a time zone in an adaptive card, or entering their closest city

  2. Although conversationUpdate doesn't pass anything useful, a regular user message to the bot has both a "timestamp" as well as a "localTimestamp" field. I'm not sure if it's -always populated (it's marked "nullable" in C# on IActivity), but it will contain the local time of the user. You can store that for later reference, to know when to message them.

In terms of actually sending the messages via your bot, you'd want to use something called "proactive messaging". You can find more here and here to get started.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM