Dialogflow fulfillment driver for BotMan

bot, Botman, Dialogflow


BotMan Dialogflow Driver

BotMan driver to handle Dialogflow fulfillment with BotMan.

Build Status codecov StyleCI

It uses eristemena/dialog-fulfillment-webhook-php library, so it supports v1 and v2 of Dialogflow request.

Installation & Setup

First you need to pull in the Driver.

composer require eristemena/botman-driver-dialogflow

If you're using BotMan Studio, that's pretty much it.

But if you don't, then load the driver before creating the BotMan instance:


// Create BotMan instance


Hearing Messages

You can start receiving message using hears() based on the Intent of the message,

$botman->hears('Intent Name', function ($botman) {
    // replies here

Single Message Reply

The simplest way to reply to an incoming message is using BotMan's own reply() method:

$botman->hears('Default Welcome Intent', function ($botman) {
    $botman->reply('Hi, welcome!');

Multiple Message Replies

Normally when you want to send multiple replies, you use reply() multiple times. Unfortunately this doesn't work for Dialogflow driver, cause the messages should be in a single response payload.

For that, you have to use specific methods for this driver addMessage() and sendMessage() as follow,

$botman->hears('Default Welcome Intent', function ($botman) {
    $botman->addMessage('Good morning');
    $botman->addMessage('How may i help you?');

Rich Messages


Use Dialogflow\RichMessage\Text

    $text = Text::create()
                <audio src=""></audio>



Use Dialogflow\RichMessage\Image

    $image = Image::create('');
        ->addMessage('This is an image')


Use Dialogflow\RichMessage\Card

    $card = Card::create()
        ->title('This is title')
        ->text('This is text body, you can put whatever here.')
        ->button('This is a button', '')

        ->addMessage('This is a card')

Quick Replies

Use Dialogflow\RichMessage\Suggestion

    $suggestion = Suggestion::create(['Tell me a joke', 'Tell me about yourself']);

        ->addMessage('Hi, how can i help you with?')

Custom Payload

Use Dialogflow\RichMessage\Payload

    $payload = Payload::create([
        'expectUserResponse' => false

        ->addMessage('Have a good day')