Skip to main content

Send events to Zerobus Ingest from Twilio Data Destinations

info

Maintained by: Twilio, in its Data Destinations documentation. Databricks maintains the Zerobus Ingest steps.

Twilio lists the release status of the Databricks destination as Beta. Data Destinations is a Private Beta product, and Twilio states that it isn't a HIPAA Eligible Service or PCI compliant.

Twilio's Databricks destination streams each event over a gRPC connection to Zerobus Ingest. Zerobus Ingest writes it into a Unity Catalog Delta Lake table, so you don't need to run a message bus between Twilio and the table. After you finish these steps, the events of the types you subscribe to appear as rows in that table.

For every setting of the Databricks destination, see Twilio's Databricks destination. For the workspace URL and endpoint steps, see Get your workspace URL and Zerobus Ingest endpoint. For the service principal steps, see Configure authentication.

When to use this path​

Use this path in the following cases.

  • You send Twilio events through Twilio Data Destinations and want them in a Unity Catalog table.
  • You want any event type that Twilio Event Streams supports. Twilio states that the Databricks destination has no user identifier restriction.

Otherwise, to write your own client, see Choose an interface.

How it works​

The following describes how events move from Twilio to the table.

  • Schema: Twilio writes each event to the table twilio_events_<subscription-id> in your catalog and schema. The table has the columns event_id, event_type, event_timestamp, and payload.
  • Authentication: Twilio exchanges the service principal's client ID and OAuth secret for a short-lived OAuth token and sends the token as a bearer token on every request. Twilio doesn't send the OAuth secret itself to Zerobus Ingest.
  • SQL warehouse: Twilio uses the SQL warehouse one time, to create the table. Twilio streams every event after that directly into the table, and the warehouse isn't involved in delivery.
  • Delivery: Twilio delivers events at least one time. Twilio queues events for up to four hours, and it might deliver them out of order. Twilio says to use the embedded timestamps to reconcile duplicates or out-of-order events. Zerobus Ingest also delivers each record at least one time when the protocol provides a durability acknowledgment and the client retries records that aren't acknowledged, so a record can be written more than one time. See Delivery guarantees. For the Zerobus Ingest record size limit, see Record size.
  • Latency: Twilio states that an event is typically queryable within seconds, and that it doesn't maintain service-level agreements (SLAs) for Data Destinations latency. For the Zerobus Ingest side, see Latency.

Requirements​

You must have the following before you start.

  • A Twilio account with access to Data Destinations. Sign up for the private beta on Twilio's Data Destinations page.
  • Access to a Twilio region that supports creating Databricks destination subscriptions. Twilio lists the regions for the destination on its Databricks destination page and the regions for subscriptions on its setup page. This is a Twilio region, separate from the region of your Databricks workspace.
  • A Databricks workspace in a region that supports Zerobus Ingest. See Availability.
  • A service principal with a client ID and an OAuth secret, and the Workspace access entitlement. Zerobus Ingest requires the entitlement, and Twilio's page doesn't list it. See Configure authentication and Manage entitlements.
  • The workspace administrator or account administrator role, to create the service principal. See Add service principals to your account.
  • An existing catalog and schema. Twilio creates only the table, so the catalog and schema must already exist. See Table requirements. For the limits on schema location and endpoints that apply to this path, see Limitations.
  • Permission to grant privileges on the catalog and schema, for example, as their owner or with MANAGE. See Who can manage privileges?.
  • A SQL warehouse whose permissions you manage, for example, as its owner or with CAN MANAGE. See SQL warehouse ACLs.
  • Access to the Twilio Console, or to the Destinations API with a Twilio API key.

Create the service principal​

Create a service principal in Databricks, and generate an OAuth secret for it. Save the client ID, which is a universally unique identifier (UUID), and the OAuth secret. You enter both in Twilio when you create the destination.

On the service principal's Configurations tab, make sure that you select the Workspace access entitlement. For the steps, see Configure authentication.

Grant access to the catalog, schema, and SQL warehouse​

Grant the service principal the privileges on the catalog and schema. Twilio needs CREATE TABLE on the schema to create the destination table. Replace the placeholders with your values:

SQL
GRANT USE CATALOG ON CATALOG <catalog> TO `<client-id>`;
GRANT USE SCHEMA ON SCHEMA <catalog>.<schema> TO `<client-id>`;
GRANT CREATE TABLE ON SCHEMA <catalog>.<schema> TO `<client-id>`;

Replace <client-id> with the service principal's client ID. The MODIFY and SELECT privileges come later, on the table itself, in Grant table access.

Give the service principal the CAN USE permission on the SQL warehouse. The Unity Catalog grants don't include access to the warehouse.

Create the destination in Twilio​

In the Twilio Console, go to Data > Data Destinations > Destinations > Add destination subscription. Select the Databricks destination. Enter these values:

Setting

Value

Client ID

The service principal's client ID (UUID) from Create the service principal

Client Secret

The service principal's OAuth secret from Create the service principal

Workspace URL

Your workspace URL, <workspace-url>, with the https:// prefix

Zerobus Endpoint

The Zerobus Ingest host for your workspace, without the https:// prefix. The host form follows this table.

