Slack postMessage posts message multiple times

Slack postMessage posts message multiple times

I want to post a message to Slack through a bot. When I use api/postMessage through the bot, the message gets posted multiple times (sometimes 2,3 and rarely once). When I post the same message through postman, the message is posted only once.

I want to post a message to Slack through a bot. When I use api/postMessage through the bot, the message gets posted multiple times (sometimes 2,3 and rarely once). When I post the same message through postman, the message is posted only once.

def start_bot(redis_object):
    print('In start bot')
    slack_client = SlackClient('xoxb-xxxx')
    bot_id = None
    PING_DELAY = 1 #1 sec
    response = ''
    if slack_client.rtm_connect(with_team_state=False):
        print("Starter Bot connected and running!")
        bot_id = slack_client.api_call("auth.test")["user_id"]
        while True:
            rtm_response = slack_client.rtm_read()
            #print(rtm_response)
            command, channel = parse_bot_commands(rtm_response,bot_id)
            if command:
                print("Channel",channel)
                response = handle_command(command, channel,redis_object)
                print(str(1),'########',response)
                requests.get('https://slack.com/api/chat.postMessage',
                    headers={'Authorization': 'xoxb-xxxx'},
                    params = {'text': response, 'channel': channel})
            time.sleep(PING_DELAY)
    else:
        print("Connection failed.")

print(str(1),'########',response) prints only once on the terminal but the message is still posted multiple times in the thread. Posting through slack_client.api_call method also posts multiple times.

rest python postman

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Basic Data Types in Python | Python Web Development For Beginners

In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.

What is REST API? An Overview | Liquid Web

What is REST? The REST acronym is defined as a “REpresentational State Transfer” and is designed to take advantage of existing HTTP protocols when used

Hire Python Developers

Are you looking for experienced, reliable, and qualified Python developers? If yes, you have reached the right place. At **[HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io")**, our full-stack Python development services...

Python REST API Tutorial - Building a Flask REST API

This Python REST API tutorial will teach you how to build a Python flask REST API. We will start by building a basic REST API then integrating that API with a Flask SQL-Alchemy Database. At the end of this video you will have a fully functioning REST API with Python and Flask.

Top Python Development Companies | Hire Python Developers

After analyzing clients and market requirements, TopDevelopers has come up with the list of the best Python service providers. These top-rated Python developers are widely appreciated for their professionalism in handling diverse projects. When...