Coder Social home page Coder Social logo

swapagarwal / jarvis-on-messenger Goto Github PK

View Code? Open in Web Editor NEW
1.3K 1.3K 985.0 297 KB

:speech_balloon: A community-driven python bot that aims to be as simple as possible to serve humans with their everyday tasks

Home Page: https://m.me/J.A.R.V.I.S.on.Messenger

License: MIT License

Python 100.00%
assistant bot chat jarvis messenger python

jarvis-on-messenger's Introduction

JARVIS on Messenger

Just A Rather Very Intelligent System, now on Messenger!

Build Status Python PEP8 Gitmoji License Gitter Contributors Beginner Issues Pull Requests Closed

Messenger is now used by 1.2 billion people every month. With the launch of Send/Receive API, bots are about to take over.

Usage

JARVIS is at your service here.

Buy Me A Coffee Become a Patron!

Demo (Vimeo)

JARVIS on Messenger Demo

Why?

I created JARVIS with two goals in mind:

  1. It should have a lot of useful features (both fun and commonly used).
  2. Anyone can contribute to this project. (As this is module-based, anybody with a decent knowledge of Python can contribute.) One of the prime goals of this project is to lower the entry barrier into the world of open source.

Take a look at the contributing guidelines to see how easy it is to add your own code. I'll be waiting for your pull request! ๐Ÿ˜‰

A massive Thank You to all contributors, and congratulations to people who made their first open-source contribution! ๐ŸŽ‰

Modules

Feel free to add to this list by opening an Issue/Pull Request.

Name Sample Query Source (w/ Attribution)
anime death note anime Kitsu
book anything you want book Powered by Goodreads
bye goodbye ---
coin flip a coin ---
currency usd to eur rate Fixer.io
dice roll a die ---
dictionary define comfort Words API
fact tell me a fact JARVIS
hello Hi, Jarvis! ---
help What can you do? ---
joke tell me a joke JARVIS
lyrics paradise lyrics Powered by musiXmatch
movie iron man 2 movie plot
music songs by linkin park Spotify
news latest news Powered by NewsAPI
ping ping google.com Is it up?
quote random quote JARVIS
request report a bug
request a feature
---
thanks Thank you! ---
time time in seattle TimeZoneDB API
url shorten google.com
expand http://goo.gl/7aqe
Google URL Shortener
video videos of sia YouTube
weather weather in london Info provided by OpenWeatherMap
wiki wiki html MediaWiki API
xkcd show a random xkcd comic xkcd

More sample queries can be found here.

Structure

โ”œโ”€โ”€ modules/         # home for various features
โ”œโ”€โ”€ modules/src/     # code goes here
โ”œโ”€โ”€ modules/tests/   # tests go here
โ”œโ”€โ”€ data/            # home for shared data
โ”œโ”€โ”€ templates/       # for sending structured messages
โ”œโ”€โ”€ CONTRIBUTING.md  # contributing guidelines
โ””โ”€โ”€ jarvis.py        # the main bot

Local Development / Testing

  1. Clone this repo.
  2. Linux:
    a) Debian (Ubuntu, Linux Mint, etc.): sudo apt-get install python-dev libffi-dev libssl-dev
    b) Arch Linux: sudo pacman -S python2 libffi openssl
    c) Fedora: sudo yum install python-devel libffi-devel openssl-devel
    Windows: These should already be pre-installed in your Python bundle.
    Mac/OS X:
    a) If you install Python using brew, the relevant headers are already installed for you. In other words, you don't need python-devel.
    b) brew install pkg-config libffi
    export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.0.13/lib/pkgconfig/ # May change with libffi version
    pip install cffi
    c) brew install libtins
  3. pip install -r requirements.txt
  4. python jarvis.py
  5. Visit the following URLs to see results:
    http://localhost:5000/process/?q=<<YOUR_QUERY>> returns the intent of the query.
    http://localhost:5000/search/?q=<<YOUR_QUERY>> returns the search result of the query.

result

result

  • The "process" endpoint returns what module the system classifies your query e.g. a dictionary query, a song search, etc. Visit the following URLs to understand the output format:
    http://localhost:5000/process/?q=tell%20me%20a%20joke
    http://localhost:5000/process/?q=time%20in%20seattle
    http://localhost:5000/process/?q=convert%2025%20usd%20to%20eur

You can mock the results for local testing by adding your queries here.

  • The "search" endpoint returns the actual bot output, which you get when you interact with the bot using that query.

Note that for the search query to work, you have to set your own key (of the module that you want to test) in config.py

If you want a public endpoint, use the below button to deploy on Heroku and fill the relevant API keys that you would like to use:

Deploy

