question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discrepancies in `app.client.chat.postMessage`

See original GitHub issue

Description

I have a Slack app in production and a sandbox app. Both have the same scopes and use the same exact code. However, the response from calling app.client.chat.postMessage return different things for both apps. I’ve confirmed they are using the same versions of all npm packages.

The response from calling app.client.chat.postMessage in a private channel from my sandbox app:

{ ok: true,
  channel: 'xxx',
  ts: '1581555680.000400',
  message:
   { type: 'message',
     subtype: 'bot_message',
     text: 'This content can\'t be displayed.',
     ts: '1581555680.000400',
     username: 'xxx',
     bot_id: 'xxx',
     blocks: [ [Object] ] },
  response_metadata:
   { scopes:
      [ 'identify', 'bot', 'commands', 'chat:write', 'chat:write:bot' ],
     acceptedScopes: [ 'chat:write:bot' ] } }

The response from calling app.client.chat.postMessage in a private channel from my production app:

{
   ok: true,
    channel: 'xxx',
    ts: '1581556112.000400',
    message: {
      bot_id: 'xxx',
      type: 'message',
      text: "This content can't be displayed.",
      user: 'xxx',
      ts: '1581556112.000400',
      team: 'xxx',
      bot_profile: {
        id: 'xxx',
        deleted: false,
        name: 'xxx',
        updated: 1581441204,
        app_id: 'xxx',
        icons: [Object],
        team_id: 'xxx'
      },
      blocks: [ [Object] ]
    },
    response_metadata: {
      scopes: [ 'identify', 'chat:write' ],
      acceptedScopes: [ 'chat:write' ]
    }
  }

Why are the response shapes different? I have a problem where the apps have slightly different functionalities when posting a message, even though they are mirrors of each other.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I’ve read and understood the Contributing guidelines and have done my best effort to follow them.
  • I’ve read and agree to the Code of Conduct.
  • I’ve searched for any related issues and avoided creating a duplicate issue.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
seratchcommented, Feb 15, 2020

If the bot user is not in the channel, you get the channel_not_found error. If the bot user is not in the conversation (DM, channel), it’s not possible to send a message there.

I’ve answered your similar question here before. If a user runs a slash command or clicks a button, your app can respond to it using response_url even if the app’s bot user is not in the conversation.

This question seems to be another one. As everything about the original question is already clear, could you close this issue now? Thanks!

0reactions
jackleincommented, Feb 16, 2020

I understand your situation. You can still create a new classic app from this link. To keep your app’s full functionality, please consider continuing to go with the classic app permissions.

Unfortunately when submitting my app to the app directory the reviewers wouldn’t approve my app until I updated to granular permissions.

If it’s possible to submit a classic app to the app directory, I might recreate my app and resubmit it…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Discrepancies in app.client.chat.postMessage #401 - GitHub
I have a Slack app in production and a sandbox app. Both have the same scopes and use the same exact code. However,...
Read more >
chat.postMessage method - Slack API
This method posts a message to a public channel, private channel, or direct message/IM channel. Consider reviewing our message guidelines, especially if ...
Read more >
Bolt for Python - Slack Platform Developer Tools
A framework that makes Slack app development fast and straight-forward. ... do something more advanced (like handle specific errors), you can call client....
Read more >
Basic Usage - python-slackclient
Messages posted from apps can contain more than just text, though. They can include full user interfaces composed of blocks. The chat.postMessage method ......
Read more >
slack api invalid auth error building slack bot - Stack Overflow
You can see in the API documentation for postMessage that your bot needs the chat:write scope from your App page -> OAuth &...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found