Lets assume you have a ERP system and need to sync back a message log for every contact across channels from Hellomateo.

In essence, there are two ways to sync back messages to the external system:

  1. Push Sync: Hellomateo pushes messages to the external system via a webhook.
  2. Pull Sync: The external system pulls messages from Hellomateo via the API.

We recommend using the Push Sync, as it is more efficient and real-time. However, if you are not able to set up a webhook on your external system, you can use the Pull Sync.

To set up a Push Sync, you need to create a webhook in Hellomateo that sends contact updates to your external system. Learn how to set up and consume webhooks in the Setting up Webhooks guide. Upon receiving a webhook, you can either use the contact_id of the conversation directly from the webhook payload, or query external_id of the contact:

curl "https://integration.getmateo.com/api/v1/contact?select=external_id&contact_id=eq.<conversation.contact_id>"

The webhook payload also contains the raw_content of the message, which is either the raw text or for emails the HTML content. You can use this to update the message log in your system.

The Pull Sync is a bit more complex, as you need to periodically poll the Hellomateo API for changes. We recommend setting up a cron job that runs at least every night to fetch all messages that were updated since the last run.

curl "https://integration.getmateo.com/api/v1/message?select=id,raw_content,timestamp&contact_id=eq.1&timestamp=gte.2021-01-01T00:00:00Z&limit=10&offset=0"

You can leverage all of the available filtering options to only retrieve the data you need, and pagination to retrieve the data in chunks. If you have a lot of messages per period, you might hit our rate limits. In this case, migrate to the Push Sync.