Requirement-
The requirement is to send notifications to devices on specific times. That is, if a user has setup a schedule at 07:00 AM for breakfast, he'll get a notification for the same like 'Its time for breakfast, blah blah blah!'.
However, if the user has already had his breakfast before 07:00 AM, he'll make his diary entry on what he had etc. and then the notification must not be sent to him.
This is a recurring schedule and the user will only change this if he needs to, otherwise, the schedule will mostly be the same.
What we have achieved?-
So, for now what we do is to register devices with tags like '{TimeZone:EST},{Breakfast:07:00:00}' on the app's launch.
In case, the user has already had his breakfast, we update his registration on notification hub to also contain a tag like '{HadBreakfast}' - So, the set of tags user's device is registered to becomes - '{TimeZone:EST},{Breakfast:07:00:00},{HadBreakfast}'
What are we stuck at?-
This approach will work very well because, when sending notifications, we use tag expression like - '{TimeZone:EST} && {Breakfast:07:00:00} && !{HadBreakfast}'
So, this will send a notification to all users that wants a notification for breakfast at 07:00:00 AM for EST timezone but not to the ones who already had their breakfast.
However, if the user is registered with a tag like {HadBreakfast}, then the next day, he might not get the notification based on the logic just described.
So, we came up with the workaround to de-register only the {HadBreakfast} tag at the end of day for all the devices which has that tag by running a scheduler.
But, somewhere in our mind, we think that is not the best solution for this problem.
Other Alternative-
We also thought of another alternative that we can run a scheduler for every hour within which, it will do the same thing of removing such tags for the past hour for all the user devices which has that tag - and this process seems to be effective than running it once in a day.
But we wanted to know thoughts from the community on what I can try out? If the method that we use is correct or not? What else could be done to do this more simply OR smoothly? What if we have a million plus devices? Will this work?
I would suggest exploring the option for modifying registration in bulk and using the Azure Scheduler for the reaccuring task
Related
We have integrated the NodeJs bot application with the bot framework for interacting with bot in the Microsoft teams.
Based on the user input we are sending the adaptive cards respectively. Currently user can get the adaptive card today and can update the card later that day or after few days.
Is there any way to make the card expire after specific amount of time which make the card disabled.
Thank You
I have an idea how you could do this, but just an fyi that I've not done exactly this before, so there's no guarantee it will work. Basically, you'd be combining the ability to Update a message like discussed here with sending (or in this case 'updating') a pro-active message - see more here on that.
Because this is an existing conversation with the user, you'll have access from any existing message the user sends to get the parameters you need to start your proactive conversation (you need serviceurl, conversationid, tenantid, etc.). Do note that you can send a proactive message from OUTSIDE your bot (the code can be hosted somewhere else, and doesn't need to actually live IN your bot, even though to the user it will appear as if a proactive message was sent from your bot). I mention this because you could have this "expire card" message live in a separate process to your bot.
In case if you are still looking for an answer, I recently tried this approach:
In the card's response data, I set the expiry date and so now when the user submits the card, you can validate the data in the response and then update the card accordingly.
I had to use this approach because we have a very high user base and updating the card for all users proactively took much longer.
Cons: The card will remain will remain active, unless and until the user takes some action on it.
First of all, no this is nothing that is already implemented anywhere and you completely have to build that yourself.
One way to do this is this:
You need to store the activity / message ID for all cards you send. If you have the ID, you can always at any time go back and update the message (ie update your card)
Now that said, what i would suggest is this:
Sent a card to the user and store the id
Store the ID together
with creation date and expiration date somewhere on your end
Have some scheduled process that scans for expired cards
If a card is expired, update the message with a new card saying "sorry this card is expired"
We did that for our MS Teams Bot and its working quite well this way.
I have an app that sends SMS's out to a bunch of people. Those messages contain links. They are not using any link shorteners or any other service. They link back to my site. The links themselves are randomized strings, which are stored in my db, which are associated with an action. (Click "yes" or "no" link and the db tracks what you chose.) For ALL users, this works perfectly. With one user - and it's always the same user, as soon as the cron job runs, which triggers this event, his "vote" comes in. This is without him clicking or even seeing the message sometimes.
So, the question: has anyone ever seen or heard of a cell provider or a messaging app or similar that "clicks" links as part of some process before sharing the content with the user? I can't see ANYTHING in the code that would single him out so I'm thinking it has to be something in between when the message goes out and he does what he does. Especially because the timestamp is also always within seconds of the cron job running.
Sending an SMS can sometimes go through multiple carriers before reaching an end destination. As such, providers may be "handling" the content in this case.
The best thing to do would for any cases of this in the future would be to write support for further investigation.
I'd like to be able to run 'node sendSomeEmails.js' once every Monday morning.
So far, the easiest way I've found to do it, is actually stick a reminder in my calendar and spin up a terminal and do it myself : (
I'm building an automated email series using Mandrill. Users will subscribe on my website (built on node.js with express), get the first email right away, and then every Monday morning after that I'd like to send the next email in the series. I'll maintain how far along each subscribers is in my database, but I don't know the best way to trigger the Monday morning sends.
I'm running my site on IBM Bluemix, by the way. Maybe there's an easy way to do this with AWS... Although, nothing's ever been easy for me on AWS.
I haven't tried this but it looks possible based on there API.
Mandrill supports message scheduling. It also supports webhooks, you should schedule an email, and setup a webhook. Then when the message is sent it will trigger the webhook to schedule the next email.
https://mandrill.zendesk.com/hc/en-us/articles/205582667-Can-I-schedule-a-message-to-send-at-a-specific-time-
https://mandrillapp.com/api/docs/webhooks.JSON.html
I am dealing with subscriptions where a user is subscribed to a plan and it has an expiration.
So basically each user store has an expiration field.
I want to be able to get notified when a user plan is expired as soon as it is actually expired.
Right now, I have a job that runs on all users once a day and check if anyone has expired but ideally I would like to get a server postback or some sort of event whenever a user is expired without running this each day.
Can you think of any third party service / database / other tool that deals with these sort of things ?
A lot of services, Stripe for example, notify you with a webhook whenever a user's subscription is renewed / expired. Are they just running a job repeatedly like I am ?
Hope I made myself clear enough, would appreciate help in how to focus my search in Google as well.
My current stack is Mongodb, Node.js, AWS
Thanks
We do not know for sure, how Stripe handles it.
There are two solutions coming to my mind. Let's start with the simple one:
Cronjob
As you mentioned, you already have a Cronjob solution, but you can instead make it run each hour, or each 10 minutes. Just ensure you optimize your query to the maximum, so that it is not super-heavy to run.
It is attractive, easy to implement, very few edge cases, but as you might have though can be a performance drag once you reach millions of clients.
Timers
Implementation varries, and you need to worry about the edge cases, but the concept:
On day start* (00:00) query for all clients who are set to expire today, save them into array (in-memory). Sort the array by time (preferably descending).
Create timer to execute on last array's element time.
Function: If Client X expires now, query database to ensure subscription was not extended. Notify if it wasn't.
Remove Client X from the tracked array. Repeat step 2.
On day start* - Also run it on script launch.
I am using Apigee Usergrid to create a car service database. My scenario is as such.
A customer can book his car for a service with his mobile app. This creates a service request in the car service db .
Now, many a times, the customers do not turn up on the booked date and time. In such a case, I want to mark the slot NO-SHOW as soon the stipulated date and time gets over.
As of now, I have a job that runs every day to clear up all such no-shows. But now, we have a requirement to mark such slots NO-SHOW almost as soon as the stipulated hour + 2 passes by.
E.g. if the reservation is on 24th Sept at 0900hrs and the car owner doesn't show up even after 1100hrs, the reservation booking has to be marked NO-SHOW.
Is there a way to achieve this implicitly in user grid?
Unfortunately this isn't available out of the box. You might try wiring up a Node.js service in Edge (enterprise.apigee.com) to do this?