Page MenuHomePhabricator

[GSoC Proposal 2018] Emoji Twitter bot for Commons images from NYPL fork
Closed, ResolvedPublic

Description

Personal Information

Name: Perside Rosalie Mondjo Tchelibou
Email: rosalieperside@gmail.com
Location: Cameroon Africa
IRC NickName: r054l13
Github Profile: https://github.com/rosalieper
Gerrit profile: https://gerrit.wikimedia.org/r/q/persiderosalie%2540gmail.com

Synopsis

Introduction

Wikimedia Commons is a Wikimedia Foundation project and an online repository of images videos and other media files. A Twitter bot is a type of bot software that controls a Twitter account via the Twitter API. This project aims at creating a Twitter bot similar to NYPLEmoji bot for pictures on Commons. If a user tweets an emoji to the bot, the bot should reply to the tweet with an image from Commons that represents the same emotion as the emoji. That is an image selected randomly from Commons, that matches the emoji. Note that the bot will not only use graphical emoji but also text based emoji ( as this: ;-) ).
This project will make it possible for most Wikimedia Commons pictures to be exposed to the world. Hence bringing more awareness to Commons.

Delivrables

  • Creation of a twitter developer application and new twitter account for the bot
  • Automatic startup and authentication of the twitter bot.
  • Set Up a community-maintained table mapping emoji to images
  • Bot replies to an emoji tweet with an image and a link to the image from Commons. At the moment the image will not be in preview status. It will just be the image, license and author ( and maybe a small description if the mentors approve of the idea ) with the link to the image
  • Setup project on tool labs for online testing.
  • Developer manual will be written for project

Possible Mentors

Primary mentors: @ArielGlenn, @D3r1ck01, @Dereckson
Co-mentor: @MelodyKramer

Implementation Approach

Pictures will be manually selected and mapped on to an emoji unicode in a JSON file. There will be 5-10 pictures and author name mapped to one emoji, such that the random selection is made from the list of available pictures for that emoji. Hence, making user experience amazing since the pictures change from time to time.
Once the bot receives an emoji, It is being converted to text/unicode, that will be used to search for an image in the json table.
There will be a blacklist of emoji as well, those emoji the bot will not reply to. A JSON array for the mapping of emoji unicode to picture could be similar to this.

{
    "emoji-unicode" "emoji-text":
           [
		"ImageUrl 1",
            	"ImageUrl 2",
		"ImageUrl 3"
          ]
     
}

The bot will listen to an event ‘tweet’ before replying. If the bot receives a tweet, the event will be emitted and then the action ‘reply_tweet’ executed. I will use the Stream API to listen to events emitted, the twit API will be to create a twit instance for requests to twitter’s APIs

Event:

stream.on('tweet', function (tweet) {
  ... 
})

Action:

reply_tweet.getText()

Project Timeline

Describing the timeline of my work with deadlines and milestones, broken down in 2 weeks including time I’m planning to allocate for investigation, coding, deploying, testing and documentation:
April 23 - May 14(week1-2)

  • Community bonding.
  • Put the project on Gerrit and necessary setup on Toolforge.
  • Make deeper search on the libraries or APIs related with NodeJS necessary for the project.
  • Communicate and interact with mentors and/or community member to get a few suggestions and ideas.

May 15 - May 28(week 3-4)

  • Create a new twitter app and account for the bot (with necessary permissions).
  • Learn and understand the NYPL Emoji bot.

May 29 - June 12 ( week 4-5)
(week 4)

  • Start implementation of the bot ( edit the configurations in the fork to suit the customer_key and customer_secret for our bot ).
  • Make a list of blocked emoji and implement a user friendly response for users who tweet such emoji to the bot.
  • Make a mapped list of emoji to Commons picture using JSON.

(week 5)

  • Edit the image.js and related necessary files file from the fork and add getAuthor() method, so it returns both image and Author to reply.js.
  • Deploy and Test application on Toolforge ( alongside fixing bugs found after testing).
  • First evaluation phase starts.
  • Bot receive tweet and reply with any dummy content for testing(DEMO).

