> 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/events/servicecontroller.md).

# ServiceController

The service controller's purpose is to enable SA to allow hooking up custom stream services or chat-based programs to stream avatars. (Note: you cannot get the extension to work with it!)

First you must use the custom-lua streaming service found in Login Details.

<figure><img src="/files/RvPD0a95sZvXgHh4Qder" alt=""><figcaption></figcaption></figure>

Now you can create a custom command/script that will control spawning, user-status updates, and the input of chat messages.

```lua
function output(string_message)
    log('the app wants to send a message to your viewers...');
    log(string_message);
end

return function()
    local app = getApp();
    addEvent('luaPlatformOutput', 'output'); --attaches the event to output()

    local myUserId = 1234;
    local myUserName = 'clonzeh_lua';

    app.platformServiceSettings.SetStreamer(myUserId, myUserName);
    wait(3);
    app.platformServiceSettings.SetUserJoin(myUserId, myUserName);
    wait(3);
    app.platformServiceSettings.AddMessage(myUserId, myUserName, 'hello test');
    wait(3);
    app.platformServiceSettings.AddMessage(myUserId, myUserName, '!mass jump');
    wait(3);
    app.platformServiceSettings.AddMessage(myUserId, myUserName, '!currency');
    wait(3);
    app.platformServiceSettings.SetFollower(myUserId, true);
    app.platformServiceSettings.SetSubscriber(myUserId, true);
    app.platformServiceSettings.SetModerator(myUserId, true);
    wait(1);
    
    app.platformServiceSettings.PlatformCurrencyDonation(myUserId, myUserName, 50, 1000); 
    --they donated 50, the lifetime total is now 1000

    app.platformServiceSettings.CustomCommandRedemption(myUserId, myUserName, 'Redemption Title Here',
        'extra user input here');
    wait(1);
    app.platformServiceSettings.SetUserLeave(myUserId);
    keepAlive();
end
```

{% hint style="info" %}
Events are asynchronous coroutines.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/events/servicecontroller.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.
