I'm working in an integration between Django and Chatfuel.
Right now the bot is almost complete, I have difficulties with the last task, I have certain tasks to do and each them have a due time, so three days before it expires I have to send a message to my client remindering him/her that he/she have to complete this task.
I could obtain the messenger_user_id after the first interaction with my bot, now, I know i have to run a cron job at a frequent interval to check the due date and if it's close, send a message through Broadcasting API.
But I don't know how to achieve that goal.
models.py
class Tasks(models.Model):
task = models.CharField(max_length=100)
objective = models.TextField()
created_date = models.DateTimeField(
default=timezone.now)
due_date = models.DateTimeField(
default=timezone.now)
def __str__(self):
return self.task
views.py #in here I obtain user's fb id
def save_fb_id(request, username, fb_id):
profile = Profile.objects.get(user__username=username)
if profile.fb_id != fb_id:
profile.fb_id = fb_id
profile.save()
return HttpResponse()