Catalog

Your catalog, <catalog>. You can't change it after you create the destination.

Schema

Your schema, <schema>. You can't change it after you create the destination.

SQL Warehouse ID

The ID of the SQL warehouse from Requirements

Setting

Value

Client ID

The service principal's client ID (UUID) from Create the service principal

Client Secret

The service principal's OAuth secret from Create the service principal

Workspace URL

Your workspace URL, <workspace-url>, with the https:// prefix

Zerobus Endpoint

The Zerobus Ingest host for your workspace, without the https:// prefix. The host form follows this table.

Catalog

Your catalog, <catalog>. You can't change it after you create the destination.

Schema

Your schema, <schema>. You can't change it after you create the destination.

SQL Warehouse ID

The ID of the SQL warehouse from Requirements

Zerobus Endpoint: <workspace-id>.zerobus.<region>.cloud.databricks.com

To find your workspace ID and region, see Get your workspace URL and Zerobus Ingest endpoint.

When you save the destination, Twilio validates the client ID and OAuth secret. The validation doesn't check the grants, or whether the catalog and schema exist.

To create the destination with the Destinations API instead, see Create a destination.

Create the subscription​

Create a subscription to select the event types that Twilio sends to the table. Enter a name for the subscription. Select the event types. Click Save subscription. For the full flow, see Set up a destination. For the event types, see Event types overview.

The first time you save a subscription, Twilio creates the table twilio_events_<subscription-id> in your catalog and schema.

Grant table access​

After Create the subscription creates the table, grant the service principal MODIFY and SELECT on it. Twilio lists these two privileges for ongoing writes and reads. Replace the placeholders with your values:

SQL
GRANT MODIFY, SELECT ON TABLE <catalog>.<schema>.twilio_events_<subscription-id> TO `<client-id>`;

Check the table​

Twilio doesn't offer a way to trigger a test event from the Console or the Twilio command-line interface (CLI). Wait for a real event of a type that you subscribed to, then query the table:

SQL
SELECT event_id, event_type, event_timestamp, payload
FROM <catalog>.<schema>.twilio_events_<subscription-id>
ORDER BY event_timestamp DESC
LIMIT 10;

The query returns up to 10 of the most recent events that Twilio delivered to the table, or no rows if none have arrived.

Troubleshooting​

If you created the destination in the United States (US1) region and Twilio can't deliver events, Twilio sends an error notification to its Debugger. While errors continue, Twilio repeats the notification every 20 minutes.

Symptom

Cause

Fix

Saving the destination fails with an auth error

The client ID or OAuth secret is wrong, or you revoked the secret in Databricks.

Check the client ID and OAuth secret in Databricks, and update the destination in Twilio.

Table creation fails after you save the subscription

The service principal is missing a grant on the catalog or the schema, or the CAN USE permission on the SQL warehouse.

Check the grants and the warehouse permission in Grant access to the catalog, schema, and SQL warehouse.

Delivery errors appear in the Debugger

The Zerobus Endpoint is in a different region from your workspace.

Confirm that the region in the Zerobus Endpoint matches your workspace's region. See Get your workspace URL and Zerobus Ingest endpoint.

Delivery repeatedly fails and retries, and no rows appear

Zerobus Ingest isn't available in your workspace's region. A failed connection looks like a transient outage, so check the region first.

Confirm that Zerobus Ingest is available in your region. See Availability.

Delivery errors appear in the Debugger, and events aren't retried

The table's columns don't match event_id, event_type, event_timestamp, and payload.

Don't modify the table that Twilio created. If the columns changed, restore the original columns.

No rows appear after an event of a subscribed type occurs

Either the event hasn't occurred yet, or the grants in Grant table access are missing.

Wait for a real event of a subscribed type, then check the grants in Grant table access.

Symptom

Cause

Fix

Saving the destination fails with an auth error

The client ID or OAuth secret is wrong, or you revoked the secret in Databricks.

Check the client ID and OAuth secret in Databricks, and update the destination in Twilio.

Table creation fails after you save the subscription

The service principal is missing a grant on the catalog or the schema, or the CAN USE permission on the SQL warehouse.

Check the grants and the warehouse permission in Grant access to the catalog, schema, and SQL warehouse.

Delivery errors appear in the Debugger

The Zerobus Endpoint is in a different region from your workspace.

Confirm that the region in the Zerobus Endpoint matches your workspace's region. See Get your workspace URL and Zerobus Ingest endpoint.

Delivery repeatedly fails and retries, and no rows appear

Zerobus Ingest isn't available in your workspace's region. A failed connection looks like a transient outage, so check the region first.

Confirm that Zerobus Ingest is available in your region. See Availability.

Delivery errors appear in the Debugger, and events aren't retried

The table's columns don't match event_id, event_type, event_timestamp, and payload.

Don't modify the table that Twilio created. If the columns changed, restore the original columns.

No rows appear after an event of a subscribed type occurs

Either the event hasn't occurred yet, or the grants in Grant table access are missing.

Wait for a real event of a subscribed type, then check the grants in Grant table access.

Additional resources​

The following pages cover the setup steps and the error reference.