Code not connecting to twitch chat

hi, im making a chat reader on twitch and am trying to test it, but my connection test isn’t coming trough and my chat messages on twitch’s end aren’t being sent towards my program,

any1 know how to fix this?

also im trying to do this using my offline chat, does this create problems?

code: (C#)

using System;

using [System.IO](;

using TwitchLib.Client;

using [TwitchLib.Client.Events](;

using TwitchLib.Client.Models;

namespace Chatbot


class Program


private static TwitchClient twitchClient;

static void Main(string[] args)


var credentials = new ConnectionCredentials("agentkittycat", Environment.GetEnvironmentVariable("TWITCH_ACCESS_TOKEN"));

twitchClient = new TwitchClient();

twitchClient.Initialize(credentials, "agentkittycat");

twitchClient.OnMessageReceived += OnMessageReceived;

twitchClient.OnConnected += OnConnected;




private static void OnMessageReceived(object sender, OnMessageReceivedArgs e)


if ([e.ChatMessage.Channel]( == "#agentkittycat")


Console.WriteLine("i got a message!");

// Get the newest message

var newestMessage = e.ChatMessage.Message;

// Save the message to a text file

File.WriteAllText("chat.txt", newestMessage);



private static void OnConnected(object sender, OnConnectedArgs e)


twitchClient.SendMessage("#agentkittycat", "Hello, I'm your chatbot and I'm now connected!");

Console.WriteLine("Chatbot connected to Twitch chat.");




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