botman / botman

A framework agnostic PHP library to build chat bots
https://botman.io
MIT License
6.06k stars 812 forks source link

'startConversation()' fails in a 'hears()' closure, triggered from a Slack Command #851

Closed th3d0g closed 2 years ago

th3d0g commented 6 years ago

Description:

Calling 'startConversation()' fails when called from the 'hears()' closure. See example below:

$botman->hears('/project', function ($bot) { $bot->startConversation(new ExampleConversation()); });

This is being triggered from a Slack command, which responds with:

/project failed with the error "invalid_attachments_format"

It's worth noting that the example included works which calls a controller function. This works differently as it's triggered via an Event as opposed to a Command in the example above.

$botman->hears('Start conversation', BotManController::class.'@startConversation');

Steps To Reproduce:

  1. Setup a Slack bot, and add a command.

  2. Create a 'hear()' function to listen out for this command. Within the closure run $bot->startConversation(new ExampleConversation());.

  3. Call the command from Slack.

christophrumpel commented 5 years ago

What is the error you get?