Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read a message, and how to get the id and other data #93

Open
ignacio-chiazzo opened this issue Jul 18, 2023 Discussed in #92 · 2 comments
Open

Read a message, and how to get the id and other data #93

ignacio-chiazzo opened this issue Jul 18, 2023 Discussed in #92 · 2 comments

Comments

@ignacio-chiazzo
Copy link
Owner

Discussed in #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!

@renatovico
Copy link
Contributor

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

@ignacio-chiazzo
Copy link
Owner Author

Thanks @renatovico. That's an interesting solution.

Please, submit any improvement/issue you have faced and I will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants