> For the complete documentation index, see [llms.txt](https://docs.streamavatars.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.streamavatars.com/lua-scripting-api/api-reference-and-tips/global-functions/addevent.md).

# addEvent

{% hint style="success" %}
Click Events for a list of available events.
{% endhint %}

{% content-ref url="/pages/iqU0qDpy3WUjGbyDLU4V" %}
[Events](/lua-scripting-api/api-reference-and-tips/events.md)
{% endcontent-ref %}

```lua
--note this specific event has 2 parameters
function yourFunctionName(user, string_message)
    log(user.displayName .. ' has said ' .. string_message);
end
 
return function()
    
    --attaches the event to yourFunctionName()
    addEvent('chatMessage', 'yourFunctionName'); 
    
      --make sure this script is kept alive so the event can be processed!
    keepAlive();
end
```

{% content-ref url="/pages/BZqDQ6dgraiWquJPmO26" %}
[keepAlive](/lua-scripting-api/api-reference-and-tips/global-functions/keepalive.md)
{% endcontent-ref %}

{% content-ref url="/pages/0HOYqU6agS16NIhwCm2P" %}
[Read Chat](/lua-scripting-api/api-reference-and-tips/events/read-chat.md)
{% endcontent-ref %}
