15
votes

When I receive a "message received callback" event from the Facebook Realtime API (webhooks) I want to fetch previous messages in the conversation. To do that I need the ID of the conversation thread.

https://developers.facebook.com/docs/messenger-platform/webhook-reference/message?locale=en_US

The event does not contain any information about the ID of the conversation thread (t_id). It only contains the message ID (mid).

https://developers.facebook.com/docs/graph-api/reference/v2.8/conversation

Is there a way to get the conversation thread ID?

2
I see here a similar discussion: stackoverflow.com/questions/19129017/… - Nutscracker
Sadly that doesn't help. "As of August 8, 2016, FQL will no longer be available and cannot be queried." I'm only using the Graph API. - John
Having this issue as well! - George Edward Portillo
@John, have you gotten anything? - George Edward Portillo
Sadly I didn't find a solution, yet. - John

2 Answers

4
votes

I thing there is an easier way to do this. You can use the user_id filter on conversations:

https://graph.facebook.com/v3.0/--PAGE-ID--/conversations?fields=senders&user_id=

See the Parameters section from here: https://developers.facebook.com/docs/graph-api/reference/page/conversations/

1
votes

There is no straight way of doing it. You can use the workaround below to loop conversation ids:

(a) Fetch all conversation ids with sender ids https://graph.facebook.com/v3.0/--PAGE-ID--/conversations?fields=senders

(b) lookup the user_id of the sender of the message. https://graph.facebook.com/v3.0/--MESSAGE-ID--?fields=from

(c) loop through conversation ids to find a match for the message user_id and get the thread_id.

PS: this is an expensive solution. Try to avoid it unless you really need it.