botman / botman

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

Using $this->say / $botman->say doesn't use bot account #67

Closed A-Lawrence closed 7 years ago

A-Lawrence commented 7 years ago

When sending a message using $this->say in conversations, or $botman-say in other contexts, it appears that the bot details aren't used.

333_1482365288 1

The code for this is:

public function askWhatTypeOfTraining()
    {
        return $this->ask("What type of training are you asking about? [Answer with *type_a* or *type_b*]",
            function (Answer $answer) {
                $this->typeOfTraining = strtolower($answer->getText());

                if ($this->typeOfTraining == "type_a") {
                    $this->say("This is how you complete type_a training.");
                } elseif ($this->typeOfTraining == "type_b") {
                    $this->say("This is how you complete type_b training.");
                }
            });
    }

    /**
     * Start the conversation.
     */
    public function run()
    {
        $this->askWhatTypeOfTraining();
    }

Not able to diagnose if this is a bug, or if it's down to my incompetence. Any ideas gratefully received!

mpociot commented 7 years ago

Which messaging driver(s) are you using? And which bot details do you mean?

A-Lawrence commented 7 years ago

Hi Marcel! We're using the Slack driver.

I should've been clearer about the details - You'll notice in the first image has 4 users. The first icon is the bot account (setup in slack with a name and profile picture). The last icon is the result of using ->say().

Conversation can be found here: https://github.com/VATSIM-UK/core/blob/feature/botman/app/Conversations/ExampleConversation.php

mpociot commented 7 years ago

Okay - but the first icon is the bot using the ask method?

If you're using the RTM API, inside conversations it get's swapped to the regular Slack driver which is related to the way the drivers get serialized. Could you try and pass the additional parameters to the say method?

Like this:

$parameters = [
    'username' => 'Bot User',
    'icon_url' => 'http://you-bot-icon.png',
];
$this->say('Starting training towards one of the many Pilot Ratings we offer in the UK is easy.', $parameters);

Seems like it's an issue when switching from SlackRTMDriver to SlackDriver.

mpociot commented 7 years ago

Fixed in dev-master