I’m working on a Rails application that uses Devise for user authentication. I need to automatically send user information (specifically the email address) to a Zapier webhook whenever someone successfully logs into my application.
I’ve been searching through documentation and forums but can’t seem to find a clear solution for this integration. I’m looking for a way to trigger a webhook call to Zapier that includes the logged-in user’s email address right after the authentication process completes.
Has anyone implemented something similar? I’m wondering if I should use Devise callbacks or if there’s a better approach to achieve this functionality. Any guidance on the best practices for this kind of integration would be really helpful.
I use Devise’s after_sign_in_path_for callback with a background job. Hook into the Warden callbacks instead of overriding controllers - keeps things cleaner. Add this to your ApplicationController: Warden::Manager.after_set_user do |user,auth,opts| WebhookJob.perform_later(user.email) if opts[:scope] == :user end. Then create a job that handles the Zapier webhook with error handling and retries. Your login won’t break if the webhook fails, and you’ll get better reliability. I’ve run this setup for six months with zero issues.
hey! i did smth similar last month. just override devise’s sessions_controller and place the webhook call right after super in the create action. make sure to handle any failures tho, don’t want to break the login if zapier is down.
I’ve had good luck using Devise’s trackable module with a custom concern. Made a module that extends the User model and hooks into the update_tracked_fields! method - Devise calls this during sign-in. You get access to the user object right when tracking info updates, which happens after auth succeeds. Just drop your webhook call in there with proper exception handling so auth doesn’t break if the API’s down. Nice thing is you don’t touch controllers or mess with Warden directly, and the timing works perfectly. Been running this for eight months with zero issues.