src/WebhookClient.php
public function setOutgoingContext($context)
    {
        if (is_string($context)) {
            $outgoingContext = new Context($context);
        } elseif (is_array($context)) {
            if (! isset($context['name'])) {
                throw new RuntimeException('Context must have a name');
            }

            $name = $context['name'];

            $lifespan = 1;
            if (isset($context['lifespan'])) {
                $lifespan = is_numeric($context['lifespan']) ? $context['lifespan'] : null;
            }

            $parameters = [];
            if (isset($context['parameters'])) {
                $parameters = is_array($context['parameters']) ? $context['parameters'] : null;
            }

            $outgoingContext = new Context($name, $lifespan, $parameters);
        } elseif ($context instanceof Context) {
            $outgoingContext = $context;
        } else {
            throw new RuntimeException('Context must be provided');
        }

        $this->outgoingContexts[] = $outgoingContext;

        return $this;
    }
public function setOutgoingContext($context)
    {
        if (is_string($context)) {
            $outgoingContext = new Context($context);
        } elseif (is_array($context)) {
            if (! isset($context['name'])) {
                throw new RuntimeException('Context must have a name');
            }

            $name = $context['name'];

            $lifespan = 1;
            if (isset($context['lifespan'])) {
                $lifespan = is_numeric($context['lifespan']) ? $context['lifespan'] : null;
            }

            $parameters = [];
            if (isset($context['parameters'])) {
                $parameters = is_array($context['parameters']) ? $context['parameters'] : null;
            }

            $outgoingContext = new Context($name, $lifespan, $parameters);
        } elseif ($context instanceof Context) {
            $outgoingContext = $context;
        } else {
            throw new RuntimeException('Context must be provided');
        }

        $this->outgoingContexts[] = $outgoingContext;

        return $this;
    }
public function setOutgoingContext ( $ context ) { if ( is_string ( $ context ) ) { $ outgoingContext = new Context ( $ context ) ; } elseif ( is_array ( $ context ) ) { if ( ! isset ( $ context [ 'name' ] ) ) { throw new RuntimeException ( 'Context must have a name' ) ; } $ name = $ context [ 'name' ] ; $ lifespan = 1 ; if ( isset ( $ context [ 'lifespan' ] ) ) { $ lifespan = is_numeric ( $ context [ 'lifespan' ] ) ? $ context [ 'lifespan' ] : null ; } $ parameters = [ ] ; if ( isset ( $ context [ 'parameters' ] ) ) { $ parameters = is_array ( $ context [ 'parameters' ] ) ? $ context [ 'parameters' ] : null ; } $ outgoingContext = new Context ( $ name , $ lifespan , $ parameters ) ; } elseif ( $ context instanceof Context ) { $ outgoingContext = $ context ; } else { throw new RuntimeException ( 'Context must be provided' ) ; } $ this -> outgoingContexts [ ] = $ outgoingContext ; return $ this ; }
Set a new Dialogflow outgoing context.
Reference: https://dialogflow.com/docs/contexts.

@param string|array|\Dialogflow\Context $context

@return \Dialogflow\WebhookClient
Set a new Dialogflow outgoing context . Reference : https : // dialogflow . com / docs / contexts .