Download the PHP package tmdan/dialogflow-fulfillment-webhook-php without Composer
On this page you can find all versions of the php package tmdan/dialogflow-fulfillment-webhook-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tmdan/dialogflow-fulfillment-webhook-php
More information about tmdan/dialogflow-fulfillment-webhook-php
Files in tmdan/dialogflow-fulfillment-webhook-php
Package dialogflow-fulfillment-webhook-php
Short Description Dialogflow Fulfillment Webhook v1 & v2 - modernize from eristemena/dialogflow-fulfillment-webhook-php
License MIT
Informations about the package dialogflow-fulfillment-webhook-php
Dialogflow Fulfillment PHP Library
This Library is inspired by dialogflow/dialogflow-fulfillment-nodejs.
It supports Dialogflow's fulfillment webhook JSON requests and responses for v1 and v2 agents.
For full class reference please refer to the doc.
- Installation
- Usage
- Initiate Agent
- Get Request Info
- Send Reply
- Rich Message
- Text
- Image
- Card
- Suggestion
- Custom payload
- Actions on Google
- Send Reply
- Responses
- Simple Response
- Image
- Basic Card
- List
- Carousel
- Browsing Carousel
- Suggestion Chip
- Media Responses
- Helpers
- User information
- Date and Time
- Place and Location
- Confirmation
- Surface Capabilities
Installation
Install via composer: composer require eristemena/dialogflow-fulfillment-webhook-php
.
Usage
Initiate Agent
To initiate agent, use \Dialogflow\WebhookClient
constructor with input parameter as array of request coming from Dialogflow.
In Vanilla PHP, this can be done as follow,
or if you're using Laravel,
Get Request Info
-
[Request Source]() (ex:
google
,facebook
,slack
, etc) -
Original Request, platform specific payload
- Agent Version (1 or 2)
Send Reply
To send a reply, use reply()
method.
Then use render()
to get response in array. All you have to do is to print the array as JSON,
or in Laravel,
The response payload will be automatically formatted according to Agent Version of the request.
Rich Message
Text
Image
Card
Suggestion
Custom payload
Actions on Google
This library also supports Actions on Google specific functionalities. It's still under development, so more features will be added in the future.
To use Actions on Google Dialogflow Conversation object, you must first need to ensure the requestSource
is coming from Google Assistant,
or you can just call getActionConversation()
method, and it will return null
if the request doesn't come from Google Assistant.
Send Reply
Using Dialogflow Conversation object, you can send a reply in two ways,
-
Send a reply and close the conversation
- Send a reply and wait for user's response
Responses
Simple Response
Please see the documentation here.
Image
Basic Card
Please see the documentation here.
List
Please see the documentation here.
The single-select list presents the user with a vertical list of multiple items and allows the user to select a single one. Selecting an item from the list generates a user query (chat bubble) containing the title of the list item.
To capture the option selected by user, create a Dialogflow intent with the actions_intent_OPTION
event. Assuming you name the intent as Get Option
, you can get the argument as follow,
Carousel
Please see the documentation here.
The carousel scrolls horizontally and allows for selecting one item. Compared to the list selector, it has large tiles-allowing for richer content. The tiles that make up a carousel are similar to the basic card with image. Selecting an item from the carousel will simply generate a chat bubble as the response just like with list selector.
To check if the user granted you the information and then access the data, create a Dialogflow intent with the actions_intent_OPTION
event. Assuming you name the intent as Get Option
, you can get the argument as follow,
Browsing Carousel
Please see the documentation here.
A browsing carousel is a rich response, similar to the carousel response as it scrolls horizontally and allows users to select a tile. Browsing carousels are designed specifically for web content by opening the selected tile in a web browser (or an AMP browser if all tiles are AMP-enabled). The browsing carousel will also persist on the user's Assistant surface for browsing later.
No follow-up fulfillment is necessary for user interactions with browse carousel items, since the carousel handles the browser handoff.
Suggestion Chip
Please see the documentation here.
Media Responses
Please see the documentation here.
Media responses let your Actions play audio content with a playback duration longer than the 120-second limit of SSML. The primary component of a media response is the single-track card.
Helpers
User information
Please see the documentation here.
To check if the user granted you the information and then access the data, create a Dialogflow intent with the actions_intent_PERMISSION
event. Assuming you name the intent as Get Permission
, you can get the information as follow,
Date and Time
Please see the documentation here.
To check if the user granted access and then access the data, create a Dialogflow intent with the actions_intent_DATETIME
event. Assuming you name the intent as Get Date Time
, you can get the information as follow,
Place and Location
Please see the documentation here.
To check if the user granted access and then access the data, create a Dialogflow intent with the actions_intent_PLACE
event. Assuming you name the intent as Get Place
, you can get the information as follow,
Confirmation
Please see the documentation here.
To check if the user confirmed or not, create a Dialogflow intent with the actions_intent_CONFIRMATION
event. Assuming you name the intent as Get Confirmation
, you can get the information as follow,
Surface Capabilities
Google Assistant can be used on a variety of surfaces such as mobile devices that support audio and display experiences or a Google Home device that supports audio-only experiences.
To design and build conversations that work well on all surfaces, use surface capabilities to control and scope your conversations properly.