June 13 - June 28 ( week 6-7 )
(Week 6)

  • First evaluation phase ends.
  • Implementation of bot continues till ready beta version (Edit script/reply.js and related necessary files in the fork to have author and Image returned to the twitter API).
  • Bot reply with image when tagged (DEMO)

(Week 7)

  • Bot reply with image and Author (DEMO)
  • Deploy and test application on Toolforge.

June 29 - July 12 ( week 8-9 )
(Week 8)

  • Second evaluation starts and end.
  • Continuous improvement of the bot from mentor comments and first evaluation.
  • Bot reply with both image, author and license(DEMO).
  • Add user friendly error emissions.

(Week 9)

  • Implement automatic start and authentication of the bot
  • Bot automatically starts (DEMO)
  • Implement twitter reply to text like emoji as ‘ :) ’ for the bot.
  • Reporting of work progress.

July 13 - July 29 (week 10-11 )
(Week 10)

  • Write unit tests for the various bot functionalities and make sure to have a large percentage of code coverage.
  • Bot reply to text like emoji (Demo)

(Week 11)

  • Improve on documentation of the code (code comments etc.).
  • Deploy and Test application on Toolforge.

July 29 - August 14 ( week 13-14 )

  • Reporting of work progress.
  • Continuous fixes for the bot where applicable.
  • Documentation of a developer manual for external contributors.
  • Submission of final work.

After Internship

  • Continue maintaining the bot.
  • Continue contributing to MediaWiki and it's extensions

Participation

Describing how I plan to communicate, progress and ask for help.

In other to keep track of the progress of my work, I will be documenting the work done every two weeks and on weekends, I will send via mail, a report of the progress to my mentors or use a blog for reporting, while keeping the wiki report page up to date.
I shall be communicating more on IRC, phabricator and email with the mentors and maybe on hangout and other means they will find appropriate or more comfortable to use. Also, I will do a lot of personal research on my own so as to have a minimum number of questions to ask the mentors, but of course communication is very important between mentor and candidate and as such, I will make sure to always be reachable and available.

About me

I am a final year student studying Computer Engineering at the University of Buea. I have been volunteering to the Wikimedia Foundation for more than two years and since then It has helped me improve on my skills and the more I code on MediaWiki the more I am comfortable in it. I am hoping If I get selected for this project to use it as my final year study project as it is a very exiting project, and I will learn a lot from it. My work as a volunteer in the foundation ranges from editing articles and Wikidata items to fixing bugs and reporting them. I am the program coordinator for the AMWD(Africa Wikimedia Developers) project and since the start of the project I have always been among the top 3 volunteers from Africa on MediaWiki (see here for 2017 and here for 2018). In addition to that, I volunteered to mentor GCI/17 (Google Code In 2017) @ Wikimedia.

Why me for this project
This project is an interesting one for me to learn from, just in developing my proposal I have learnt a lot and I wish to grap more. Also as a program coordinator for the AWMD program, If I get selected for such a program and complete it, it will be very encouraging for people in my community to get more involved into volunteering. Especially African girls who are my main targets presently. Added to that I have a considerable JavaScript knowledge and I am very fast at learning especially when I am excited about something.
Using this project as my final year study project will equally bring more awareness to the existence of Commons and other Wikimedia projects.
Basically my interest in this project is for 3 things.

  • Learn and improve on my skills
  • Use it as a means to impact my community and encourage female developers to volunteer for the foundation(As no African Female has ever been selected for a GSoC program in Wikimedia)
  • Use it as my final year project defense and bring more awareness to Wikimedia projects

Past Experience

  • Created a twitter bot for my personal twitter user account to favorite and re-tweet tweets with the Wikimedia hashtag and Wikipedia hashtag ( see here : for code )
  • When I just joined Wikimedia In 2015, I applied for OPW (Outreach Program for Women now called Outreachy) and I was a potential student for the project, "Implementation of HTML support for MediaWiki" but I was rejected because It was not a program for students and even my mentors didn't know about that till Last minute. Was quite a bad experience :(. But After that my interest in contributing to Mediawiki did not change and I kept on till date. Now I am interested in bringing in more volunteer developers from my community.
  • I have also got exciting experiences in Wikimedia like applying for scholarships to attend a conference and getting the scholarship. :)

