Open ebruodok opened 2 weeks ago
Hi @ebruodok, thanks for your question.
I haven't checked how the Datadog app works, but one possible reason for your situation might be that the app does not set the top-level "text" property when sending a message via the chat.postMessage API. This means the app might only set "blocks" (the Block Kit message data representation) and skip the top-level "text." Although this request is accepted by the Slack server, we generally recommend including both text and blocks for a better user experience. In the channel UI, only the blocks data is used to display the message, but the text is used for mobile app notifications, accessibility features, and Slack's search engine index.
On your end, a feasible workaround is to scan the "blocks" property data to find the text data you're looking for. I'm not sure if this will meet your needs, but I hope it was helpful to you.
Thank you so much for responding! If I'm understanding your response correctly, it seems like if the Block Kit was used for the Datadog app, then we would we would not receive the block's text in the mobile app notification or be able to search for the text via Slack's search engine index. If that's the case, then it doesn't seem like the Datadog app is using blocks- I get phone notifications with the text on the Datadog message, and I am able to search keywords from the Datadog app message. Am I understanding this correctly?
If that's the case, message "subtype" events might be causing the confusion you're experiencing. As shown here: https://api.slack.com/events/message#subtypes, there are several additional patterns of message events. Many of these do not have "text" data at the top level (e.g., message_changed, message_deleted).
If your app aims to handle only newly posted messages, it's best to respond only to those patterns. You can check this code to learn how to filter subtype patterns: https://github.com/slackapi/bolt-python/blob/v1.21.2/slack_bolt/app/app.py#L885-L900
If this does not resolve your issue, I'd suggest adding debug logs to print the whole payload your app receives. Also, if the above suggestion resolves the issue, would you mind closing this issue?
Unfortunately the app I am creating needs to be able to access the text that the Datadog bot is sending in new messages so it can regex match.
I logged the message subtype and it says None
. What would you recommend as next steps? Can you point me to documentation to printing the whole payload please? Thanks.
Can you point me to documentation to printing the whole payload please?
I meant just printing the whole payload data this way:
@app.event("message")
def handle_message(payload):
logging.info(payload)
With this, you may be able to see variation of event data patterns. If the payload does not have "text" at top level, the payload pattern might be something different than you expect. If a message event really does not have "text" in it, at least "blocks" or "attachments" should exist. If that's the case, you may be able to use these data to respond to the bot message. That said, I still believe message event data usually has "text".
Also, if your app does not need to handle subtype events, the following code could be simpler:
@app.message("") # matches all newly posted messages
def handle_message(payload):
logging.info(payload)
To further assist you on this, sharing the actual message event data (rather than just the existence of "text" / "subtype" property) with us would be appreciated.
Hi team 👋 I created a slack app via the python sdk for tagging specific people in messages that the Datadog slack app sends to a channel. For context, we receive monitor alerts in a channel as messages sent by the Datadog app, and we have action items for on call engineers. The idea is that the slack app I created would be able to parse through the text of the message and tag people accordingly.
Unfortunately this isn't working, because seemingly there is no text from this message event.
How I attempt to get the text from the Datadog app's message:
Expected result:
I would expect to recognize the text of the message sent by the Datadog app. Logs should look something like this:
Actual result:
Logs show that the app I created is recognizing that an event is sent in a channel, and it correctly identifies the user ID and channel ID. However, it doesn't pick up any text. Logs:
Weirdly, if I copy and paste the same message and send it from my own user id, the app I created works as expected. It only fails on messages sent from the Datadog app agent. Is there a different way I should be getting the text from a message sent from a Slack app?
Requirements
For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. :bow:
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.