@@ -0,0 +1,1129 @@
+# ------------------%0A# Only for running this script here%0Aimport logging%0Aimport sys%0Afrom os.path import dirname%0A%0Asys.path.insert(1, f%22%7Bdirname(__file__)%7D/../../..%22)%0Alogging.basicConfig(level=logging.DEBUG)%0A# ------------------%0A%0A# export SLACK_API_TOKEN=xoxb-***%0A# python3 integration_tests/samples/issues/issue_506.py%0A%0Aimport os%0Afrom slack import RTMClient%0A%0Alogger = logging.getLogger(__name__)%0Aglobal_state = %7B%7D%0A%0A%0A@RTMClient.run_on(event=%22open%22)%0Adef open(**payload):%0A    web_client = payload%5B%22web_client%22%5D%0A    auth_result = web_client.auth_test()%0A    global_state.update(%7B%22bot_id%22: auth_result%5B%22bot_id%22%5D%7D)%0A    logger.info(f%22cached: %7Bglobal_state%7D%22)%0A%0A%0A@RTMClient.run_on(event=%22message%22)%0Adef message(**payload):%0A    data = payload%5B%22data%22%5D%0A    if data.get(%22bot_id%22, None) == global_state%5B%22bot_id%22%5D:%0A        logger.debug(%22Skipped as it's me%22)%0A        return%0A    # do something here%0A    web_client = payload%5B%22web_client%22%5D%0A    message = web_client.chat_postMessage(channel=data%5B%22channel%22%5D, text=%22What's up?%22)%0A    logger.info(f%22message: %7Bmessage%5B'ts'%5D%7D%22)%0A%0A%0Artm_client = RTMClient(token=os.environ%5B%22SLACK_API_TOKEN%22%5D)%0Artm_client.start()%0A

Add sample code for #506