Other Info

  • Last year I got a full scholarship to attend Wikimedia Hackaton but unfortunatle did not go due to visa issues. Also got a partial scholarship for Wikimedia Diversity conference.
  • This year I got one full Scholarship for WikiIndaba and was able to be present. I learnt alot from the experience and am ready to impact my community for the 2030 Wikimedia goals.
  • I also intend to present this project for the next WikiIndaba (if the mentors don't mind). For people to know it and use it
  • To see my past contributions you can check on my Gerrit profile (see Personal info for link) and phabricator profile

Details

Related Gerrit Patches:
labs/tools/Commons-twitter-bot : masterAdded more images to images.json
labs/tools/Commons-twitter-bot : masterRefactor repo to use Wikimedia's JS coding convention As per [[mw:Manual:Coding_conventions/JavaScript#Linting]].
labs/tools/Commons-twitter-bot : masterFixed an error test. "Image value assigned but not used"
labs/tools/Commons-twitter-bot : masterFixing a mistake in the documentation
labs/tools/Commons-twitter-bot : masterUpdated developer manual for project in docs/devManual
labs/tools/Commons-twitter-bot : masterAdded a developer manual containing the deployment on toolforge steps and more info.
labs/tools/Commons-twitter-bot : masterUpdated developer manual for project in docs/devManual
labs/tools/Commons-twitter-bot : Promise-dev[WIP]Added a script for Download of images.
labs/tools/Commons-twitter-bot : masterImplemented text-like emoji tweet reply
labs/tools/Commons-twitter-bot : masterEdited the test scripts to suit to changes for the bot
labs/tools/Commons-twitter-bot : masterUpdated the README.md and added license url to the tweet
labs/tools/Commons-twitter-bot : masterIncluded a prettier display of the author name and removed the html arround it
labs/tools/Commons-twitter-bot : masterAddition of license and author from mediawiki api but the author info still need some work.
labs/tools/Commons-twitter-bot : masterUpdated the README.md
labs/tools/Commons-twitter-bot : masterDocumenting Code
labs/tools/Commons-twitter-bot : masterAdded License and Author name to the images tweeted.
labs/tools/Commons-twitter-bot : masteradded a friendly reply to blocked emojies
labs/tools/Commons-twitter-bot : mastermodified the reply function and the reply_tweet class. Bot now reply to tweets
labs/tools/Commons-twitter-bot : masterImplemented image download as a small script
labs/tools/Commons-twitter-bot : Promise-devSome code to make the request and twit work asyncronously
labs/tools/Commons-twitter-bot : masterFirst set of pictures
labs/tools/Commons-twitter-bot : masterEmoji-Twitter Bot project initiallisation

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
rosalieper added a comment.EditedMar 24 2018, 7:58 PM

Hi! @Balaji030698 Thank you for that

rosalieper updated the task description. (Show Details)Mar 29 2018, 9:52 PM
rosalieper updated the task description. (Show Details)Mar 29 2018, 10:14 PM
rosalieper updated the task description. (Show Details)Mar 29 2018, 10:25 PM

Change 433620 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Emoji-Twitter Bot project initiallisation

https://gerrit.wikimedia.org/r/433620

Change 434272 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] First set of pictures

https://gerrit.wikimedia.org/r/434272

Change 433620 merged by D3r1ck01:
[labs/tools/Commons-twitter-bot@master] Emoji-Twitter Bot project initiallisation

https://gerrit.wikimedia.org/r/433620

Change 434272 merged by D3r1ck01:
[labs/tools/Commons-twitter-bot@master] First set of pictures

https://gerrit.wikimedia.org/r/434272

Ariel removed a subscriber: Ariel.May 25 2018, 9:18 PM

Change 437067 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] [WIP]Added a script for Download of images.

https://gerrit.wikimedia.org/r/437067

Change 440741 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@Promise-dev] Some code to make the request and twit work asyncronously

https://gerrit.wikimedia.org/r/440741

Change 441149 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@Promise-dev] [WIP]Added a script for Download of images.

https://gerrit.wikimedia.org/r/441149

