# addEvent

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

{% content-ref url="../events" %}
[events](https://docs.streamavatars.com/lua-scripting-api/api-reference-and-tips/events)
{% 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="keepalive" %}
[keepalive](https://docs.streamavatars.com/lua-scripting-api/api-reference-and-tips/global-functions/keepalive)
{% endcontent-ref %}

{% content-ref url="../events/read-chat" %}
[read-chat](https://docs.streamavatars.com/lua-scripting-api/api-reference-and-tips/events/read-chat)
{% endcontent-ref %}
