# Can I send a notification with custom content in code?

**URL:** <https://community.gravityforms.com/t/can-i-send-a-notification-with-custom-content-in-code/12774>\
**Category:** Get Help\
**Tags:** notifications, gform\_notification\_events, gravity-flow, gform\_after\_submission\
**Created:** [June 8, 2022, 12:43pm UTC](https://community.gravityforms.com/t/can-i-send-a-notification-with-custom-content-in-code/12774 "2022-06-08T12:43:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sundaramdesign](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/sundaramdesign/32/5360_2.png) [@sundaramdesign](https://community.gravityforms.com/u/sundaramdesign)\
**Post date:** [June 8, 2022, 12:43pm UTC](https://community.gravityforms.com/t/can-i-send-a-notification-with-custom-content-in-code/12774/1 "2022-06-08T12:43:42Z")

</div>

To clarify, I would like to send a custom admin notification without a specific form attached to it, populated with content generated from certain conditions in code. For example, a user submits a form, some code is run based on the content of the form entry which is ultimately used to make a REST API call. Then based on the result of that REST API call, let’s say receiving a list of resources available to that user, is it then possible to trigger a Gravityforms notification populated with that data?

I see that there is a GFCommon::send\_notification function, but looking at the code I’m not sure how I would apply it to this situation. Any thoughts?

---

<div class="post-metadata">

**Author:** ![sacom](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/sacom/32/53_2.png) [@sacom](https://community.gravityforms.com/u/sacom)\
**Post date:** [June 8, 2022, 1:25pm UTC](https://community.gravityforms.com/t/can-i-send-a-notification-with-custom-content-in-code/12774/2 "2022-06-08T13:25:49Z")

</div>

You can use the following filter to add your own custom Event for notifications: [gform\_notification\_events](https://docs.gravityforms.com/gform_notification_events/)

That will allow you create a notification in your form as usual, and select your custom event for the Event setting in the notification.

You can hook your code for the API call to [gform\_after\_submission](https://docs.gravityforms.com/gform_after_submission/), which gives you access to $form and $entry, then once you’re ready to trigger the notification, you would include your custom event as part of the function call, example:

```auto
GFAPI::send_notifications( $form, $entry, 'your_custom_event' );

```

---

<div class="post-metadata">

**Author:** ![JamieO](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/jamieo/32/2521_2.png) [@JamieO](https://community.gravityforms.com/u/JamieO)\
**Post date:** [June 15, 2022, 3:55am UTC](https://community.gravityforms.com/t/can-i-send-a-notification-with-custom-content-in-code/12774/3 "2022-06-15T03:55:53Z")

</div>

If you would like a less code intensive solution, I would recommend you look at [Gravity Flow](https://gravityflow.io).

- The [outgoing webhook step](https://docs.gravityflow.io/article/114-the-outgoing-webhook-step) includes response mapping into fields (including reading from within arrays or complex structures - such as translations\0\text). If the API is particular about structures it receives that the raw body format isn’t enough [gravityflow\_webhook\_args](https://docs.gravityflow.io/article/95-gravityflowwebhookargs) lets you customize through code. On the response side there is also [gravityflow\_entry\_webhook\_response\_mapping](https://docs.gravityflow.io/article/236-gravityflowentrywebhookresponsemapping)

- Notification steps (and all steps) can define conditions on whether to execute or not - with similar UI as you are used to for defining conditional logic to show/hide fields on a form.

- If following the notification you want them to approve a choice or provide more details the [approval step](https://docs.gravityflow.io/article/22-approval-process) or [user input step](https://docs.gravityflow.io/article/23-configuring-user-input-step)s may be of use to cover a larger part of your business process than just the initial form submission.

Cheers,  
Jamie

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/f/fef63f0599c45e0218c30d9f5d7ca8bff9b00189.png) [@system](https://community.gravityforms.com/u/system)\
**Post date:** [July 15, 2022, 3:56am UTC](https://community.gravityforms.com/t/can-i-send-a-notification-with-custom-content-in-code/12774/4 "2022-07-15T03:56:31Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
