Improve flow for receiving NEW_INBOX_MESSAGE webhook and finding the corresponding message thread and which guest it came from.
Please improve the flow for receiving NEWINBOXMESSAGE webhook and finding the corresponding message thread and which guest it came from.
Currently, the only way for me to do this is (every single time I receive a webhook): receive the webhook, get the threaduid and agencyuid, pull ALL of the leads for that agency, then for EACH lead call the GET messages endpoint to get the message and check to see if the thread_uid matches to find the thread with the uid matching what was in the webhook. This is highly inefficient, both for my program and Hostfully as I need to pull a lot of data (all of the agency's leads) and make many API calls (one for each lead) every time a message is received, when just one call should suffice.
For a more efficient flow, I would need one of the following:
* leadUid included in the messages webhook. That way when I receive a message, I can just read the leadUid and plug it into GET messages to get the conversation. I would also know what guest sent the message (from the leadUid). OR
* GET messages could accept threadUid as a parameter, instead of leadUid. Then I could read threadUid from the webhook and plug it straight in to GET messages to get the conversation. In this case, you should also be sure to add information to either the webhook or the GET messages response (leadUid would be sufficient) that tells me which guest the message thread is with - otherwise I'm not sure how I would know.