How To Build A Slack Bot Using Laravel

Submitted by azazqadir - 4 months ago

This tutorial demonstrates how you can build a simple “Hello World” Slackbot by using Laravel. Slack is a cloud-based team collaboration tool co-founded by Stewart Butterfield, Eric Costello, Cal Henderson, and Serguei Mourachov. It offers a lot of IRC-like features including persistent chat rooms (channels) organized by topic, as well as private groups and direct messaging. Source: https://www.cloudways.com/blog/build-laravel-powered-slack-bot/

$ vim app/Controller/SlackController.php
 
<?php
 
namespace App\Http\Controllers;
 
use App\Http\Controllers\Controller;
 
use Illuminate\Support\Facades\View;
 
use Illuminate\Foundation\Bus\DispatchesJobs;
 
use Illuminate\Routing\Controller as BaseController;
 
use Illuminate\Foundation\Validation\ValidatesRequests;
 
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
 
class SlackController extends Controller
 
{
 
public function pushData()
 
{
 
\Slack::send('Hello World')
 
}
 
}
comments powered by Disqus

Ads cover the costs of maintaining Laravel-tricks