I tried to call intent in dialogflow. My intent is detect geo-city from message. This is my dialogflow page. My problem is when I run the application and send message in botman it doesn't send me the geo-city value.
I tried send in botman 'My city is colombo' but no any responce or reply in botman.
I setup my api json file in .env file
GOOGLE_CLOUD_PROJECT="project_id"
GOOGLE_APPLICATION_CREDENTIALS="pathtojsonfile"
In dialogflow::create() function did I call the security key correctly?
<?php
namespace App\Http\Controllers;
use App\Botman\MainConversation;
use Illuminate\Http\Request;
use BotMan\BotMan\Middleware\ApiAi;
use BotMan\BotMan\Middleware\Dialogflow;
class BotManController extends Controller
{
public function handle()
{
$botman = app('botman');
$dialogflow = Dialogflow::create('en');
$botman->middleware->received($dialogflow);
$botman->hears('getzone', function ($bot) {
$extras = $bot->getMessage()->getExtras('apiParameters');
$apiReply = $extras['geo-city'];
$bot->reply('hi');
})->middleware($dialogflow);
$botman->listen();
}
}
Related
I've been trying to get fortify's native email verification feature to use mailjet so templates can easily be adjusted. I've hit a bit of a roadblock as all tutorials and sources I've found are all about blade templates. Does someone have some pointers in the right direction or perhaps personal experience setting this up?
Thanks in advance!
You need to bind your own implementation of Laravel\Fortify\Contracts\VerifyEmailViewResponse in the FortifyServiceProvider class.
# app/Providers/FortifyServiceProvider.php
namespace App\Providers;
use App\Actions\Fortify\YourClassHere;
use Laravel\Fortify\Contracts\VerifyEmailViewResponse;
class FortifyServiceProvider extends ServiceProvider
{
public function boot()
{
app()->singleton(VerifyEmailViewResponse::class, YourClassHere::class);
}
}
# app/Actions/Fortify/YourClassHere.php
namespace App\Actions\Fortify;
use Laravel\Fortify\Contracts\VerifyEmailViewResponse;
class YourClassHere extends VerifyEmailResponse
{
public function toResponse($request)
{
// your logic here.
// since mailjet uses an api, perhaps return the response of a curl call,
// or a response form Http::get(...)
// or use a third-party package like laravel-mailjet (https://mailjet.github.io/laravel-mailjet/)
}
}
The logic that sends the verification email is part of the Illuminate\Auth\MustVerifyEmail trait. If you want to change it, you need to override it in your User model.
class User extends Authenticatable
{
/**
* Send the email verification notification.
*
* #return void
*/
public function sendEmailVerificationNotification()
{
// your logic here.
}
}
good day;
I am new in vue.js and I want to build API in my project using vue.js and laravel
I have some question and answer because I got confused
I have services controller that return all service
as below:-
class ServicesController extends Controller
{
public function Services()
{
//get all serveice
$services=Services::where(['deleted'=>1,'status'=>1])->get();
return response()->json($services);
}
}
and API route as below:-
Route::get('/Servicess', 'API\ServicesController#Services');
it is necessary to make a component to send a request to using
Axios request to get data and if yes how to tell the mobile developer about a link to access it.
i want the steps from vue.js side to
prepare data and send it using Axios
You can not use your front-end javascript code inside php controllers, there are two ways to use the data; First: send it via the request. Second: fetch the required data at the back-end side and use it there.
Also there are many alternatives to Axios like the fetch api etc.
Update#1:
example controller
use Illuminate\Http\Request;
class ExampleController extends Controller
{
public function exampleMethod(Request $request){
$name = $request->input('name');
//DO sth
}
}
Route in api.php:
Route::get('/users', 'API\ExampleController#exampleMethod');
I'm using laravel and integrate the payment gateway.when i send the post request then after success or cancellation ,it redirect the referece id like this
http://localhost/multi_vendor/user/paypal/return?flwref=FLW-MOCK-d4f7572650fbe61ecff7fb17a7129859&txref=rave-bxw7c98dymo8so0kwosco0wwscs8ogc
so how can tackle it in laravel?
I made route for this
Route::get('/paypal/return', 'User\PaypalController#payreturn')->name('user.payment.return');
You can create a route as you write above:-
Route::get('/paypal/return', 'User\PaypalController#payreturn')->name('user.payment.return');
Then in User\PaypalController Controller method payreturn, you can do as following:-
<?php
namespace App\Http\Controllers\User;
use Illuminate\Http\Request;
class PaypalController extends Controller
{
public function payreturn(Request $request)
{
//Here you can get the response request values
$ref = $request->flwref;
$TxRef = $request->txref;
}
}
I also didn't understand well your question, but let me try.
Possible appointments:
if your route is like localhost/multi_vendor/user/paypal/return, you must represent all steps in route file, something like Route::get('/multi_vendor/{user}/paypal/return,[...]). If you are already using somethink like it or a group with prefix, ignore it;
if you wish to redirect, you could use return redirect('yourCompleteUrl') in your controller or in route file;
if you wish to retrieave the parameters Tim Lewis anserwed what you need:
public function payreturn(Request $request)
{
$flref = $request->input('flref');
$txref = $request->input('txref');
}
#darnish manzoor just add your url callback rootverto verifycrsf token
if your redirection url is /ravecallback, just add it and it will stop giving you method not allowed
protected $except = [
'/ravecallback'
];
I used Laravel 5.0 and Irazasyed telegram bot, I want work by webhook and when a person send message to telegram bot, the telegram send a message automatically to that.
My code is here bot not worked by webhook:
<?php namespace App\Http\Controllers;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Technical;
use Illuminate\Support\Facades\Session;
use Url;
use Telegram\Bot\Api;
use Telegram\Bot\Laravel\Facades\Telegram;
use Artisaninweb\SoapWrapper\Facades\SoapWrapper;
class HomeController extends Controller {
public function __construct()
{
//$this->middleware('auth');
}
public function index()
{
$telegram = new Api('117451573:*********************', 'true');
$telegram->setWebhook(['url' => 'https://******.com/117451573:********************/webhook']);
$update = $telegram->getWebhookUpdates();
$telegram->sendMessage([
'chat_id' => '********',
'text' => 'thanks',
]);
return response()->json(["status" => "success"]);
}
}
I am trying to get Irazasyed's Telegram Bot SDK to work as well. Heres a tutorial: Let's make a Telegram bot with PHP, that seems to be up to date. I had not the time to test it by myself. Will come hopefully the next days.
To use webhooks its seems you have to call the following command in the shell once.
curl -H "Content-Type: application/json" -X POST -d '{"url":"https://www.example.com/my-secret-webhook.php"}' https://api.telegram.org/botYOUR_BOT_TOKEN/setWebhook
see chapter II. Configuring the Webhook at the tutorial.
Good luck
I use Lumen 5.1 and Redis for queues. And I have a pretty standard event handler that should send an email:
<?php
namespace App\Handlers\Events;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Events\UserHasRegistered;
use Illuminate\Contracts\Mail\Mailer;
class SendWelcomeEmail implements ShouldQueue
{
protected $mailer;
public function __construct(Mailer $mailer)
{
$this->mailer = $mailer;
}
public function handle(UserHasRegistered $event)
{
$user = $event->user;
$this->mailer->raw('Test Mail', function ($m) use ($user) {
$name = $user->getFirstName().''.$user->getLastName();
$m->to($user->auth()->getEmail(), $name)->subject('This is a test.');
});
}
}
The email is sent when I don't use the ShouldQueue interface. But when I push the event handler to the queue (i. e. use the ShouldQueue interface), the email is not sent and I don't get any error messages.
Do you have any ideas how to solve or debug this?
It was not a bug, just an unexpected behaviour.
I am using Xampp on Windows and the php mail driver for development. For some reason the queued mails were not saved in the default mailoutput folder within the Xampp directory. Instead a new mailoutput folder was automatically created within the Lumen directory.
There I found all the missed mails. :)