Messaging daily
Messaging volume, delivery and spend per day: the numbers on Twilio's Messaging Insights overview.
- Grain
- one row per day (UTC) x account x messaging service x direction x currency
- Built from
- 2Raw tables
- 2Staging
- 1Core
- 1Analytics
- Reads from Twilio
- messagemessaging_service
- Ships as
- Weld and dbt SQL, open source on GitHub
1-- core.twilio.messaging_daily
2-- Messaging volume, delivery and spend per day: the numbers on Twilio's Messaging
3-- Insights overview.
4--
5-- Grain: one row per day (UTC) x account x messaging service x direction x currency.
6-- Depends on: staging.twilio.message, .messaging_service
7--
8-- Day is the send time, or the creation time for messages that were never sent (queued,
9-- failed before sending, scheduled). `direction` is `inbound`, `outbound-api`,
10-- `outbound-reply` or `outbound-call`.
11--
12-- Delivery rate follows Messaging Insights: delivered over outbound messages that reached
13-- a final state (delivered, undelivered, failed, read). `sent` means Twilio handed the
14-- message to the carrier and never got a receipt back, which is common on some routes; it
15-- is counted separately and left out of the rate's denominator. The rate is per row:
16-- sum the counts and divide again when you aggregate.
17--
18-- Segments are what Twilio bills SMS on: a long message is several segments.
19--
20-- `messaging_service_name` is the service's current name, looked up after aggregation so
21-- the join cannot change any count. Messages sent straight from a number have no service.
22
23WITH daily AS (
24 SELECT
25 DATE(COALESCE(sent_at, created_at)) AS date,
26 account_sid,
27 messaging_service_sid,
28 direction,
29 currency,
30
31 COUNT(*) AS messages,
32 SUM(segments) AS segments,
33 COUNTIF(media_count > 0) AS messages_with_media,
34
35 COUNTIF(status IN ('delivered', 'read')) AS delivered,
36 COUNTIF(status = 'read') AS read,
37 COUNTIF(status = 'sent') AS sent_no_receipt,
38 COUNTIF(status = 'undelivered') AS undelivered,
39 COUNTIF(status = 'failed') AS failed,
40 COUNTIF(status IN ('received', 'receiving')) AS received,This model and the 3 it depends on. Deploy them together; refs like {{staging.…}} resolve to the matching folders in Weld, and the dbt view uses source() and ref().
How it counts. And where it stops.
Day is the send time, or the creation time for messages that were never sent (queued, failed before sending, scheduled). `direction` is `inbound`, `outbound-api`, `outbound-reply` or `outbound-call`. Delivery rate follows Messaging Insights: delivered over outbound messages that reached a final state (delivered, undelivered, failed, read). `sent` means Twilio handed the message to the carrier and never got a receipt back, which is common on some routes; it is counted separately and left out of the rate's denominator. The rate is per row: sum the counts and divide again when you aggregate. Segments are what Twilio bills SMS on: a long message is several segments. `messaging_service_name` is the service's current name, looked up after aggregation so the join cannot change any count. Messages sent straight from a number have no service.
Raw tables it reads
- raw.twilio.message
- raw.twilio.messaging_service
More Twilio models
Put Twilio in front
of your agents.
Connect Twilio, deploy the models, and ask questions in Claude, Cursor or ChatGPT. Free for 14 days, no credit card.