Skip to content

Easily create a webhook for Google Assistant (Actions on Google) on api.ai with php.

License

Notifications You must be signed in to change notification settings

richtepa/google_assistant-api.ai-php_helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Google Assistant api.ai PHP-Helper

also see example.php

Setup

1. Add webhook to api.ai

see: api.ai docs - Fulfillment

use _ instead of symbols (e.g. -) or spaces in intent-names on api.ai

2. Configure settings (optional)

code:

$helper_config["PARAMETER"]

options:

PARAMETER if true default
log logs input, compiled data, output and additional logs in log.json next to the helper.php false
intent-function executes function with the intent-name from api.ai false

You can use log_out(TITLE, CONTENT); (after include()) to log additional things to log.json if you declared $helper_config["log"] = true;.

example:

$helper_config["intent-function"] = true;

3. Add helper.php after the import of necessary data (before usage of input)

include(PATH/TO/FILE.php);

Input

code:

$helper["PARAMETER"]

options:

PARAMETER type description example
audio boolean capability of audio output true
screen boolean capability of screen output false
timestamp string timestamp "2017-09-30T11:08:03.526Z"
query string input "I like cookies"
method string input method "KEYBOARD"
locale string locale "en-US"
userId string userId "SLONXM2bnazxzrC3MQMr5nU7xeF9"
conversationId string locale "2617870626043"
parameters object from api.ai resolved parameters {type: "cookies", person: "I"}
intent string intent "like"

example:

global $helper;
$userId = $helper["userId"];

Output

You can respond on prompts in different versions. For requirements check Actions on Google Guides - Responses

methods:

response type code
simple response  
simple_response(TEXT);
                               
Basic Card
basic_card(TITLE, DESCRIPTION, IMG-URL, IMG-ALT-TEXT);
List selector
list_selector(LIST-TITLE);
Carousel selector
carousel_selector();
Suggestion Chips
suggestion_chips([CHIP1, CHIP2, ...]);

before calling carousel_selector(); or list_selector(); add each item:

addItem(TITLE, DESCRIPTION, IMG-URL, IMG-ALT-TEXT);

examples:

see example.php

About

Easily create a webhook for Google Assistant (Actions on Google) on api.ai with php.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages