# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.streamavatars.com/lua-scripting-api/api-reference-and-tips/global-functions/addevent.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
