lundi 4 octobre 2021

Using DialogFlow ES EventInput on Laravel + SQLite

I'm new to DialogFlow API and created Laravel sandbox app, that takes some query data and sends it to a database. I would like to use HTTP Protocol to start a conversation via EventQuery, but could not figure out the whole way to do it.

There is a JavaScript app that uses hardcoded event query parameters and sends it to a simple UI. This is almost it, but without db.

EventQuery class: https://github.com/googleapis/google-cloud-php-dialogflow/blob/master/src/V2/EventInput.php

Laravel sandbox app: https://phpsandbox.io/e/x/gziyh?layout=EditorPreview&defaultPath=%2F&theme=dark&showExplorer=no&openedFiles=

JavaScript app with eventQuery: https://github.com/fitwist/chatbot-app

How do I send an EventQuery request, made of form data, send data to SQLite at the same time and continue the dialogue in simple UI?

Possible template:

<?php 
namespace Google\Cloud\Dialogflow\V2;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;

class EventInput extends \Google\Protobuf\Internal\Message
{

    private $name = '';
    private $parameters = null;
    private $language_code = '';

    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Dialogflow\V2\Session::initOnce();
        parent::__construct($data);
    }

    public function getName()
    {
        return $this->name;
    }

    public function setName($var)
    {
        GPBUtil::checkString($var, True);
        $this->name = $var;

        return $this;
    }

    public function getParameters()
    {
        return isset($this->parameters) ? $this->parameters : null;
    }

    public function hasParameters()
    {
        return isset($this->parameters);
    }

    public function clearParameters()
    {
        unset($this->parameters);
    }

    public function setParameters($var)
    {
        GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class);
        $this->parameters = $var;

        return $this;
    }

    public function getLanguageCode()
    {
        return $this->language_code;
    }

    public function setLanguageCode($var)
    {
        GPBUtil::checkString($var, True);
        $this->language_code = $var;

        return $this;
    }

}
?>

<!DOCTYPE html>
<html>
    

    <section class="container grey-text">
        <h4 class="center">Add a Pizza</h4>
        <form class="white" action="add.php" method="POST">
            <label>Your Email</label>
            <input type="text" name="email">
            <label>Your Name</label>
            <input type="text" name="name">
            <label>Company</label>
            <input type="text" name="company">
            <div class="center">
                <input type="submit" name="submit" value="Submit" class="btn brand z-depth-0">
            </div>
        </form>
    </section>
</html>

I would appreciate any of your help, because the struggle has already taken three months.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3ixlpj3
via IFTTT

Aucun commentaire:

Enregistrer un commentaire