# Calling a plug function from Lua Expression

**URL:** <https://community.silverbullet.md/t/calling-a-plug-function-from-lua-expression/2626>\
**Category:** Plug Development\
**Created:** [July 18, 2025, 8:38am UTC](https://community.silverbullet.md/t/calling-a-plug-function-from-lua-expression/2626 "2025-07-18T08:38:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dsolera](https://community.silverbullet.md/user_avatar/community.silverbullet.md/dsolera/32/1482_2.png) [@dsolera](https://community.silverbullet.md/u/dsolera)\
**Post date:** [July 18, 2025, 8:38am UTC](https://community.silverbullet.md/t/calling-a-plug-function-from-lua-expression/2626/1 "2025-07-18T08:38:11Z")

</div>

I’m trying to convert a block of space-lua to a self-contained plug on SilverBullet v2 that I’d like to share with the community.

The working principle is that you call a function in a Lua Expression block to render the interactive functionality of the plug (generated using the dom APIs), for example:

`${ mystuff.renderMyTools() }`

How do I achieve the same in a Plug? I’ve played with the .yaml file in the Plug template but I can’t seem to find a solution.

Any suggestions? Should I completely change my approach?

Thank you!

---

<div class="post-metadata">

**Author:** ![dsolera](https://community.silverbullet.md/user_avatar/community.silverbullet.md/dsolera/32/1482_2.png) [@dsolera](https://community.silverbullet.md/u/dsolera)\
**Post date:** [July 18, 2025, 8:42am UTC](https://community.silverbullet.md/t/calling-a-plug-function-from-lua-expression/2626/2 "2025-07-18T08:42:55Z")

</div>

OK, I just found the answer.

[API/system](https://silverbullet.md/API/system) → system.invokeFunction(“myplug.processData”, “input”, 123)

---

<div class="post-metadata">

**Author:** ![MrMugame](https://community.silverbullet.md/user_avatar/community.silverbullet.md/mrmugame/32/358_2.png) [@MrMugame](https://community.silverbullet.md/u/MrMugame)\
**Post date:** [July 18, 2025, 11:08am UTC](https://community.silverbullet.md/t/calling-a-plug-function-from-lua-expression/2626/3 "2025-07-18T11:08:39Z")

</div>

If I understand you correctly, you can also make it a syscall, there are plenty of examples in the core plugs. On my phone rn so I can‘t provide an example, but then you don‘t need the invokeFunction thing

---

<div class="post-metadata">

**Author:** ![dsolera](https://community.silverbullet.md/user_avatar/community.silverbullet.md/dsolera/32/1482_2.png) [@dsolera](https://community.silverbullet.md/u/dsolera)\
**Post date:** [July 18, 2025, 12:03pm UTC](https://community.silverbullet.md/t/calling-a-plug-function-from-lua-expression/2626/4 "2025-07-18T12:03:20Z")

</div>

I tried the syscall way as well but for some reason it wouldn’t find the function. Anyway, the invokeFunction works perfectly.

---

<div class="post-metadata">

**Author:** ![MrMugame](https://community.silverbullet.md/user_avatar/community.silverbullet.md/mrmugame/32/358_2.png) [@MrMugame](https://community.silverbullet.md/u/MrMugame)\
**Post date:** [July 18, 2025, 2:35pm UTC](https://community.silverbullet.md/t/calling-a-plug-function-from-lua-expression/2626/5 "2025-07-18T14:35:28Z")

</div>

Just for completeness sake of this thread, this is how it should work:

```yaml
doSomething:
    path: "./path/to/file.ts:functionName"
    syscall: "yourplug.doSomething"

```
