https://docs.chatfuel.com/en/articles/735122-json-api
<?php
use Finwe\Chatfuel\JsonApi\JsonApiResponse;
use Finwe\Chatfuel\JsonApi\Message\ImageMessage;
use Finwe\Chatfuel\JsonApi\Message\TextMessage;
use Finwe\Chatfuel\JsonApi\Redirect;
use Finwe\Chatfuel\JsonApi\SetAttribute;
$response = new JsonApiResponse();
$attributes = new SetAttribute();
$attributes->addAttribute('attribute', 'value');
$redirect = new Redirect();
$redirect->addBlock('Bot start');
$response->addMessage(new TextMessage('Hello'))
->addMessage(new ImageMessage('http://example.com'))
->setAttributes($attributes)
->setRedirect($redirect);
header('Content-type: application/json');
echo json_encode($response->getResponse());
A simple text message.
Image message.
Video message.
Audio message.
Finwe\Chatfuel\JsonApi\Message\ButtonMessage(string $text, \Finwe\Chatfuel\JsonApi\Template\Button[] $buttons)
A text message with buttons.
Buttons can also be added with addButton(Button $button)
method.
Generic message with custom payload. More concrete message types extend from this class.
Class to add a button below an element.
Button type is a Consistence\Enum instance, eg. ButtonType::get(ButtonType::WEB_URL);
. Available types are ButtonType::WEB_URL
, ButtonType::JSON_PLUGIN_URL
and ButtonType::SHOW_BLOCK
Specification is either a string for all types, or an array of strings for ButtonType::SHOW_BLOCK
.