Example: Receiving prospect updated webhook from email sequencing API
You can use a webhook handler to receive a prospect updated event from the email sequencing API and update the corresponding record in Attio. To add a webhook handler to your app:- create a file with the
.webhook.tssuffix. - The file must be placed under the
src/app/webhooksdirectory, and it mustexport defaultan async function. - The function must take an HTTP
Requestargument and must return an HTTPResponse.
src/app/webhooks/prospect-updated.webhook.ts
Response object, the App SDK will respond with a 500 status code by default.
Defining a webhook handler isn’t enough to make it usable. You’ll need to enable it programmatically and register it with the third-party service.
You can do this from any server function, but most of the time you’ll want to do it inside the connection-added event.
The connection-added event runs whenever an Attio user connects to a third-party service through your app.
If your event handler completes without throwing an error, the connection will be saved.
If it throws, the user will be asked to authenticate again.
Be sure to test your
connection-added events carefully. If something goes wrong, users won’t be
able to connect to third-party services.connection-added event handler to our app.
- The file must live in
src/app/events/connection-added.event.ts - The file must
export defaultan async function that takes a{ connection: Connection }argument.
src/app/events/connection-added.event.ts
prospect-updated webhook handler will be called.