I created my app and then follow to send button tutorial (I replaced client_id to ########)
Add to Slack
then follow by this redirction and click allow
after success get code in redirect_uri I used it on oauth api V2, I got this response (I replaced real data to #######)
https://slack.com/api/oauth.v2.access
{
"ok": true,
"app_id": "#######",
"authed_user": {
"id": "#######"
},
"scope": "chat:write",
"token_type": "bot",
"access_token": "xoxb-#######",
"bot_user_id": "#######",
"team": {
"id": "#######",
"name": "#######"
},
"enterprise": null,
"is_enterprise_install": false
}
so then after that I grab access_token from that response I try to execute post message is some channel in workspace (in response this is team info)
$response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/api/chat.postMessage', [
'json' => array_filter($options),
'auth_bearer' => $this->accessToken,
'headers' => [
'Content-Type' => 'application/json; charset=utf-8',
],
]);
and I faced with repult like that,
$result = {array[2]}
ok = false
error = "not_in_channel"
so what I'm doing wrong ? how to force bot send message in some channel from my workspace which was allow scope for current bot(app) by slack button suggestion ?