public function render()
    {
        $out = [];

        $out['expectUserResponse'] = $this->expectUserResponse;

        $items = [];
        $suggestions = [];
        $linkOutSuggestion = null;
        foreach ($this->messages as $message) {
            if ($message instanceof ResponseInterface) {
                $item = $message->renderRichResponseItem();

                if ($item) {
                    $items[] = $item;
                }
            }

            if ($message instanceof SuggestionInterface) {
                $rendered = $message->renderRichResponseSuggestion();

                if (is_array($rendered)) {
                    foreach ($rendered as $suggestion) {
                        $suggestions[] = ['title' => $suggestion];
                    }
                } elseif (is_string($rendered)) {
                    $suggestions[] = ['title' => $rendered];
                } else {
                    // do nothing
                }
            }

            if ($message instanceof LinkOutSuggestionInterface) {
                $linkOutSuggestion = $message->renderRichResponseLinkOutSuggestion();
            }

            if ($message instanceof QuestionInterface) {
                if ($item = $message->renderRichResponseItem()) {
                    $items[] = $item;
                }
            }
        }

        $out['richResponse']['items'] = $items;

        if (count($suggestions) > 0) {
            $out['richResponse']['suggestions'] = $suggestions;
        }

        if ($linkOutSuggestion) {
            $out['richResponse']['linkOutSuggestion'] = $linkOutSuggestion;
        }

        $systemIntent = null;
        foreach ($this->messages as $message) {
            if ($message instanceof QuestionInterface) {
                $systemIntent = $message->renderSystemIntent();
            }
        }

        if ($systemIntent) {
            $out['systemIntent'] = $systemIntent;
        }

        return $out;
    }
public function render()
    {
        $out = [];

        $out['expectUserResponse'] = $this->expectUserResponse;

        $items = [];
        $suggestions = [];
        $linkOutSuggestion = null;
        foreach ($this->messages as $message) {
            if ($message instanceof ResponseInterface) {
                $item = $message->renderRichResponseItem();

                if ($item) {
                    $items[] = $item;
                }
            }

            if ($message instanceof SuggestionInterface) {
                $rendered = $message->renderRichResponseSuggestion();

                if (is_array($rendered)) {
                    foreach ($rendered as $suggestion) {
                        $suggestions[] = ['title' => $suggestion];
                    }
                } elseif (is_string($rendered)) {
                    $suggestions[] = ['title' => $rendered];
                } else {
                    
                }
            }

            if ($message instanceof LinkOutSuggestionInterface) {
                $linkOutSuggestion = $message->renderRichResponseLinkOutSuggestion();
            }

            if ($message instanceof QuestionInterface) {
                if ($item = $message->renderRichResponseItem()) {
                    $items[] = $item;
                }
            }
        }

        $out['richResponse']['items'] = $items;

        if (count($suggestions) > 0) {
            $out['richResponse']['suggestions'] = $suggestions;
        }

        if ($linkOutSuggestion) {
            $out['richResponse']['linkOutSuggestion'] = $linkOutSuggestion;
        }

        $systemIntent = null;
        foreach ($this->messages as $message) {
            if ($message instanceof QuestionInterface) {
                $systemIntent = $message->renderSystemIntent();
            }
        }

        if ($systemIntent) {
            $out['systemIntent'] = $systemIntent;
        }

        return $out;
    }
public function render ( ) { $ out = [ ] ; $ out [ 'expectUserResponse' ] = $ this -> expectUserResponse ; $ items = [ ] ; $ suggestions = [ ] ; $ linkOutSuggestion = null ; foreach ( $ this -> messages as $ message ) { if ( $ message instanceof ResponseInterface ) { $ item = $ message -> renderRichResponseItem ( ) ; if ( $ item ) { $ items [ ] = $ item ; } } if ( $ message instanceof SuggestionInterface ) { $ rendered = $ message -> renderRichResponseSuggestion ( ) ; if ( is_array ( $ rendered ) ) { foreach ( $ rendered as $ suggestion ) { $ suggestions [ ] = [ 'title' => $ suggestion ] ; } } elseif ( is_string ( $ rendered ) ) { $ suggestions [ ] = [ 'title' => $ rendered ] ; } else { // do nothing } } if ( $ message instanceof LinkOutSuggestionInterface ) { $ linkOutSuggestion = $ message -> renderRichResponseLinkOutSuggestion ( ) ; } if ( $ message instanceof QuestionInterface ) { if ( $ item = $ message -> renderRichResponseItem ( ) ) { $ items [ ] = $ item ; } } } $ out [ 'richResponse' ] [ 'items' ] = $ items ; if ( count ( $ suggestions ) > 0 ) { $ out [ 'richResponse' ] [ 'suggestions' ] = $ suggestions ; } if ( $ linkOutSuggestion ) { $ out [ 'richResponse' ] [ 'linkOutSuggestion' ] = $ linkOutSuggestion ; } $ systemIntent = null ; foreach ( $ this -> messages as $ message ) { if ( $ message instanceof QuestionInterface ) { $ systemIntent = $ message -> renderSystemIntent ( ) ; } } if ( $ systemIntent ) { $ out [ 'systemIntent' ] = $ systemIntent ; } return $ out ; }
Render response as array.

@return array
Render response as array .