You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RTM API example for just parroting messages received
Daigo Tsubouchi edited this page May 16, 2020
·
1 revision
RTM API example for just parroting messages received
This is a simple example for receiving a message and sending back the same message, using RTM API.
classRTMParrotExample{staticvoidMain(string[]args){ManualResetEventSlimclientReady=newManualResetEventSlim(false);SlackSocketClientclient=newSlackSocketClient(YOUR_AUTH_TOKEN);client.Connect((connected)=>{// This is called once the client has emitted the RTM start commandclientReady.Set();},()=>{// This is called once the RTM client has connected to the end point});client.OnMessageReceived+=async(message)=>{// Handle each message as you receive themawaitTask.Run(()=>client.SendMessage(null,message.channel,message.text));};clientReady.Wait();Console.ReadKey();}}
Note: You must wrap client.SendMessage to async function; otherwise client.OnMessageReceived would be fired only once.