/** * @param string $sessionId * @param string $message * @param array $contexts * * @return Action|Speech */ private function getStep($sessionId, $message, $contexts = []) { $query = $this->queryApi->extractMeaning($message, ['sessionId' => $sessionId, 'contexts' => $contexts]); $query = new Query($query); if (null === $query) { $query = new Query(); } if ($query->getStatus()->getCode() !== 200) { throw new DialogException($query->getStatus()->getErrorDetails(), $sessionId, $query); } try { $step = StepFactory::create($query); } catch (InvalidStepException $error) { throw new DialogException($error->getMessage(), $sessionId, $error->getQuery()); } return $step; }
/** * @param Query $query * * @return Speech */ public static function createSpeechStep(Query $query) { return new Speech($query->getResult()->getFulfillment()->getSpeech(), $query->getResult()->getContexts()); }