I’ve created an add-on that looks up a form submitter’s location via their IP address. Using this location, I want to send an email to one of our offices responsible for that region with the form’s information.
I’ve got the IP lookup and region lookup done. I’m looking for best practices regarding generating a new notification email that will go to the email address associated with the user’s region.
I’ve tried using the gform_notification hook. I got a nicely formatted email, but the code felt messy. Based on the value in the “To Email” field, I had to determine if the notification was intended for someone in our company or the external customer–we don’t want these emails going out to someone outside of the organization. Additionally, this left the forms admin putting a company address in the notification’s TO field, which would ultimately not be used because the IP address routing would change it.
Right now, I’m using the feed framework. I’ve got a feed set up, and it’s processing successfully. This feels a lot cleaner, since the forms admin just has to create a new feed for the form. However, I’m left with the question of how best to send an email out to the necessary office from within the process_feed() function. I can add a custom event (https://docs.gravityforms.com/notifications-custom-events-addon-framework/), but that requires the forms admin to create a notification in addition to the current feed (and we’re back to them putting in a TO address that will not be used).
Is there a way that I can streamline this? I’d like to minimize the amount of work required by the forms admin to hopefully just a few clicks–if that. If they can create a feed, and I can send out a notification in the background without any further work on their part, that would be great.