ruby_whatsapp_sdk
ruby_whatsapp_sdk copied to clipboard
Read a message, and how to get the id and other data
Discussed in https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk/discussions/92
Originally posted by AlkhabazHasan July 18, 2023
Grate gem and well documented and, it save times of works, but isn't messages_api.read_message(sender_id: 1234, message_id: "wamid.HBgLMTM0M12345678910=")
needs more explanation?
It is so easy to get the id for sent message:
message_sent = messages_api.send_text(sender_id: sender, recipient_number: phone_numbers, message: "Hey there! it's Whatsapp Ruby SDK")
message_id = message_sent.data.messages.first.id
puts message_id
But for messages_api.read_message
I have to do it like this:
params["entry"][0]["changes"][0]["value"]["messages"][0]["id"]
Is there something I didn't get? I think I may need some help!
i did a big "parse" of possibilities in incoming message,
Basic i have created this architecture:
| WhatsAPP Hook -> Persist Incoming Message -> Send to Queue Job Incoming |
| Queue Job Incoming -> Loop Entries -> Loop Changes -> Process Envelope -> { Metadata, Contacts, Messages, Statuses } |
Metadata -> Extract destination phone Contacts -> Extract customers in conversation Messages -> Handle by type -> Persist the message Statuses -> Find Previous Message & Update the Status
When Message is Persisted & Handled the read_message is dispatched with id
It's is bit tedious but worked really well
Thanks @renatovico. That's an interesting solution.
Please, submit any improvement/issue you have faced and I will take a look.