Jump to content

Bots

From Open Food Facts wiki
Slack channel

The bots are mainly written in Perl and Python, but it's relatively independent of the Product Opener code base; similar scripts could be written in pretty much any language.

General requirements about bots

  1. By default, your bot/script should be read-only - don't modify anything without a clear opt-in option. Eg. erase_all_products.sh --erase
  2. Do use time delays when modifying many products. One second, at least, is good practice.
  3. Never test your bots directly in production. Use staging environment: https://world.openfoodfacts.net/ (off / off)
  4. Your code should be published and reviewed. Please ask for permission on Slack to use the bot before you switch to .org
  5. Use a dedicated user for your bot, beginning or ending by "bot".
  6. Your bot should not have administrator rights, to avoid bad behaviors.

Writing bots in Perl

Bots in Perl have the advantage to modify products with the Product Opener Perl API, not using the http API.

The following script provide an example of good practices to write a Perl bot:

https://github.com/openfoodfacts/openfoodfacts-server/blob/main/scripts/remove_bad_nearly_empty_products_wo_images.pl

Writing bots in Python

Check the Python SDK for Open Food Facts: https://github.com/openfoodfacts/openfoodfacts-python

Writing bots in Javascript

Check the Javascript SDK: https://world.openfoodfacts.org/facets/editors/bot-tags-and-languages

Active bots

Robotoff

Our main bot. It applies confident automatic changes driven by our AI. See Artificial Intelligence.

https://world.openfoodfacts.org/facets/editors/roboto-app

Scanbot

Scanbot user profile Scanbot will look for the IP of scanned products, and will add the matching countries in the country field. Runs on demand. Not really reliable because of the IP system.

https://world.openfoodfacts.org/facets/editors/scanbot

remove_bad_nearly_empty_products_wo_images

[to be explained]

Tags and languages bot

https://world.openfoodfacts.org/facets/editors/bot-tags-and-languages

Retired bots

Autorotate-bot

https://world.openfoodfacts.org/facets/editors/autorotate-bot

Infobot

Infobot user profile Infobot will add some information on requests on many products

Fixbot

Fixbot user profile Fixbot removed bogus countries that appeared at some point in the products, due to a Product Opener bug Product http://world.openfoodfacts.org/product/8414606446629 (miel-quot-esencia-andalusi-quot / esencia-andalusi) : removing bogus countries, replacing with Spain

Code

  • Language: Perl

Ideas

tacite [12:53 AM] 
ça permettrait aussi de fusionner quand on a un "leclerc drive" comme magasin au lieu de "leclerc", c'est plus pertinent de laisser que "leclerc" vu que leclerc fait du picking dans son magasin

stephane [10:38 AM] 
C'est une idĂ©e intĂ©ressante. Pour l'instant dans magasins, on met en gĂ©nĂ©ral seulement le magasin oĂč la personne qui a ajoutĂ© le produit l'a achetĂ©, mais c'est vrai que ça serait intĂ©ressant. AprĂšs le problĂšme c'est que ça change tout le temps.

vince [2:55 AM] 
​_"quand on a un "leclerc drive" comme magasin au lieu de "leclerc", c'est plus pertinent de laisser que "leclerc" vu que leclerc fait du picking dans son magasin"_​
Je ne suis pas sĂ»r : Leclerc rend-il disponible ​*tous*​ ses produits via le drive? Tous les distributeurs le font-ils? Si certains distributeurs ne mettent Ă  disposition qu'une partie de leurs produits en drive, il pourrait ĂȘtre intĂ©ressant de savoir lesquels. En rĂ©sumĂ© et comme souvent, je suis partisan de laisser l'utilisateur saisir l'information la plus granulaire possible, quitte Ă  ​*afficher*​ une info simplifiĂ©e aggrĂ©gĂ©e, mais en continuant Ă  ​*stocker*​ l'info dĂ©taillĂ©e.

AprĂšs, je serais prudent quant Ă  l'ajout ​*automatique*​ du magasin sur la simple base de la marque distributeur : l'Ă©picerie de quartier en bas de chez moi est bourrĂ©e de produits de marques distributeurs (françaises et allemandes Ă  Paris, anglaises et polonaises Ă  Liverpool)... au double du prix, mais en bas de chez moi :wink:

tacite [1:21 PM] 
Tout les produits Leclerc Drive peuvent ĂȘtre trouvĂ©s dans Leclerc mais l'inverse pas forcĂ©ment

Checkbot

Checkbot is a little bot that will check Open Food Facts for obvious errors and report them on Slack, in the #bots channel.

Code

  • Language: Perl

Current checks

  • It checks if one of the nutrients has a value higher than 105g for 100g / 100ml.
  • It checks if sugar+starch > carbohydrates etc.
  • We'll be able to add rules like: sum of nutrients per 100g > 105g,

Ideas

  • Checkbot pingue sur Slack les personnes qui ont ajoutĂ© les produits (ou leur envoyer un mail d'ailleurs)
  • version live de checkbot qui pingue en continu
  • Ă©cart Ă  la moyenne de plus d'un facteur 9 (erreur de virgule)
  • What about a label we could add on the products that have a verified erroneous label like the ajolix-chili above? We could tag them "error on label" and have checkbot skip them. What would you think of that @stephane?

incorrect-nutrition-facts-on-label

UPCBot

UPCbot user profile UPCBot was used to normalize UPC codes. Since we now normalize them in Product Opener, it should not be used anymore.

Code

  • Language: Perl

Ideas for new bots

  • tacite [10:10 PM] New bot idea : Getting notifications for new complete products by contributors that have less than 5 completed products. That way we know we have to control it thoroughly

Get in touch

Slack channel

Archives

Writing bots in Ruby

gem install openfoodfacts