EventSub Redeems May Contain New Lines

Ran into an unexpected situation: if a user presses Shift+Enter in Twitch chat, a new line is created. Usually, it’s then stripped out or otherwise ignored when it’s received or displayed. However, it appears that in the case of channel point redeem notifications through EventSub, the new line is actually kept and parsed, with the user_input field containing an \n escape sequence:

{
    "subscription": {
        "id": "c1c81b94-162a-4f56-a13d-70fa8f00b9a4",
        "status": "enabled",
        "type": "channel.channel_points_custom_reward_redemption.add",
        "version": "1",
        "condition": {
            "broadcaster_user_id": "548015560",
            "reward_id": ""
        },
        "transport": {
            "method": "webhook",
            "callback": "[redacted]"
        },
        "created_at": "2023-11-08T17:57:52.428993066Z",
        "cost": 0
    },
    "event": {
        "broadcaster_user_id": "548015560",
        "broadcaster_user_login": "realityripple",
        "broadcaster_user_name": "RealityRipple",
        "id": "4e500bc5-8c81-4d9b-9be9-5b4feb97a893",
        "user_id": "548015560",
        "user_login": "realityripple",
        "user_name": "RealityRipple",
        "user_input": "this is\na test",
        "status": "fulfilled",
        "redeemed_at": "2023-11-20T18:27:35.969349662Z",
        "reward": {
            "id": "c3f3a3d1-3236-43a1-b0d9-0228b225b20d",
            "title": "Start a Conga Line",
            "prompt": "Trigger the Conga Kappagen",
            "cost": 11
        }
    }
}

I’m not sure if you want to strip them entirely and call it solved, but if there’s any case for keeping them, PLEASE mention it in the documentation, as this was completely unexpected behavior.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.