Change 440741 abandoned by Rosalieper:
Some code to make the request and twit work asyncronously

https://gerrit.wikimedia.org/r/440741

Change 445849 had a related patch set uploaded (by Rosalieper; owner: tools.wm-commons-emoji-bot):
[labs/tools/Commons-twitter-bot@master] modified the reply function and the reply_tweet class. Bot now reply to tweets

https://gerrit.wikimedia.org/r/445849

Change 445891 had a related patch set uploaded (by Rosalieper; owner: tools.wm-commons-emoji-bot):
[labs/tools/Commons-twitter-bot@master] added a friendly reply to blocked emojies

https://gerrit.wikimedia.org/r/445891

rosalieper updated the task description. (Show Details)Jul 18 2018, 4:15 PM
rosalieper added a comment.EditedJul 18 2018, 5:15 PM

Work Progress for WMCommons Emoji Twitter Bot Project:

DONE

  • Creation of Bot Twitter account and twitter application
  • Made json mapping table for the BOT(not all emojies are maped yet).
  • Bot post Status and Reply with
    • Image
    • link to the image on Commons
    • emoji sent
    • image author
    • image Lisence
    • Bot is set on toolforge
  • Bot friendly reply for not yet mapped emojies or blocked emojies
  • Some Blogs written to share my experience in the project and the progress

WIP

  • Deploying the bot on toolforge

TODOs

  • Reply to text like emojies
  • Write Unit test for the project
  • Code cleanup and documentation (code commenting and updating README with the emoji-image json mapping format )

successful bot reply demo: crying face emoji

Change 437067 merged by D3r1ck01:
[labs/tools/Commons-twitter-bot@master] Implemented image download as a small script

https://gerrit.wikimedia.org/r/437067

Change 447443 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Added License and Author name to the images tweeted.

https://gerrit.wikimedia.org/r/447443

Change 447662 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Documenting Code

https://gerrit.wikimedia.org/r/447662

Change 445849 merged by D3r1ck01:
[labs/tools/Commons-twitter-bot@master] modified the reply function and the reply_tweet class. Bot now reply to tweets

https://gerrit.wikimedia.org/r/445849

Change 445891 merged by D3r1ck01:
[labs/tools/Commons-twitter-bot@master] added a friendly reply to blocked emojies

https://gerrit.wikimedia.org/r/445891

Change 447443 merged by D3r1ck01:
[labs/tools/Commons-twitter-bot@master] Added License and Author name to the images tweeted.

https://gerrit.wikimedia.org/r/447443

Change 447662 merged by D3r1ck01:
[labs/tools/Commons-twitter-bot@master] Documenting Code

https://gerrit.wikimedia.org/r/447662

Change 449251 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Updated the README.md

https://gerrit.wikimedia.org/r/449251

Change 450055 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Addition of license and author from mediawiki api but the author info still need some work.

https://gerrit.wikimedia.org/r/450055

Change 450255 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Included a prettier display of the author name and removed the html arround it

https://gerrit.wikimedia.org/r/450255

I am trying to deploy the bot on toolforge but get this error when I start the webservice.
with the command

webservice --backend=kubernetes nodejs start

I had updated my package.json and the bot normally runs when I run

npm start

but fails when I run it as a toolforge service

Change 450390 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Updated the README.md and added license url to the tweet

https://gerrit.wikimedia.org/r/450390

Change 450475 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Edited the test scripts to suit to changes for the bot

https://gerrit.wikimedia.org/r/450475

While working on the implementation of text-like emoji for the bot the following assumptions were made.

  • The last characters in a tweet sent is the emoji. I other words the emoji is not followed by some other characters.
  • The emoji comprises of exactly 3 characters.
  • Some example emoji to consider: ":-)", ":-P", ":-O", " :-(", " :-D"

Change 450619 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Implemented text-like emoji tweet reply

https://gerrit.wikimedia.org/r/450619

rosalieper updated the task description. (Show Details)Aug 6 2018, 5:47 PM

Change 449251 merged by Rosalieper:
[labs/tools/Commons-twitter-bot@master] Updated the README.md

https://gerrit.wikimedia.org/r/449251

