{"id":15563203,"url":"https://github.com/anastassia-b/imessage-chatbot","last_synced_at":"2025-04-23T23:20:50.894Z","repository":{"id":91025115,"uuid":"122031300","full_name":"anastassia-b/imessage-chatbot","owner":"anastassia-b","description":"💬 Recurrent neural network -- generates messages in your style of speech! Trained on imessage data. Sqlite3, TensorFlow, Flask, Twilio SMS, AWS.","archived":false,"fork":false,"pushed_at":"2018-04-10T03:15:01.000Z","size":1620,"stargazers_count":41,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T04:31:43.528Z","etag":null,"topics":["flask","imessage","recurrent-neural-networks","sqlite3","tensorflow","twilio"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anastassia-b.png","metadata":{"files":{"readme":"README.md","changelog":"change_encoding.py","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-19T07:34:48.000Z","updated_at":"2023-10-15T21:26:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"dae10a0e-2080-475d-8d5b-f1b227ffc0f3","html_url":"https://github.com/anastassia-b/imessage-chatbot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anastassia-b%2Fimessage-chatbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anastassia-b%2Fimessage-chatbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anastassia-b%2Fimessage-chatbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anastassia-b%2Fimessage-chatbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anastassia-b","download_url":"https://codeload.github.com/anastassia-b/imessage-chatbot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250529638,"owners_count":21445658,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","imessage","recurrent-neural-networks","sqlite3","tensorflow","twilio"],"created_at":"2024-10-02T16:20:29.844Z","updated_at":"2025-04-23T23:20:50.864Z","avatar_url":"https://github.com/anastassia-b.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# imessage-rnn\n\nIn-progress project: Building a neural network to learn an individual's style of speaking, and respond in their manner.\n\n**Current State:**\nTrained on my iMessages from the past year (many of which are with my mom). ~**60%** accuracy in letter-by-letter message generation. Disclaimer: I am not responsible for what the neural network generates!\n[Live Chat](http://chat.anastassia.io/).\n\n### Technologies\n\n* Training messages obtained with **SQL**\n* Recurrent Neural Network (RNN) built with **TensorFlow**\n* **Flask** app responds with generated messages to a **Twilio SMS** webhook\n* **AWS EC2**: Trained RNN on p2.xlarge instance, message generator deployed through t2.micro instance\n\n### Implementation\n\n\n#### 1. Extract Data\n\nData was extracted from the iMessage sqlite3 database, located in `/Library/Messages/chat.db`.\n\nGetting all messages from yourself:\n```sql\nSELECT text FROM message WHERE is_from_me = 1;\n```\n\nGetting all messages from another person:\n```sql\n-- get their handle_id\nSELECT * FROM handle WHERE id=\"(their_phone_number)\";\n-- use it to extract their messages\nSELECT text FROM message WHERE handle_id = \"(handle_id)\" AND is_from_me = 0;\n```\n\nSave the ascii messages to a .txt file and format it (ie; deal with emojis).\n\n#### 2. Process Data\n\nWith `dataset.py`, process the text data with parameters from `config.py` into _batches_. The input shape for the recurrent neural network is: (None, 32, 62, 256).\n\n#### 3. Train the Recurrent Neural Network model\n\nNow draw the rest of the owl\n\n#### 4. Use the model to generate text\n\nWhen a text is sent to our Twilio webhook, it hits out app, which generates a message and responds.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"/docs/message_ai.png\" height=\"600\"/\u003e\n\u003cimg src=\"/docs/webapp_ai.png\" height=\"600\"/\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003eChatbot available through both SMS and online chat.\u003c/p\u003e\n\nOur app is very basic. It has two backend routes, one to respond to texts via Twilio and one that responds to messages on the [online app version](http://chat.anastassia.io/).\n\n```python\n@app.route(\"/sms\", methods=['GET', 'POST'])\ndef sms_reply():\n    resp = MessagingResponse()\n    rnn_message = generate_message(459)\n    resp.message(rnn_message)\n    return str(resp)\n\n@app.route(\"/message\", methods=['GET'])\ndef message_reply():\n    return str(generate_message(459))\n```\n\nThe current step is to generate responses of varying natural lengths 🤔.\n\n### Next Steps\n\n- [x] Add a second layer to the model\n- [x] Improve RNN performance with LSTM cells\n- [x] In progress: Build web app version with **React**\n- [x] In progress: Generate responses of varying lengths\n- [ ] Look into Natural Language Processing (NLP)\n- [ ] Increase training data\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanastassia-b%2Fimessage-chatbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanastassia-b%2Fimessage-chatbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanastassia-b%2Fimessage-chatbot/lists"}