narrow-hospital-35452
01/16/2025, 3:33 AMbrief-egg-61061
01/16/2025, 3:34 AMbrief-egg-61061
01/16/2025, 3:34 AMjsonnet function(ctx) if ctx.flow.type == "settings" && ctx.identity.traits.phone != ctx.flow.request_body.traits.phone then { event: "phone_number_changed", old_phone: ctx.identity.traits.phone, new_phone: ctx.flow.request_body.traits.phone } else error "cancel"
This template does the following: - Checks if the flow type is "settings" - Compares the phone number in the current identity traits with the phone number in the request body - If they're different, it returns an object with the event details - If they're the same (or if it's not a settings flow), it cancels the webhook 3. Configure the webhook: Set up your webhook in the Ory Console or configuration file, using the Jsonnet template above in the body
field of the webhook config. For more detailed information on configuring webhooks and using Jsonnet templating, you can refer to the [Ory documentation on webhooks](https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks). Remember that this approach assumes that the phone number is stored in the traits.phone
field of the identity. Adjust the field names if your schema is different. Also, note that this method will only trigger the webhook when the phone number is changed, regardless of whether other fields are also changed in the same settings update. If you need more complex logic, you might need to adjust the Jsonnet template accordingly.