Change 450055 merged by Rosalieper:
[labs/tools/Commons-twitter-bot@master] Addition of license and author from mediawiki api but the author info still need some work.

https://gerrit.wikimedia.org/r/450055

rosalieper added a comment.EditedAug 6 2018, 6:20 PM

Work progress from the preview comment.

DONEs

  • Bot reply to text like emojies.
    • Made the bot reply to include link to the license information and not just license name. (both for regular and text-like emojies)
  • Writen Unit test for the project.
  • Started cleanup of code and updated README.

WIP

  • GSoC Documentation
  • Deployment on toolforge

TODOs

  • Automatic bot start

Work Progress for WMCommons Emoji Twitter Bot Project:
WIP

  • Deploying the bot on toolforge

TODOs

  • Reply to text like emojies
  • Write Unit test for the project
  • Code cleanup and documentation (code commenting and updating README with the emoji-image json mapping format )

Sample tweet reply of Bot to text-like emoji => smile :-)

rosalieper updated the task description. (Show Details)Aug 6 2018, 6:26 PM

Change 450255 merged by Rosalieper:
[labs/tools/Commons-twitter-bot@master] Included a prettier display of the author name and removed the html arround it

https://gerrit.wikimedia.org/r/450255

Change 450390 merged by Rosalieper:
[labs/tools/Commons-twitter-bot@master] Updated the README.md and added license url to the tweet

https://gerrit.wikimedia.org/r/450390

Change 450475 merged by Rosalieper:
[labs/tools/Commons-twitter-bot@master] Edited the test scripts to suit to changes for the bot

https://gerrit.wikimedia.org/r/450475

Change 450619 abandoned by Rosalieper:
Implemented text-like emoji tweet reply

Reason:
Patch has limitations in th implementation of text-like emoji reply

https://gerrit.wikimedia.org/r/450619

Change 452197 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Added a developer manual containing the deployment on toolforge steps and more info.

https://gerrit.wikimedia.org/r/452197

Change 452584 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Created a developer manual for project in docs/devManual

https://gerrit.wikimedia.org/r/452584

Change 441149 abandoned by Rosalieper:
[WIP]Added a script for Download of images.

https://gerrit.wikimedia.org/r/441149

Change 452584 abandoned by Rosalieper:
Updated developer manual for project in docs/devManual

Reason:
having conflicts

https://gerrit.wikimedia.org/r/452584

Change 452197 abandoned by Rosalieper:
Added a developer manual containing the deployment on toolforge steps and more info.

Reason:
having conflicts
and trying to resolve

https://gerrit.wikimedia.org/r/452197

Change 452659 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Updated developer manual for project in docs/devManual

https://gerrit.wikimedia.org/r/452659

Change 452659 merged by Rosalieper:
[labs/tools/Commons-twitter-bot@master] Updated developer manual for project in docs/devManual

https://gerrit.wikimedia.org/r/452659

Change 452679 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Fixing a mistake in the documentation

https://gerrit.wikimedia.org/r/452679

Change 452679 merged by Rosalieper:
[labs/tools/Commons-twitter-bot@master] Fixing a mistake in the documentation

https://gerrit.wikimedia.org/r/452679

Josve05a removed a subscriber: Josve05a.Aug 14 2018, 4:17 PM
ArielGlenn closed this task as Resolved.Sep 6 2018, 8:26 AM

Still one thing from this proposal not done but it can be moved to a separate task. Maybe I'll file a few :-)

Change 464477 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Fixed an error test. "Image value assigned but not used"

https://gerrit.wikimedia.org/r/464477

Change 464477 merged by Rosalieper:
[labs/tools/Commons-twitter-bot@master] Fixed an error test. "Image value assigned but not used"

https://gerrit.wikimedia.org/r/464477

Change 464478 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Refactoring the code to follow the code cenvention stated here: https://www.mediawiki.org/wiki/Manual:Coding_conventions/JavaScript#Linting

https://gerrit.wikimedia.org/r/464478

Change 487452 had a related patch set uploaded (by Rosalieper; owner: Rosalieper):
[labs/tools/Commons-twitter-bot@master] Added more images to images.json

https://gerrit.wikimedia.org/r/487452