Socket
Book a DemoInstallSign in
Socket

warb

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

warb

1.0.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

Warb

A Ruby Gem focused on wrap all the functionalities and use cases of the WhatsApp Business API. With Warb you can send messages, audio, images, videos, locations and so much more.

Installation

TODO: Replace UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.

Install the gem and add to the application's Gemfile by executing:

bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG

If bundler is not being used to manage dependencies, install the gem by executing:

gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG

Configuration

If you don't have a facebook developer account, business portfolio and meta app created yet, please redirect to this official documentation to get started.

Rails

To use Warb in your Rails application first you will need to initialize it in config/initializers/warb.rb:

Warb.setup do |config|
  config.access_token = <YOUR_WHATSAPP_BUSINESS_ACCESS_TOKEN>
  config.business_id = <YOUR_WHATSAPP_BUSINESS_ID>
  config.sender_id = <YOUR_WHATSAPP_BUSINESS_PHONE_ID>
  config.adapter = <YOUR_ADAPTER_CHOICE> # defaults to Faraday.default_adapter (which is "":net_http" at the moment)
  config.logger = <YOUR_PERSONALIZED_LOGGER> # defaults to Logger.new($stdout)
end

If you would like a more direct way to use it, you can always instanciate it directly:

warb = Warb.new(
  access_token: <YOUR_WHATSAPP_BUSINESS_ACCESS_TOKEN>,
  business_id: <YOUR_WHATSAPP_BUSINESS_ID>,
  sender_id: <YOUR_WHATSAPP_BUSINESS_PHONE_ID>
  adapter: <YOUR_ADAPTER_CHOICE> # defaults to Faraday.default_adapter (which is "":net_http" at the moment)
  logger: <YOUR_PERSONALIZED_LOGGER> # defaults to Logger.new($stdout)
)

Usage

Initial Steps

Warb is simple to use — either directly from the module or via an instance.

The first and second usage modes share a common global configuration instance. The third mode, however, creates a new configuration instance, allowing you to define separate local configurations based on the global configuration (if it exists) when needed.

  • From the Warb module:
Warb.message.dispatch(recipient_number, message: "Hello from warb!")
  • From the Warb instance returned from .setup:
warb = Warb.setup { |config| ... }

warb.message.dispatch(recipient_number, message: "Hello from warb!")
  • From the Warb instance return from .new:
warb = Warb.new(...)

warb.message.dispatch(recipient_number, message: "Hello from warb!")

What more can we do?

You can also pass a block to the dispatch method, which look like this:

Warb.message.dispatch(recipient_number) do |builder|
  builder.message = "Hello from warb!"
end

Find all usage examples

We suggest heading to the examples/ directory, where you'll find documentation files with plenty of usage examples, organized by Resources (Resources are the types of messages you can send via WhatsApp using Warb).

You can also check the docs for a more structured overview of the available resources and their usage.

Webhook Support

You might want to take action in response to messages users send. For example:

  • A user sends a message like: “generate an image based on...”
  • You receive the message, so you mark it as read to let the user know their request was acknowledged.
  • Since the operation might take some time, you send a typing indicator to show that the request is being processed.

To enable this kind of flow, you’ll need to know when a message is received. For that, you’ll need to run your own server to listen for incoming webhook events and respond accordingly.

⚠️ Note: This gem does not provide built-in support for webhooks. However, you can look at examples/webhook.rb for a starting point on how to implement it. Also, check the official documentation for more details if you get stuck.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/warb.

FAQs

Package last updated on 01 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.