messaging

Plang: How do I send a reminder to write food entry


In the https://github.com/ingig/FoodDiaryApp, how can I make the app remind me to write my food entry. I would like it send me reminder at 8pm, since I should have stopped eating at that time

I don't know what to do to make this work, I know I need to write some plang code, but I am not sure how to do that


Solution

  • You need to change your Start.goal file, open the file in your text editor. Find the line - call !ShowTotalCalories, above or below(doesn't matter) that line add this code

    - call goal !SetupSchedule
    

    Then scroll to the bottom of the file and add this

    SetupSchedule
    - every day at 20:00, call !SendReminder
    
    SendReminder
    / Check if I have any entries today, I dont want to send if I have added already
    - select * from food_entries where date is today, write to %entries%
    / if I haven't created any entry, remind me
    - if %entries% is empty then
        - call goal !SendMessage content="Don't forget to add to your diary"
    

    now you need to build the code, open the terminal/command and go to the folder where Start.goal is located, run this command

    plang build
    

    It will now send you a message at 20:00 (8pm) to remind you to add your food entry.