Class: Zavudev::Resources::Messages
- Inherits:
-
Object
- Object
- Zavudev::Resources::Messages
- Defined in:
- lib/zavudev/resources/messages.rb,
sig/zavudev/resources/messages.rbs
Instance Method Summary collapse
-
#initialize(client:) ⇒ Messages
constructor
private
A new instance of Messages.
-
#list(channel: nil, cursor: nil, limit: nil, status: nil, to: nil, request_options: {}) ⇒ Zavudev::Internal::Cursor<Zavudev::Models::Message>
List messages previously sent by this project.
-
#react(message_id, emoji:, zavu_sender: nil, request_options: {}) ⇒ Zavudev::Models::MessageResponse
Some parameter documentations has been truncated, see Models::MessageReactParams for more details.
-
#retrieve(message_id, request_options: {}) ⇒ Zavudev::Models::MessageResponse
Get message by ID.
-
#send_(to:, attachments: nil, channel: nil, content: nil, fallback_enabled: nil, html_body: nil, idempotency_key: nil, message_type: nil, metadata: nil, reply_to: nil, subject: nil, text: nil, voice_language: nil, zavu_sender: nil, request_options: {}) ⇒ Zavudev::Models::MessageResponse
Some parameter documentations has been truncated, see Models::MessageSendParams for more details.
-
#show_typing(message_id, zavu_sender: nil, request_options: {}) ⇒ Zavudev::Models::MessageShowTypingResponse
Some parameter documentations has been truncated, see Models::MessageShowTypingParams for more details.
Constructor Details
#initialize(client:) ⇒ Messages
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Messages.
203 204 205 |
# File 'lib/zavudev/resources/messages.rb', line 203 def initialize(client:) @client = client end |
Instance Method Details
#list(channel: nil, cursor: nil, limit: nil, status: nil, to: nil, request_options: {}) ⇒ Zavudev::Internal::Cursor<Zavudev::Models::Message>
List messages previously sent by this project.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/zavudev/resources/messages.rb', line 44 def list(params = {}) parsed, = Zavudev::MessageListParams.dump_request(params) query = Zavudev::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "v1/messages", query: query, page: Zavudev::Internal::Cursor, model: Zavudev::Message, options: ) end |
#react(message_id, emoji:, zavu_sender: nil, request_options: {}) ⇒ Zavudev::Models::MessageResponse
Some parameter documentations has been truncated, see Models::MessageReactParams for more details.
Send an emoji reaction to an existing WhatsApp message. Reactions are only supported for WhatsApp messages.
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/zavudev/resources/messages.rb', line 76 def react(, params) parsed, = Zavudev::MessageReactParams.dump_request(params) header_params = {zavu_sender: "zavu-sender"} @client.request( method: :post, path: ["v1/messages/%1$s/reactions", ], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Zavudev::MessageResponse, options: ) end |
#retrieve(message_id, request_options: {}) ⇒ Zavudev::Models::MessageResponse
Get message by ID
16 17 18 19 20 21 22 23 |
# File 'lib/zavudev/resources/messages.rb', line 16 def retrieve(, params = {}) @client.request( method: :get, path: ["v1/messages/%1$s", ], model: Zavudev::MessageResponse, options: params[:request_options] ) end |
#send_(to:, attachments: nil, channel: nil, content: nil, fallback_enabled: nil, html_body: nil, idempotency_key: nil, message_type: nil, metadata: nil, reply_to: nil, subject: nil, text: nil, voice_language: nil, zavu_sender: nil, request_options: {}) ⇒ Zavudev::Models::MessageResponse
Some parameter documentations has been truncated, see Models::MessageSendParams for more details.
Send a message to a recipient via SMS or WhatsApp.
Channel selection:
- If
channelis omitted andmessageTypeistext, defaults to SMS - If
messageTypeis anything other thantext, WhatsApp is used automatically
WhatsApp 24-hour window:
- Free-form messages (non-template) require an open 24h window
- Window opens when the user messages you first
- Use template messages to initiate conversations outside the window
Daily limits:
- Unverified accounts: 200 messages per channel per day
- Complete KYC verification to increase limits to 10,000/day
Email recipient pre-flight: Email messages are validated automatically
before dispatch. Sends that would be a guaranteed hard bounce are failed instead
of sent, protecting your bounce rate: the message transitions to failed
(visible via GET /v1/messages/{messageId} and the message.failed webhook)
with errorCode set to EMAIL_INVALID_RECIPIENT (malformed address),
EMAIL_DOMAIN_NOT_FOUND (recipient domain has no MX or A records), or
EMAIL_RECIPIENT_SUPPRESSED (address is on your suppression list after a
previous bounce or complaint). Advisory signals (role addresses, disposable
domains) do not block sends — check them beforehand with
POST /v1/introspect/email.
156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/zavudev/resources/messages.rb', line 156 def send_(params) parsed, = Zavudev::MessageSendParams.dump_request(params) header_params = {zavu_sender: "zavu-sender"} @client.request( method: :post, path: "v1/messages", headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Zavudev::MessageResponse, options: ) end |
#show_typing(message_id, zavu_sender: nil, request_options: {}) ⇒ Zavudev::Models::MessageShowTypingResponse
Some parameter documentations has been truncated, see Models::MessageShowTypingParams for more details.
Mark an inbound WhatsApp message as read and display a typing indicator to the user while you prepare a response. The indicator is automatically dismissed when you send a reply, or after 25 seconds — whichever comes first. Only valid for inbound WhatsApp messages. Use this when a reply will take more than a couple of seconds (LLM agent, tool call, lookup) to improve the recipient's experience.
189 190 191 192 193 194 195 196 197 198 |
# File 'lib/zavudev/resources/messages.rb', line 189 def show_typing(, params = {}) parsed, = Zavudev::MessageShowTypingParams.dump_request(params) @client.request( method: :post, path: ["v1/messages/%1$s/typing", ], headers: parsed.transform_keys(zavu_sender: "zavu-sender"), model: Zavudev::Models::MessageShowTypingResponse, options: ) end |