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