Class: Sendly::WhatsAppResource
- Inherits:
-
Object
- Object
- Sendly::WhatsAppResource
- Defined in:
- lib/sendly/whatsapp_resource.rb
Overview
WhatsApp resource — connect senders, manage their business profiles and templates, and check 24-hour windows.
WhatsApp is a first-class Sendly channel: connect a number you own,
create Meta-reviewed message templates, and send via
client.messages.send(channel: "whatsapp", ...).
Connecting a number is a one-time $19 setup (no monthly fee) and always
ends with a human step: Sendly::WhatsAppSignupResource#create returns a
connect_url that a person must open in a browser and log in with
Facebook to link their WhatsApp Business Account.
Two ways to reach a recipient:
- Inside a 24-hour window (the recipient messaged you in the last 24h): free-form text and media are allowed. Check with #window.
- Anytime: an approved template. Templates are reviewed by Meta (typically 24-48h) and categorized as authentication, utility, or marketing — pricing follows the category and destination country. Note: Meta has paused marketing template delivery to US (+1) numbers.
Instance Attribute Summary collapse
-
#senders ⇒ WhatsAppSendersResource
readonly
List connected numbers and manage their business profiles.
-
#signup ⇒ WhatsAppSignupResource
readonly
Connect numbers to WhatsApp.
-
#templates ⇒ WhatsAppTemplatesResource
readonly
Manage Meta-reviewed templates.
Instance Method Summary collapse
-
#initialize(client) ⇒ WhatsAppResource
constructor
A new instance of WhatsAppResource.
-
#window(from:, to:) ⇒ WhatsAppWindow
Check whether a 24-hour customer-service window is open between one of your WhatsApp senders and a recipient.
Constructor Details
#initialize(client) ⇒ WhatsAppResource
Returns a new instance of WhatsAppResource.
624 625 626 627 628 629 |
# File 'lib/sendly/whatsapp_resource.rb', line 624 def initialize(client) @client = client @signup = WhatsAppSignupResource.new(client) @senders = WhatsAppSendersResource.new(client) @templates = WhatsAppTemplatesResource.new(client) end |
Instance Attribute Details
#senders ⇒ WhatsAppSendersResource (readonly)
Returns List connected numbers and manage their business profiles.
619 620 621 |
# File 'lib/sendly/whatsapp_resource.rb', line 619 def senders @senders end |
#signup ⇒ WhatsAppSignupResource (readonly)
Returns Connect numbers to WhatsApp.
615 616 617 |
# File 'lib/sendly/whatsapp_resource.rb', line 615 def signup @signup end |
#templates ⇒ WhatsAppTemplatesResource (readonly)
Returns Manage Meta-reviewed templates.
622 623 624 |
# File 'lib/sendly/whatsapp_resource.rb', line 622 def templates @templates end |
Instance Method Details
#window(from:, to:) ⇒ WhatsAppWindow
Check whether a 24-hour customer-service window is open between one of your WhatsApp senders and a recipient.
Free-form text and media only deliver while a window is open (it opens when the recipient messages you and lasts 24h from their last inbound message). Outside a window, send an approved template.
647 648 649 650 651 652 653 |
# File 'lib/sendly/whatsapp_resource.rb', line 647 def window(from:, to:) raise ValidationError, "from is required" if from.nil? || from.to_s.empty? raise ValidationError, "to is required" if to.nil? || to.to_s.empty? response = @client.get("/whatsapp/window", { from: from, to: to }) WhatsAppWindow.new(response) end |