# Creating a gateway function that calls a javascript function

**URL:** <https://forum.inductiveautomation.com/t/creating-a-gateway-function-that-calls-a-javascript-function/109374>\
**Category:** Module Development\
**Tags:** perspective, scripting\
**Created:** [August 5, 2025, 9:09am UTC](https://forum.inductiveautomation.com/t/creating-a-gateway-function-that-calls-a-javascript-function/109374 "2025-08-05T09:09:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [August 5, 2025, 1:36pm UTC](https://forum.inductiveautomation.com/t/creating-a-gateway-function-that-calls-a-javascript-function/109374/2 "2025-08-05T13:36:36Z")

</div>

Yup, you can do this. See Embr-Periscope for inspiration:

> [@Musson Industrial's Embr-Periscope Module](https://forum.inductiveautomation.com/t/musson-industrials-embr-periscope-module/99047/23):
>
> The Toasts Update [Periscope version 0.7.0](https://github.com/mussonindustrial/embr/releases/tag/%40embr-modules%2Fperiscope%400.7.0) includes toasts powered by [react-toastify](https://github.com/fkhadra/react-toastify). The toasts also work in the designer wink. Creating a Toast These are client-side toasts, therefore all the interaction is done via [system.perspective.runJavaScriptAsync](https://docs.mussonindustrial.com/ignition/embr-periscope/scripting/perspective/system-perspective-runJavaScriptAsync). periscope.toast is directly mapped to react-toastify's toast object, all features are supported. Simplest Example system.perspective.runJavaScriptAsync('''() =\> { periscope.toast('Your first toast!') }''') Embedded View To…

1. On the Perspective client-side, add your own message handler to the `ClientStore's` connection.

```js
clientStore.connection.handlers.set('your-protocol', (payload) => { ... } )

```

> <https://github.com/mussonindustrial/embr/blob/c27a4d9502738e45e98e5852a3a7b13f48d2a865/modules/periscope/web/src/extensions/runJavaScript.ts#L14>

1. On the Perspective gateway-side, trigger this message by sending a message to a `Page`.

```java
page.send("your-protocol", payload)

```

> <https://github.com/mussonindustrial/embr/blob/c27a4d9502738e45e98e5852a3a7b13f48d2a865/modules/periscope/gateway/src/main/kotlin/com/mussonindustrial/ignition/embr/periscope/scripting/JavaScriptFunctions.kt#L120>

---

_[View the full topic](https://forum.inductiveautomation.com/t/creating-a-gateway-function-that-calls-a-javascript-function/109374)._
