twilio / twilio-go

A Go package for communicating with the Twilio API.
MIT License
278 stars 40 forks source link

Get Latest Sent Message Index #111

Closed zs-codex closed 2 years ago

zs-codex commented 3 years ago

Issue Summary

Is there an API to get the last message that was sent to a conversation?

We're looking for a way to get (a rough) count of the number of messages in a conversation.

Technical details:

shwetha-manvinkurke commented 2 years ago

With the latest release, to get the last message I believe you can set the order to desc and limit to 1.

params := &conversationsV1.ListConversationMessageParams{}

params.SetOrder("desc")
params.SetLimit(1)

resp, err := client.ConversationsV1.ListConversationMessage("ConversationSid", params)

To get a count, not sure there is a more intuitive way other than just list all the messages and count them. Let me know if this helps at all. API reference here

zs-codex commented 2 years ago

Thank you @shwetha-manvinkurke