PHP code example of socheatsok78 / manychat-block-sdk
1. Go to this page and download the library: Download socheatsok78/manychat-block-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
socheatsok78 / manychat-block-sdk example snippets
namespaceApp\Http\Controllers\Flow;
useManyChat\Dynamic\Chat;
useIlluminate\Http\Request;
useApp\Http\Controllers\Controller;
classWelcomeMessageextendsController{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/publicfunction__invoke(Request $request){
$chat = new Chat();
$text = new Text('Welcome to ManyChat Dynamic Response');
$chat->reply($text);
return $chat;
}
}
useManyChat\Dynamic\Messages\Text;
$text = new Text('Example text message');
# or
$text = Text::create('Example text message');
useManyChat\Dynamic\Messages\Element;
useManyChat\Dynamic\Messages\LargeList;
useManyChat\Dynamic\Messages\CompactList;
# You need to create at lease 2 Element block
$element_1 = new Element([/* ... */]);
$element_2 = new Element([/* ... */]);
$compactList = new CompactList([$element_1, $element_2]);
$largeList = new LargeList([$element_1, $element_2]);
useManyChat\Dynamic\Messages\Element;
useManyChat\Dynamic\Messages\SquareCard;
useManyChat\Dynamic\Messages\HorizontalCard;
# You need to create at lease 2 Element block
$element_1 = new Element([/* ... */]);
$element_2 = new Element([/* ... */]);
$horizontalCard = new HorizontalCard([$element_1, $element_2]);
$squareCard = new SquareCard([$element_1, $element_2]);
useManyChat\Dynamic\Messages\Element;
$element = new Element();
$element->title = 'Unsplash';
$element->subTitle = 'Photos for everyone';
$element->imageUrl = 'https://source.unsplash.com/random';
$element->actionUrl = 'https://unsplash.com';
# or
$element = new Element([
'title' => 'Unsplash',
'subTitle' => 'Photos for everyone',
'imageUrl' => 'https://source.unsplash.com/random',
'actionUrl' => 'https://unsplash.com',
]);
useManyChat\Dynamic\Attachments\File;
$file = new File('/* URL to the file */');
# or
$file = File::url('/* URL to the file */');
useManyChat\Dynamic\Attachments\Image;
$image = new Image('https://source.unsplash.com/random');
# or
$image = Image::url('https://source.unsplash.com/random');
useManyChat\Dynamic\Attachments\Audio;
$audio = new Audio('/* URL to the audio file */');
# or
$audio = Audio::url('/* URL to the audio file */');
useManyChat\Dynamic\Attachments\Video;
$video = new Video('/* URL to the video file */');
# or
$video = Video::url('/* URL to the video file */');
useManyChat\Dynamic\Buttons\Call;
$call = new Call('+123456789');
# or
$call = Call::phone('+123456789');
useManyChat\Dynamic\Buttons\Url;
$url = new Url('https://example.com');
# or
$url = Url::create('https://example.com');