messaging

Plang: How do I modify the message sent to me in the Food diary app


I am using the Food diary app, https://github.com/ingig/FoodDiaryApp

I want it to send me more information, like protein of the food I just ate, instead of the calories. I am not following my calories

Not sure how I can do this. I have never done any programming in Plang so this is not really clear to me.


Solution

  • Your first step is to figure out where that data that is being sent to you is being created.

    In this case it is in actions/Insert.goal, so start by opening that file in your favorite text editor (I use Visual Code or just Notepad/TextEdit)

    Now you need to find the text - call goal SendMessage (around line 22 or so), this is where the language is telling the app to send a message. The content= is the message that will be sent to you. We can modify this part.

    - call goal SendMessage content=%foodEntry.emojis% - Calories: %foodEntry.dish.totalCalories%
    

    Since you want protein instead of calories, your first step is to figure out how to find those proteins in the data. If you search in the Insert.goal file for protein, you will find something like this: %foodEntry.dish.totalProtein%

    Let copy that and replace it with the content we want

    - call goal SendMessage content=%foodEntry.emojis% - Protein: %foodEntry.dish.totalProtein%
    

    Next step is to build your code, this is needed for the application to start using your new code.

    Open up the terminal/command. You need to navigate to the folder where your FoodDiaryApp is located.

    Now run this command

    plang build
    

    It will then build your code, and you can run your app with the new code. 🎉