Skip to main content

🎬 Action Function

Action functions allow you to write custom buttons to the message toolbar for end users to interact with. This feature enables more interactive messaging, enabling users to grant permission before a task is performed, generate visualizations of structured data, download an audio snippet of chats, and many other use cases.

A scaffold of Action code can be found in the community section.

An example of a graph visualization Action can be seen in the video below.

Graph Visualization Action

Action

Actions are used to create a button in the Message UI (the small buttons found directly underneath individual chat messages).

Actions have a single main component called an action function. This component takes an object defining the type of action and the data being processed.

Example
async def action(
self,
body: dict,
__user__=None,
__event_emitter__=None,
__event_call__=None,
) -> Optional[dict]:
print(f"action:{__name__}")

response = await __event_call__(
{
"type": "input",
"data": {
"title": "write a message",
"message": "here write a message to append",
"placeholder": "enter your message",
},
}
)
print(response)

Example - Specifying Action Frontmatter

Each Action function can include a docstring at the top to define metadata for the button. This helps customize the display and behavior of your Action in Open WebUI.

Example of supported frontmatter fields:

  • title: Display name of the Action.
  • author: Name of the creator.
  • version: Version number of the Action.
  • required_open_webui_version: Minimum compatible version of Open WebUI.
  • icon_url (optional): URL or Base64 string for a custom icon.

Base64-Encoded Example:

"""
title: Summarize Text
author: @you
version: 1.0.0
required_open_webui_version: 0.5.0
icon_url: data:image/svg+xml;base64,<IMAGE STRING>...
"""