***

title: swml_user_event
slug: /reference/python/agents/function-result/swml-user-event
description: Send a custom user event through SWML for real-time UI updates.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[functionresult]: /docs/server-sdks/reference/python/agents/function-result

Send a custom user event through SWML. Events are delivered to connected
clients in real time, commonly used to drive UI updates in interactive
applications (e.g., updating a scoreboard, dealing cards, showing status).

## **Parameters**

<ParamField path="event_data" type="dict[str, Any]" required={true} toc={true}>
  Dictionary containing the event payload. Include a `"type"` key to help
  clients distinguish between different event types.
</ParamField>

## **Returns**

[`FunctionResult`][functionresult] — self, for chaining.

## **Example**

```python {11}
from signalwire import AgentBase
from signalwire import FunctionResult

agent = AgentBase(name="my-agent", route="/agent")
agent.set_prompt_text("You are a helpful assistant.")

@agent.tool(name="deal_cards", description="Deal cards and notify the UI")
def deal_cards(args, raw_data):
    return (
        FunctionResult("You have blackjack!")
        .swml_user_event({
            "type": "cards_dealt",
            "player_hand": ["Ace", "King"],
            "dealer_hand": ["7", "hidden"],
            "player_score": 21
        })
    )

agent.serve()
```