{"id":15046319,"url":"https://github.com/getninjas/whatsapp","last_synced_at":"2025-04-06T01:11:31.793Z","repository":{"id":48769331,"uuid":"125244361","full_name":"getninjas/whatsapp","owner":"getninjas","description":"A Ruby interface to WhatsApp Enterprise API.","archived":false,"fork":false,"pushed_at":"2024-01-18T18:01:43.000Z","size":346,"stargazers_count":108,"open_issues_count":4,"forks_count":24,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-30T00:09:49.209Z","etag":null,"topics":["api","gem","hacktoberfest","ruby","whatsapp"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/getninjas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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-03-14T16:47:52.000Z","updated_at":"2024-11-04T17:07:08.000Z","dependencies_parsed_at":"2024-01-18T18:28:29.798Z","dependency_job_id":null,"html_url":"https://github.com/getninjas/whatsapp","commit_stats":{"total_commits":104,"total_committers":10,"mean_commits":10.4,"dds":0.5865384615384616,"last_synced_commit":"62088b11c51ba63afb1f8390cf9e0c3b5fa37150"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getninjas%2Fwhatsapp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getninjas%2Fwhatsapp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getninjas%2Fwhatsapp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getninjas%2Fwhatsapp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/getninjas","download_url":"https://codeload.github.com/getninjas/whatsapp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419872,"owners_count":20936013,"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":["api","gem","hacktoberfest","ruby","whatsapp"],"created_at":"2024-09-24T20:52:59.180Z","updated_at":"2025-04-06T01:11:31.772Z","avatar_url":"https://github.com/getninjas.png","language":"Ruby","readme":"# WhatsApp\n\n[![Build Status](https://travis-ci.org/getninjas/whatsapp.svg?branch=master)](https://travis-ci.org/getninjas/whatsapp)\n[![Gem Version](https://badge.fury.io/rb/whatsapp.svg)](https://badge.fury.io/rb/whatsapp)\n\nA ruby interface to WhatsApp Enterprise API.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"whatsapp\"\n```\n\nOr manualy install\n```bash\ngem install whatsapp\n```\nthen require it when there's a need to use it\n```ruby\nrequire \"whatsapp\"\n```\n\n## Usage\n\n### Setting up a WhatsApp Business API Client\n\nFor the gem to be useful you need a WhatsApp Business account from Facebook. You can get it here: https://developers.facebook.com/docs/whatsapp/getting-started\n\nThat link also has the documentation for the Whatsapp api, which this gem aims to encapsulate.\nAfter that you should have to containers running, the `whatsapp-core` and `whatsapp-web`\n\n### Configuration\n\nBefore you can send messages there's some Configuration to be done. Set the base path, username and password for the `whatsapp-web` container\n\n```ruby\nWhats.configure do |config|\n  config.base_path = \"https://example.test\"\n  config.user = \"admin\"\n  config.password = \"secret password\"\nend\n```\n\nCreate an instance of the API client, which is going to be used from now on to interact with whatsapp\n\n```ruby\nwhats = Whats::Api.new\n```\n\n### Check Contacts\n\nTake a look [here](https://developers.facebook.com/docs/whatsapp/api/contacts) (WhatsApp Check Contacts doc) for more information.\n\n```ruby\nwhats.check_contacts([\"+5511942424242\"])\n\n# output:\n{\n  \"contacts\" =\u003e [\n    {\n      \"input\" =\u003e \"+5511942424242\",\n      \"status\" =\u003e \"valid\",\n      \"wa_id\" =\u003e \"5511942424242\"\n    }\n  ]\n}\n```\n\n### Send Message\n\nTake a look [here](https://developers.facebook.com/docs/whatsapp/api/messages/text) (WhatsApp Send Message doc) for more information.\n\n*The first parameter is the WhatsApp **username**!*\n\n```ruby\nwhats.send_message(\"5511942424242\", \"Message goes here.\")\n\n# output:\n{\n  \"messages\" =\u003e [{\n    \"id\" =\u003e \"BAEC4D1D7549842627\"\n  }]\n}\n```\n\n### Send HSM (templated) messages\nSend a kind of message that will not allow the receiver to flag it as spam since it's template was pre approved by WhatsApp, find more informations [here](https://developers.facebook.com/docs/whatsapp/message-templates)\n\n```ruby\nwhats.send_hsm_message(\n  \"+1234567890\",\n  \"cdb2df51_9816_c754_c5a4_64cdabdcad3e\",\n  \"purchase_with_credit_card\",\n  \"en\",\n  [ # ordered list of replacements that will happen at the template\n    {default: \"$10\"},\n    {default: \"300\"},\n  ]\n)\n\n# output:\n\n{\n  \"messages\": [{\n    \"id\": \"gBEGkYiEB1VXAglK1ZEqA1YKPrU\"\n  }]\n}\n```\n\n## Tests\n\n### Running tests\n\n```shell\nrspec\n```\n\n### Debugging specs\n\nYou can print all stubs using the environment variable `PRINT_STUBS=true` like this:\n\n```shell\nPRINT_STUBS=true rspec\n```\n\nAll stubs can be seen in the debugging session from the wiki: https://github.com/getninjas/whatsapp/wiki/Debugging\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetninjas%2Fwhatsapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgetninjas%2Fwhatsapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetninjas%2Fwhatsapp/lists"}