Use Webhook survey invitations to send an SMS when a client system reports an event, such as a closed support case. Each qualifying event can create a survey entry and queue a personalized browser-survey link. Confirm that your project allows the planned contact and prefill fields and that recipients have authorized the invitation.
Configure the respondent source
- From the survey's Summary tab, select Add respondent source, choose Webhook survey invitations, set the market and language, and save the draft.
- Enter the Twilio Account SID and Auth Token, and configure an SMS-enabled sender number or Messaging Service SID. Use the inbound webhook URL shown in the source for Twilio replies and STOP messages. See Twilio Text to Web setup.
- Set a random client webhook token of at least 32 characters. Keep it in the client system's secret store and send it as
Authorization: Bearer <token>on each request to the client webhook URL. Saving a new token replaces the previous one. - Include
{link}in the invitation template and keep the rendered invitation within one SMS segment. Use the configured delivery window and sender settings. - When the source is ready, put it In Field. Use Example request on the saved source to check the expected POST format and client webhook URL.
The client webhook receives survey events. The separate inbound URL receives Twilio replies. Configure both for the source.
Send an event and handle retries
Send the recipient's number in E.164 format. The default payload accepts phone_number, an optional customer_id, and an optional retry key. For example:
{
"phone_number": "+12025550123",
"customer_id": "customer-061",
"idempotency_key": "case-404"
}
Use a unique key for each new event. Reuse the same key for every retry of that event. You can send it in the payload as idempotency_key or in the Idempotency-Key header. If you provide both, use the same value. Without a key, each request is treated as a new event.
When Allow duplicates is off, the source uses the customer ID, or the normalized phone number if the ID is absent, to admit that customer once. When it is on, separate qualifying events can give that customer distinct links. Opening an existing link again uses the original survey entry while the source is live.
Map approved fields and prefill
Ask a superuser to configure a custom payload if the standard fields are insufficient. Declare the accepted fields, mark required fields, and map the event ID, customer ID and recipient number to distinct inputs. Keep the number required. Map only approved inputs to survey question IDs for prefill. If the invitation uses a field as a placeholder, make the field required so the message can render.
Check the outcome
| Outcome | What to do |
|---|---|
queued | The invitation is queued. The send window and dispatch rate still apply. |
duplicate_event or duplicate_customer | The request did not queue another invitation. |
inactive or opted_out | The source is inactive, or the recipient opted out. The request sends no SMS. |
HTTP 401, 413 or 422 | Check the credential, request size or payload fields before trying again. |
HTTP 409 or 503 | Reuse the same idempotency key if retrying an in-progress or interrupted request. |
Test with an authorized number and synthetic event data. Check the received invitation, any configured prefill, and the survey entry. Repeat the event with the same key and confirm that it sends only one invitation. Test a paused source and a number that has opted out. If Twilio's send outcome is unclear, check its delivery status before attempting another invitation.
