Obtener análisis de mensajería

Utilice este punto final para recuperar los análisis de mensajería de una determinada WhatsApp Business Account (WABA). Proporciona el número y el tipo de mensajes enviados y entregados por los números de teléfono asociados a la WABA.

Puede solicitar datos analíticos con una granularidad de media hora, diaria o mensual. Todas las marcas de tiempo se devuelven en UTC.

Ejemplo

A continuación encontrará la descripción de todas las variables utilizadas en cada fragmento de código:

ClaveDescripción
CHANNEL_MANAGER_WABA_ID

The waba_id of the WhatsApp Business Account (WABA) for which to retrieve the template analytics data.

VONAGE_API_KEY

Your Vonage API key (see it on your dashboard).

VONAGE_API_SECRET

Your Vonage API secret (also available on your dashboard).

CHANNEL_MANAGER_WHATSAPP_ANALYTICS_START

The start date and time in ISO-8601 format for the analytics data to be retrieved from, in the format YYYY-MM-DD.

CHANNEL_MANAGER_WHATSAPP_ANALYTICS_END

The end date and time in ISO-8601 format for the analytics data to be retrieved to, in the format YYYY-MM-DD. The maximum difference between the start and end dates is 90 days.

CHANNEL_MANAGER_WHATSAPP_ANALYTICS_GRANULARITY

The granularity of the analytics data to be retrieved.

Requisitos previos

Si no tiene una solicitud, puede crear uno. Asegúrese también de configure sus webhooks.

Escriba el código

Añada lo siguiente a get-messaging-analytics.sh:

curl -G https://api.nexmo.com/v1/channel-manager/whatsapp/wabas/"${CHANNEL_MANAGER_WABA_ID}"/messaging-analytics \
  -u "${VONAGE_API_KEY}:${VONAGE_API_SECRET}" \
  -H 'Accept: application/json' \
  --data-urlencode start=$CHANNEL_MANAGER_WHATSAPP_ANALYTICS_START \
  --data-urlencode end=$CHANNEL_MANAGER_WHATSAPP_ANALYTICS_END \
  --data-urlencode granularity=$CHANNEL_MANAGER_WHATSAPP_ANALYTICS_GRANULARITY

Ver fuente completa

Ejecute su código

Guarde este archivo en su máquina y ejecútelo:

bash get-messaging-analytics.sh