/**
  * You can set the welcome message to be text or Structured Message.
  * 
  * @param string $text
  * @param StructuredMessage $template Structured Message
  */
 public function addNext($text, $template = null)
 {
     if (!empty($text)) {
         $this->callToActions = ['message' => ['text' => $text]];
     }
     if (!empty($template)) {
         if ($template instanceof StructuredMessage) {
             $this->callToActions = ['message' => [$template->getDataForCall(FALSE)]];
         } else {
             throw new MessengerPlatformException('Template for welcome message is not StructuredMessage.', 4);
         }
     }
 }
 /**
  * Send a complex message.
  * 
  * @param fritak\MessengerPlatform\MessageSend|fritak\MessengerPlatform\StructuredMessage $message
  * @return fritak\MessengerPlatform\Response
  */
 public function sendComplexMeesage($message)
 {
     return $this->gate->request(Gate::URL_MESSAGES, $message->getDataForCall());
 }
 /**
  * Send a structured Message - receipt template.
  * 
  * @param int $recipient This must be either:
  * <ul>
  * <li>an id that was retrieved through the Messenger entry points or through the Messenger callbacks</li>
  * <li>or instance of fritak\MessengerPlatform\UserRecipient</li>
  * </ul>
  * @param Receipt $receipt
  * @param string $notificationType One of 3 types of notification, use constants (eg. NOTIFICATION_TYPE_REGULAR)
  * @return fritak\MessengerPlatform\Response
  * @see https://developers.facebook.com/docs/messenger-platform/send-api-reference#guidelines
  */
 public function sendReceipt($recipient, Receipt $receipt, $notificationType = MessageSend::NOTIFICATION_TYPE_REGULAR)
 {
     $structuredMessage = new StructuredMessage($recipient, $receipt, $notificationType, StructuredMessage::ATTACHMENT_TYPE_TEMPLATE, StructuredMessage::TEMPLATE_PAYLOAD_TYPE_RECEIPT);
     return $this->gate->request(Gate::URL_MESSAGES, $structuredMessage->getDataForCall());
 }