TL;DR for Beginners

  1. J.A.R.V.I.S. runs on Python 2
  2. For the search query to work, you have to set your own key (of the module that you want to test) in config.py
  3. The best place to ask anything: https://gitter.im/swapagarwal/JARVIS-on-Messenger
  4. Some issues are reserved for you! Low-Hanging Fruit
  5. If you're working on something, let everyone know by either creating an issue or commenting on an existing one so that work is not duplicated.
  6. Prefer using an IDE (Use PyCharm if you don't have any preference yet)

History

I started out with a rule-based model, but it didn't scale well so now I've shifted to Natural Language Processing. Rest assured, I'll strive to keep it as simple as possible so that you, yes you, can contribute!

If you'd like to contribute to the old model, you are welcome to do so as well. I've created a new branch legacy for this purpose. I'll be accepting Pull Requests to this branch also. ๐Ÿ˜„

P.S. If you've come this far, you might as well contribute. Looking for a place to start? Take a look at some of the low-hanging fruits!

References

jarvis-on-messenger's People

Contributors

a-edusei avatar achelikani avatar akarshhegde avatar akornor avatar astrophilic avatar azie-ginanjar avatar camdroid avatar coderowl avatar conormag94 avatar cskinner74 avatar gitter-badger avatar happyvalentinesdayswati avatar havanagrawal avatar jindalmohit avatar krizhan avatar matthiasrms avatar narendravardi avatar nikhilgeo avatar nolannicholson avatar sarthakmadaan avatar scottyla19 avatar seongju avatar shaishavgandhi avatar shanmukhateja avatar shnupta avatar shreyas95 avatar subhrajyotisen avatar swapagarwal avatar tdraebing avatar ushalnaidoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jarvis-on-messenger's Issues

Introduction Message Error

When I enter a query such as Who are you? , like so http://localhost:5000/process/?q=Who are you? the output I get is [null, {}].

It would probably be better if the output would be the content of the help variable under modules/src/help.py

Toss a coin feature

Hey, I think it would be nice to have a simple feature where the users can ask JARVIS to toss a coin and it randomly replies either 'Head' or 'Tail'. What do you think of it?

Add images in coin and dice module

As pointed out in #114,
Instead of displaying text, we can show an image or a gif of a coin showing the result (heads/tails).
This can be used in the dice roll as well.
See the attachment template. Use the Image type.

Jarvis keyword

In any line containing the word Jarvis, the reply seems to be the same as a greeting. Even if I say bye Jarvis!
Screenshot:
screenshot from 2016-06-07 10-18-42

Music Lyrics API : Genius

Hey

I think the Genius API would be great for serving lyrics. https://docs.genius.com/

Best thing about Genius is it's annotations which actually specify the meaning and context of particular lines in a song. Great value add-on for JARVIS

What are your thoughts on this?

Integrating JARVIS with dmenu

I think I have a great idea to integrate JARVIS with the pretty popular program launcher dmenu.
It's possible to write a simple script to point to the URL to make the query, but the only issue is the output text from the URL isn't pretty.

So... what do you say?

Caching results to limit requests to APIs

A lot of API guidelines have one thing in common; they either limit the number of requests made per day, or throttle requests, especially in case of free APIs.

In such a case, eventually, users will be unable to avail these services even if they are repeating a query.

For API's where real-time results are not required (eg: movies, books, jokes, wiki) and where caching is not against the policy of using the API, we could maintain a server-side cache of the results.

For queries with randomized results (like jokes, quotes), we could enter a small probability that the joke is picked up from the cache, rather than a new request (of course, this is just an example.. If we use our own joke/quote list, this won't be required, but the principle applies to most other API's we'll use eventually)

Use cases:

  1. I'm trying to decide which book to buy. I ask JARVIS for the rating of Throne of Glass. Then I ask it for Lady Midnight. But being my absent minded self, I forget the rating Throne of Glass had, and so I query it again. But alas, the query limit has been exceeded, and I can't see the rating anymore ๐Ÿ˜ž Must wait till tomorrow to decide.
  2. I have an upcoming math test ๐Ÿ˜ฑ I ask JARVIS to tell me about the Pythagoras theorem, but eventually, because of exam stress ๐Ÿ“š I forget it. So I ask it again, but alas, Wikipedia has crashed because it's exam time everywhere, and now I'm going to fail ๐Ÿ˜ญ

Rule based to NLP. Are you sure?

You shifted from a rule based system to an online NLP based system. Is it a complete shift? This would mean that the system would not work offline. This would adversely affect in case of slow internet connection.

Add offline data sources

Below is the list of modules that can make use of an offline data source:

  • fact
  • joke
  • quote

Add (Improve) the curated lists in data/* folder. Comment below if you'd like to take up one of these.

Python 3.5 - ImportError: No module named 'src'

After installing the dependencies, and running the python code

$ python -V; printf "\n\n"; python jarvis.py

I get the following error:

Python 3.5.1

Traceback (most recent call last):
File "jarvis.py", line 6, in
import modules
File "/tmp/JARVIS-on-Messenger/modules/init.py", line 2, in
from src import *
ImportError: No module named 'src'
`

Anime rating

Hey, I was thinking of working on the Anime rating feature. There is this Api from hummingbird.me that seems to be reliable and easy to use.

Check the api structure:

API-v1

Let me know your thoughts

Wiki: Jarvis

If I type wiki jarvis, I should be getting wiki data from the Jarvis' page. But it doesn't.
PS: There exists a wiki page for Jarvis.
Screenshot:
screenshot from 2016-06-07 09-57-58

Messages in continuation

The bot should remember what it said the last time, especially if the bot itself is asking a question.

screenshot from 2016-06-07 10-22-07

Travel

We could use API's like Skyscanner to find out travel information to a certain country. Maybe include the weather and a few accommodation links, maybe with the TripAdvisor API https://www.tripadvisorsupport.com/hc/en-us/articles/200615457

Could do something like :
Travel to Bali

Response:
Bali prices : Emirates $2000...etc
Weather: ...
Hotel links: [] [] []

Add a curated list of jokes

The API call in the joke module can be prevented by adding a curated list of jokes in the source file itself.
Pros:

  • Fewer API calls
  • Curated jokes (only include the ones that tickle your funny bone)
  • No offensive jokes (sometimes the API returns such type of jokes)

Con:

  • The curation effort (only one time!)

Show specific error messages

Right now, whenever an error occurs, a generic error message (something didn't work as expected) is displayed to the user, who can't determine what went wrong!

Restaurant rating

Given the name of a restaurant/cafe/pub, find out locations and a (user) rating.

Nice to have:

  1. Timings
  2. Average bill for 2
  3. Suggest location nearest to my current location
  4. Specify cuisine

Ambitious:

  1. Suggest 5 nearest restaurants based on my preference (eg: Veg, pizza, burger, italian, etc)

Sample queries:

  1. How is the food at Starbucks?
  2. Does Starbucks have good food?
  3. Is Starbucks a good place to eat?
  4. I'm hungry. Where's the nearest Starbucks?
  5. I'm craving for some good food. How's Starbucks?
  6. Do you know if Starbucks has good coffee?
  7. Does Starbucks have cheap food?
  8. What is the food rating for Starbucks.
  9. I want to eat at Starbucks. Will it be open?

Random fact module needs work

The random fact module needs some work. I have noticed two issues:

  1. The are exponential values not being superscripted and so we have values like 6.022e+23 in the output.
  2. There are few characters like the single quotation mark which is sometimes shown as \U2019.

This is a medium priority bug and I feel it can be assigned the Low hanging fruit label too.

Calculator feature

Hey, it would be pretty cool if JARVIS could return some basic calculation results . What do you think?

I also found an api for the same ๐Ÿ˜›
Calcatraz

Making general conversations

I think it'll be good if Jarvis can make conversations with us. Say I'm bored and neither of my close friends are online, so I'll text Jarvis like "Hey", " Hi" or "Hello" and so begins the conversation.

Response for 'bye'

Currently Jarvis responds with-
"I'm sorry; I'm not sure I understand what you're trying to say sir.
Try typing "help" or "request" for a "bye"
It should have a better system to deal with keywords such "bye" ,"thanks you" etc

Songs

If I enter a query for which the bot is unable to find a match, it doesn't reply anything (when I entered chrs brown instead of chris brown). I had to wait for some time to realize that ๐Ÿ˜
Also, no responses for wiz khalifa? ๐Ÿ˜ฑ
screenshot from 2016-06-07 10-46-18

Add some philosophic answers

It will be nice to add some answers to philosophic.
e.g is there a life after death?
do you believe in god?
do you have a soul?
The idea is taken from the popular virtual assistants like Google allo, and Cortana etc.

Can JARVIS post images or Gifs?

An example is, in the coin toss feature, instead of displaying text it shows an image or a gif of a coin showing the result (heads/tails). This can be used in the dice roll as well.

HTML entities in output

Query: define a superhero
Response: ... in popular children&#39;s and fantasy literature ...
Expected: ... in popular children's and fantasy literature ...

Random fact feature

Hey, There is this interesting api i found, which provides random facts related to numbers and dates. We could use this for now.
Numbersapi

Another one,
FactAPI
(returns data in xml)
Let me know your opinions ๐Ÿ˜ƒ

Show rating scale

Show the maximum rating, like 3.73 / 5 instead of just 3.73.

  • anime
  • book
  • movie

Add error handling

Below is the list of modules that need a output['error_msg'] in case of an exception:

  • anime
  • book
  • currency
  • dictionary Line#20
  • movie
  • music
  • time
  • wiki

Pick Random Feature

It would be nice if you could decide group decisions based on what you tell jarvis, who would pick one essentially at random. An example query could be

pick chinese mexican thai

to which Jarvis would reply a random entry

chinese. Have fun.

Not sure if you create the issue or PR first (new to contributing) but that's my idea if someone could help me out with next steps (i.e do I have to have code already done, or is what I have here good enough to get started)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.