-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
slack is posting two/three messages with chat_postMessage #693
Comments
Transferring this issue to slackapi/bolt-python |
Hi @kunalrc2022 👋🏻 Thanks for reaching out! I've transferred this issue to slackapi/bolt-python because it looks like you're using the Python framework instead of the JavaScript framework. Can you provide a complete code example of posting a message into Slack? Thanks for the steps to reproduce, but I think it will be helpful to understand when you're posting a message. For example, are you responding to an event or action? Some requests must be acknowledged and the Slack API will re-send the request multiple times when it's not acknowledge. This could be one reason why you're sending multiple messages. |
hey @mwbrooks thanks for looking into it. @app.message(re.compile("(TECHAWAY-)"))
def message_hello(message, ack,say):
ack()
'''
Having code logic and if else checks
""
res_out = app.client.chat_postMessage(channel=message['channel'],thread_ts = original_thread_id,blocks=block_final) |
Is there a way i can limit it's retry attempt count to 1 in the the above api call ? |
hello @mwbrooks /team team, could anybody please help me with the above message ? |
Hello @mwbrooks , @objectfox @episod @seratch hope you are doing well. |
@kunalrc2022 have you tried putting something into app.client.headers? Like |
Hello @objectfox , thanks for looking into this request . i have tried adding app.client.headers['X-Slack-Retry-Num'] = 1 before using chat_postMessage but still sometimes it sends multiple messages. Here is the piece of lines i am using in the code: |
If your Bolt app cannot respond to message events within 3 seconds for some reason, the Slack server-side can send retry requests up to 3 times. There is no way to prevent this behavior but you can check X-Slack-Retry-Num (retry_attempt in Socket Mode) value. To do this, you can use @app.use # or @app.middleware
def ignore_retry_request(request, ack, next):
if _is_retry(request): # implement this predicate function on your own
return ack()
next() # if this is not a retry, Bolt app should handle it See also:
I think I've answered your question here. Would you mind closing this issue now? |
Since we've already provided answers to the question here, let us close this issue now. That said, if you have anything further to discuss here, please don't hesitate to write in more 👋 |
Hello @seratch,Thank you for the detailed explanation. if _is_retry(request): # implement this predicate function on your own |
Hi @iwakiri0104, the |
Hello @seratch,Thank you for answering! |
@iwakiri0104 No, the |
@seratch Thanks for the detailed explanation. Is the extraction not working with this code? def _is_retry(request):
logging.info("request is:",json.dumps(request))
logging.info("request headers is:",json.dumps(request.headers))
if "X-Slack-Retry-Num" in request.headers:
return True |
@iwakiri0104 This issue is already closed. I will reply to your issue #731 |
Description
Describe your issue here.
I am using slack-bolt python framework for my slack bolt which is going through some logic. I am using chat_postMessage method to send a message from bot. But currently it is sending three messages even though it's having single API call. I read about it and notices that it can be avoided with making X-Slack-Retry-Num =1 in header.(https://api.slack.com/apis/connections/events-api#graceful_retries) But i am wondering how can i change the header of the api call in res_out = app.client.chat_postMessage(channel=message['channel'],thread_ts = original_thread_id,blocks=block_final)
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
package version:
node version:
OS version(s):
Steps to reproduce:
Expected result:
Bot should only post single message.
Actual result:
Bot is posting two/three same messages
Attachments:
The text was updated successfully, but these errors were encountered: