ack() Not Triggered in Some Instances, Causing Multiple Ticket Creation
Description:
In my Slack bot implementation, when a user clicks a button, it triggers a specific @app.action, which raises a ticket and responds to the user. However, in some cases, the ack() function is not being triggered, leading to repeated actions and the creation of multiple tickets for a single request.
Code Snippet:
from slack_bolt.async_app import AsyncApp
from slack_bolt.adapter.socket_mode.async_handler import AsyncSocketModeHandler
from slack_sdk import WebClient
Slack_app_token = "APP TOKEN"
Slack_bot_token = "BOT TOKEN"
client = WebClient(token=Slack_bot_token)
app = AsyncApp(token=Slack_bot_token)
@app.action("raise_ticket")
async def helpcentral_ticket_trigger(ack, body, logger):
await ack()
{ticket function}
async def main():
handler = AsyncSocketModeHandler(app, Slack_app_token)
await handler.start_async()
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
logging.error("Keyboard Interruption")
Expected Behaviour:
- The
ack()function should be triggered, preventing the action from being repeated.
Actual Behaviour:
- In some instances, the
ack()function is not triggered, resulting in multiple tickets being created.
I am seeking guidance or solutions on how to ensure ack() is always triggered to prevent this issue from happening.
Hey @PrajwalNaik07 👋
This can be a confusing issue, but I have a few guesses on how we can debug this! The most helpful would be if you can share debug logs for both failed and successful events?
I'm also wondering if this app uses Socket Mode to receive events? It sometimes happens where multiple connections exist for an app and an unknown connection is handling events in an unexpected manner:
DEBUG:slack_bolt.App:on_message invoked: (message: {"type":"hello","num_connections":1,"debug_info":...
Please let me know if either of these hint at a problem or if the missed calls to ack are somehow predictable!
getting logs for failed:
2025-05-08 01:28:33 UTC [WARNING] Unhandled request ({'type': 'block_actions', 'block_id': 'Bc8LB', 'action_id': 'vertex_raise_ticket'})
---
[Suggestion] You can handle this type of event with the following listener function:
@app.action("vertex_raise_ticket")
async def handle_some_action(ack, body, logger):
await ack()
logger.info(body)
For successful I get the logs that I have written
Yes the app uses socket mode. We run the app in Google Kubernetes engine and have 2 pods enabled for the app
Hi @zimeg ,
Any updates on the above?
@PrajwalNaik07 We often have a lot of issues being addressed at once so I appreciate your patience here.
From the outputs above it appears that an action with the ID "vertex_raise_ticket" is being sent from a block action which is not being acknowledged with the "raise_ticket" listener shared earlier.
I'm not sure where this block action is defined, but changing this value to match the existing listener or adding the suggested snippet to handle this might be useful:
@app.action("vertex_raise_ticket")
async def handle_some_action(ack, body, logger):
await ack()
logger.info(body)
Hi @zimeg ,
This is the body block
"type":"block_actions",
"user":{
"id":"U059B7EJLF7",
"username":"-8530867091951762466",
"name":"-8530867091951762466",
"team_id":"TFEG37XL7"
},
"api_app_id":"A06MHJ7FN15",
"token":"eXas13k11gcaWyqfDDJICgBg",
"container":{
"type":"message",
"message_ts":"1747911329.656639",
"channel_id":"C06MGRA09HV",
"is_ephemeral":false,
"thread_ts":"1747911306.625009"
},
"trigger_id":"8938493634082.524547269687.cdb0b01bc6d6a881e64cd7f03cdf07d7",
"team":{
"id":"TFEG37XL7",
"domain":"a10662047",
"enterprise_id":"EDBV1AA7J",
"enterprise_name":"IS&T-Test"
},
"enterprise":{
"id":"EDBV1AA7J",
"name":"IS&T-Test"
},
"is_enterprise_install":false,
"channel":{
"id":"C06MGRA09HV",
"name":"privategroup"
},
"message":{
"user":"U06NT4F1MDW",
"type":"message",
"ts":"1747911329.656639",
"bot_id":"B06MPPNK1KR",
"app_id":"A06MHJ7FN15",
"text":"Ticket creation provided",
"team":"TFEG37XL7",
"thread_ts":"1747911306.625009",
"blocks":[
{
"type":"section",
"block_id":"yQSbo",
"text":{
"type":"mrkdwn",
"text":"*Hello, If you are looking for assistance from CloudTech/CSE Support please click the link to open a ticket and some one will follow up with you.*",
"verbatim":false
}
},
{
"type":"actions",
"block_id":"Bc8LB",
"elements":[
{
"type":"button",
"action_id":"vertex_raise_ticket",
"text":{
"type":"plain_text",
"text":"Open support request",
"emoji":true
},
"value":"Raise ticket"
}
]
}
]
},
"state":{
"values":{
}
},
"response_url":"https://hooks.slack.com/actions/TFEG37XL7/8938493633922/TNSiJnknFZgUexsydreCts6t",
"actions":[
{
"action_id":"vertex_raise_ticket",
"block_id":"Bc8LB",
"text":{
"type":"plain_text",
"text":"Open support request",
"emoji":true
},
"value":"Raise ticket",
"type":"button",
"action_ts":"1747911487.110339"
}
]
}
The action ID is: vertex_raise_ticket
And the way I have configured the function is as follows:
async def helpcentral_ticket_trigger(ack, body, logger):
log.setLevel(logging.DEBUG)
log.debug("Received event: %s", body)
await ack()
It is exactly the way you have mentioned above but still I see that sometimes the ack() is not triggered and repeates the issue with the following error:
---
[Suggestion] You can handle this type of event with the following listener function:
@app.action("vertex_raise_ticket")
async def handle_some_action(ack, body, logger):
await ack()
logger.info(body)
@PrajwalNaik07 Does the function you shared include a decorator:
@app.action("raise_ticket")
Or
@app.action("vertex_raise_ticket")
The first example shared shows the first one but this incoming event might be expecting to find the second one 🔍
👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.
As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.