Giter Club home page Giter Club logo

Comments (18)

mpociot avatar mpociot commented on May 19, 2024 2

I'll close this issue for now. With the new version of this library, I will create a demo repository showing off all supported messaging platforms.

from botman.

mpociot avatar mpociot commented on May 19, 2024 1

I still want to provide a separate repository with a Laravel example application to get you started. But I haven't found the time yet.

If you find some things in the documentation that could be improved, feel free to send pull requests.

from botman.

brianclogan avatar brianclogan commented on May 19, 2024

If you need any code (like what I have now from the #14 issue), let me know.

from botman.

brianclogan avatar brianclogan commented on May 19, 2024

Quick question, I see that the repo does support buttons, does it accept button requests too, or just send them?

from botman.

mpociot avatar mpociot commented on May 19, 2024

What do you mean by "Button requests"?
It allows sending (and responding) to Slack message buttons.

from botman.

brianclogan avatar brianclogan commented on May 19, 2024

That's what I meant, so in the value do you put the same thing that's in the ->hears() section?

from botman.

brianclogan avatar brianclogan commented on May 19, 2024

So from my code from yesterday, something like this, would it work?

    public function handleBotRequest(Request $request)
    {
        $payload = $request->json();
        if ($payload->get('type') === 'url_verification') {
            return $payload->get('challenge');
        }

        $team = Company::find(1);

        $slackBot = app('slackbot');

        $slackBot->initialize($team->slack_info->bot->bot_access_token);
        $slackBot->hears('ping', function (SlackBot $bot) {
            $bot->reply(Question::create('PONG')->addButton(Button::create('Ping')->value('ping'))->callbackId('PINGPONG'));
        });
        $slackBot->listen();
    }

from botman.

mpociot avatar mpociot commented on May 19, 2024

Yes exactly, that should work.

Here is an example from one of my bots:

$question = Question::create('Do you need a database?')
            ->fallback('Unable to create a new database')
            ->callbackId('create_database')
            ->addButtons([
                Button::create('Yes')->value('yes'),
                Button::create('No')->value('no'),
            ]);

$bot->reply($question, function (Answer $answer) {
            if ($answer->isInteractiveMessageReply()) {
                $decision = $answer->getValue();
                if ($decision === 'yes') {}
            }
});

Please note that the bot reply method no longer exists. It got renamed to respond

from botman.

brianclogan avatar brianclogan commented on May 19, 2024

Ah, okay! Also, I scrapped what I had created and started a repo to make it easy, I can transfer if you want and I also have a dev site setup on a forge server so I could play with it more.

https://github.com/darkgoldblade01/slackbot-laravel

from botman.

brianclogan avatar brianclogan commented on May 19, 2024

How are you using $bot->reply($question, function()) when the second argument is supposed to be an array?

I am getting an error:

ErrorException: array_merge(): Argument #2 is not an array in /home/forge/***/vendor/mpociot/slackbot/src/Mpociot/SlackBot/SlackBot.php:248

from botman.

mpociot avatar mpociot commented on May 19, 2024

Ah - this was taken from a Conversation class and I just changed the syntax from $this->ask (which only accepts two arguments) to $bot->reply

So this should be inside of a conversation too, since you need to get the users input.

from botman.

brianclogan avatar brianclogan commented on May 19, 2024

Okay, I am hoping to compile the examples we are coming up with into the repo I created for the laravel example.

from botman.

webmestre-comeul avatar webmestre-comeul commented on May 19, 2024

Btw, thanks @darkgoldblade01 for that repo, it'll come handy, I did try to follow @mpociot's blog post on it, but somehow I failed miserably ;-) I hope yours will get me through it!

from botman.

mpociot avatar mpociot commented on May 19, 2024

Sorry for that - I wrote the blog post while writing the library, which has now a more stable API.
I'll update the blogpost soon :)

from botman.

webmestre-comeul avatar webmestre-comeul commented on May 19, 2024

No worries about that, that'll just teach me to blindly follow step by step :P

from botman.

webmestre-comeul avatar webmestre-comeul commented on May 19, 2024

Well, thank you guys, I finally re-read this issue correctly (And #14) and got my bot working just fine on my part! Now the fun part begins...

from botman.

jerairrest avatar jerairrest commented on May 19, 2024

If you encounter any issues that could be shared let us know! :-)

from botman.

webmestre-comeul avatar webmestre-comeul commented on May 19, 2024

Honestly, at this moment, the only issue I encountered was probably due to the fact that I was trying to follow the blog post, the readme and two issues at the same time ;-)

from botman.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.