External system integrations with webhooks
You can easily integrate with external systems using webhooks. Use these examples to integrate with one of the listed systems or to create a custom configuration.
tip
Read this document to learn more about configuring hooks and webhooks.
Mailchimp
Use this configuration to send emails to users with Mailchimp
- The Ory Network
- Self-Hosted Ory Kratos Config
- hook: web_hook
config:
url: https://mandrillapp.com/api/1.0/messages/send
method: POST
# Encode the Jsonnet with Base64 and add the encoded string to 'body'.
body: base64://ENCODED_JSONNET
path/to/my/kratos.config.yml
- hook: web_hook
config:
url: https://mandrillapp.com/api/1.0/messages/send
method: POST
body: /path/to/my/mandrillapp.jsonnet
Request body Jsonnet:
info
For Mailchimp, you must pass the API key in the request body. This means you must include it in the Jsonnet snippet.
Mailchimp request body
function(ctx) {
key: "<Your-Api-Key>",
message: {
from_email: "hello@example.com",
subject: "Hello from Ory",
text: "Welcome to Ory! Have fun and happy hacking!",
to: [
{
email: ctx.identity.verifiable_addresses[0].value,
type: "to"
}
]
}
}
HubSpot
Use this configuration to add customers to your HubSpot contact list:
note
This setup creates a non-blocking webhook. Click here to learn more.
- The Ory Network
- Self-Hosted Ory Kratos Config
- hook: web_hook
config:
response:
ignore: true
url: "https://api.hubapi.com/crm/v3/objects/contacts?hapikey=<YOUR_API_KEY_HERE>"
method: POST
# Encode the Jsonnet with Base64 and add the encoded string to 'body'.
body: base64://ENCODED_JSONNET
path/to/my/kratos.config.yml
- hook: web_hook
config:
response:
ignore: true
url: "https://api.hubapi.com/crm/v3/objects/contacts?hapikey=<YOUR_API_KEY_HERE>"
method: POST
body: /path/to/my/hubspot_body.jsonnet
Request body Jsonnet:
HubSpot request body
function(ctx)
{
properties: {
email: ctx.identity.traits.email,
firstname: ctx.identity.traits.name,
// ...
},
}
Segment
Use this configuration to call Segment's Identify API and collect user-specific usage data:
- The Ory Network
- Self-Hosted Ory Kratos Config
- hook: web_hook
config:
auth:
type: "basic_auth"
config:
user: <segment_write_key>
password: ""
url: "https://api.segment.io/v1/identify"
method: POST
# Encode the Jsonnet with Base64 and add the encoded string to 'body'.
body: base64://ENCODED_JSONNET
- hook: web_hook
config:
auth:
type: "basic_auth"
config:
user: <segment_write_key>
password: ""
url: "https://api.segment.io/v1/identify"
method: POST
body: /path/to/my/segment_body.jsonnet
Request body Jsonnet:
Segment request body
function(ctx) {
userId: ctx.identity.id,
traits: {
email: ctx.identity.traits.email,
name: ctx.identity.traits.name,
newsletterConsent: ctx.identity.traits.consent.newsletter,
},
}