Get dialogflow fullfilment message in PHP

Overview

dialogflow-php

  • PHP Client Library for Dialogflow API v2

Requirements

Installation

  • To begin, lets clone this repository
git clone https://github.com/sumithemmadi/dialogflow-php.git
cd dialogflow-php
  • Then install the preferred dependencies for Dialogflow.
composer install

Before you begin

You should do the following before reading this guide:

  1. First create a project on Google Cloud Console then create a service account and download the private key file.
  2. Create Agent in Dialogflow and get the project ID from settings.

    for more details click here.

Create a service account and download the private key file

Create a service account:

  1. In the Cloud Console, go to the Create service account page.

    Go to Create service account

    image

  2. Select a project.
  3. In the Service account name field, enter a name. The Cloud Console fills in the Service account ID field based on this name.

    In the Service account description field, enter a description. For example, Service account for quickstart.

  4. Click Create and continue.
  5. Click the Select a role field.

    Under Quick access, click Basic, then click Owner.

    Note: The Role field affects which resources your service account can access in your project. You can revoke these roles or grant additional roles later. In production environments, do not grant the Owner, Editor, or Viewer roles. Instead, grant a predefined role or custom role that meets your needs.
  6. Click Continue.
  7. Click Done to finish creating the service account.

    Do not close your browser window. You will use it in the next step.

Create a service account key:

  1. In the Cloud Console, click the email address for the service account that you created.
  2. Click Keys.
  3. Click Add key, then click Create new key.
  4. Click Create. A JSON key file is downloaded to your computer.
  5. Click Close.

Usage

curl -sX POST  http://localhost:8080/dialogflow.php -d '{"sid":"1234567","message":"hi"}'
~$ curl -sX POST http://localhost:8080/dialogflow.php -d '{"sid":"12345678","message":"my name is sumith"}'

{
    "responseId": "f7f810a1-0043-4f85-ac6c-241705aa6b8a-94f60986",
    "queryResult": {
        "queryText": "my name is sumith",
        "languageCode": "en",
        "parameters": {
            "person": {
                "name": "sumith"
            }
        },
        "allRequiredParamsPresent": true,
        "fulfillmentText": "Sorry, I was not able to understand your intention . I'm trying to get better at this thing.",
        "fulfillmentMessages": [
            {
                "text": {
                    "text": [
                        "Sorry, I was not able to understand your intention . I'm trying to get better at this thing."
                    ]
                }
            }
        ],
        "intent": {
            "name": "projects\/sumith-rwup\/agent\/intents\/f95d3add-52fb-4119-87f0-e1717181173d",
            "displayName": "user.name"
        },
        "intentDetectionConfidence": 1
    }
}

Testing

  • After saving the service-account-file.json file in main directory.
  • start a PHP server (for testing purpose)
php -S localhost:8080
  • Now open http://localhost:8080 in any web browser.

  • Now enter any name in sender field and enter any message in message field.

  • Click send message you will see fullfilment message

Note: Wait untill you get fulfilment message.

LICENSE

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/

Copyright 2021 sumithemmadi

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

You might also like...
Get the system resources in PHP, as memory, number of CPU'S, Temperature of CPU or GPU, Operating System, Hard Disk usage, .... Works in Windows & Linux

system-resources. A class to get the hardware resources We can get CPU load, CPU/GPU temperature, free/used memory & Hard disk. Written in PHP It is a

MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way

Mysql Optimizer mysql optimizer also known as MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query

A php package to get the server information.

A php package to get you the server information Install Via Composer $ composer require ameetroy/server Usage use BubbleGum\Sweety; $getTotalSpace =

PHP scraper to get data from Google Play

nelexa/google-play-scraper PHP library to scrape application data from the Google Play store. Checking the exists of the app on Google Play. Retrievin

Get mobile app version and other related data from Google Play Store, Apple App Store and Huawei AppGallery

Mobile App Version Get mobile app version and other related data from Google Play Store, Apple App Store and Huawei AppGallery. Installation Add to co

ShellHacks 2021 Project: URide is a carpooling app for College students to get to and from campus
ShellHacks 2021 Project: URide is a carpooling app for College students to get to and from campus

ShellHacks 2021 Project: URide is a carpooling app for College students to get to and from campus. Focused on scheduling it matches you to students nearby with similar schedules to alleviate campus parking and emissions.

Supper quick use Aliyun OSS or Tencent COS or Qiniu Koa to get、put、delete Object.

An SDK integrating Alibaba cloud, Tencent cloud and qiniu cloud object storage

DiscordLookup | Get more out of Discord with Discord Lookup! Snowflake Decoder, Guild List with Stats, Invite Info and more...
DiscordLookup | Get more out of Discord with Discord Lookup! Snowflake Decoder, Guild List with Stats, Invite Info and more...

DiscordLookup Get more out of Discord with Discord Lookup! Snowflake Decoder, Guild List with Stats, Invite Info and more... Website Getting Help Tool

Enforce that your classes get only instantiated by the factories you define!

Enforce that your classes get only instantiated by the factories you define!

Comments
  • Bump guzzlehttp/psr7 from 2.1.0 to 2.2.1

    Bump guzzlehttp/psr7 from 2.1.0 to 2.2.1

    Bumps guzzlehttp/psr7 from 2.1.0 to 2.2.1.

    Release notes

    Sourced from guzzlehttp/psr7's releases.

    2.2.1

    See change log for changes.

    2.2.0

    See change log for changes.

    2.1.2

    See change log for changes.

    2.1.1

    See change log for changes.

    Changelog

    Sourced from guzzlehttp/psr7's changelog.

    2.2.1 - 2022-03-20

    Fixed

    • Correct header value validation

    2.2.0 - 2022-03-20

    Added

    • A more compressive list of mime types
    • Add JsonSerializable to Uri
    • Missing return types

    Fixed

    • Bug MultipartStream no uri metadata
    • Bug MultipartStream with filename for data:// streams
    • Fixed new line handling in MultipartStream
    • Reduced RAM usage when copying streams
    • Updated parsing in Header::normalize()

    2.1.1 - 2022-03-20

    Fixed

    • Validate header values properly
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • PHP Fatal error:  Uncaught Error: Call to undefined function Google\Protobuf\Internal\bccomp() in /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php:959

    PHP Fatal error: Uncaught Error: Call to undefined function Google\Protobuf\Internal\bccomp() in /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php:959

    uncaught error on submit button.

    [Wed Oct 6 14:30:13 2021] PHP Fatal error: Uncaught Error: Call to undefined function Google\Protobuf\Internal\bccomp() in /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php:959 Stack trace: #0 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1300): Google\Protobuf\Internal\Message->convertJsonValueToProtoValue() #1 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1239): Google\Protobuf\Internal\Message->mergeFromArrayJsonImpl() #2 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(867): Google\Protobuf\Internal\Message->mergeFromJsonArray() #3 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1292): Google\Protobuf\Internal\Message->convertJsonValueToProtoValue() #4 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1239): Google\Protobuf\Internal\Message->mergeFromArrayJsonImpl() #5 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(867): Google\Protobuf\Internal\Message->mergeFromJsonArray() #6 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1300): Google\Protobuf\Internal\Message->convertJsonValueToProtoValue() #7 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1239): Google\Protobuf\Internal\Message->mergeFromArrayJsonImpl() #8 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1336): Google\Protobuf\Internal\Message->mergeFromJsonArray() #9 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(793): Google\Protobuf\Internal\Message->parseFromJsonStream() #10 /home/microhawk/Desktop/dialogflow-php/vendor/google/gax/src/Transport/RestTransport.php(125): Google\Protobuf\Internal\Message->mergeFromJsonString() #11 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/Promise.php(204): Google\ApiCore\Transport\RestTransport->Google\ApiCore\Transport{closure}() #12 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler() #13 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}() #14 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(158): GuzzleHttp\Promise\TaskQueue->run() #15 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(183): GuzzleHttp\Handler\CurlMultiHandler->tick() #16 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\Handler\CurlMultiHandler->execute() #17 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn() #18 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending() #19 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList() #20 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending() #21 /home/microhawk/Desktop/dialogflow-php/vendor/google/cloud-dialogflow/src/V2/Gapic/SessionsGapicClient.php(503): GuzzleHttp\Promise\Promise->wait() #22 /home/microhawk/Desktop/dialogflow-php/test.php(81): Google\Cloud\Dialogflow\V2\Gapic\SessionsGapicClient->detectIntent() #23 {main} thrown in /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php on line 959 [Wed Oct 6 14:30:13 2021] [::1]:53372 [500]: POST /test.php - Uncaught Error: Call to undefined function Google\Protobuf\Internal\bccomp() in /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php:959 Stack trace: #0 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1300): Google\Protobuf\Internal\Message->convertJsonValueToProtoValue() #1 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1239): Google\Protobuf\Internal\Message->mergeFromArrayJsonImpl() #2 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(867): Google\Protobuf\Internal\Message->mergeFromJsonArray() #3 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1292): Google\Protobuf\Internal\Message->convertJsonValueToProtoValue() #4 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1239): Google\Protobuf\Internal\Message->mergeFromArrayJsonImpl() #5 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(867): Google\Protobuf\Internal\Message->mergeFromJsonArray() #6 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1300): Google\Protobuf\Internal\Message->convertJsonValueToProtoValue() #7 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1239): Google\Protobuf\Internal\Message->mergeFromArrayJsonImpl() #8 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1336): Google\Protobuf\Internal\Message->mergeFromJsonArray() #9 /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(793): Google\Protobuf\Internal\Message->parseFromJsonStream() #10 /home/microhawk/Desktop/dialogflow-php/vendor/google/gax/src/Transport/RestTransport.php(125): Google\Protobuf\Internal\Message->mergeFromJsonString() #11 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/Promise.php(204): Google\ApiCore\Transport\RestTransport->Google\ApiCore\Transport{closure}() #12 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler() #13 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}() #14 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(158): GuzzleHttp\Promise\TaskQueue->run() #15 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(183): GuzzleHttp\Handler\CurlMultiHandler->tick() #16 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\Handler\CurlMultiHandler->execute() #17 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn() #18 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending() #19 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList() #20 /home/microhawk/Desktop/dialogflow-php/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending() #21 /home/microhawk/Desktop/dialogflow-php/vendor/google/cloud-dialogflow/src/V2/Gapic/SessionsGapicClient.php(503): GuzzleHttp\Promise\Promise->wait() #22 /home/microhawk/Desktop/dialogflow-php/test.php(81): Google\Cloud\Dialogflow\V2\Gapic\SessionsGapicClient->detectIntent() #23 {main} thrown in /home/microhawk/Desktop/dialogflow-php/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php on line 959

    opened by micro-hawk 0
Releases(v1.0.7)
Owner
Emmadi Sumith Kumar
Emmadi Sumith Kumar
PHP Lightweight Message Bus supporting CQRS.

Prooph Service Bus PHP 7.1+ lightweight message bus supporting CQRS and Micro Services Important This library will receive support until December 31,

null 440 Nov 20, 2022
⚡ Php snippets, random stuff, demos, functions, fast message system, agnostic and framework free - 100% compactible ;) ⚡

⚡ Php8 FPM Nginx Fast, Scripts, Pearls & Treasures ?? Want to run and test asap ? docker-compose up -d phpgit_php8;ip=$(docker-machine ip default);ech

Benjamin FONTAINE 0 Mar 20, 2022
Ecotone Framework is Service Bus Implementation. It enables message driven architecture and DDD, CQRS, Event Sourcing PHP

This is Read Only Repository To contribute make use of Ecotone-Dev repository. Ecotone is Service Bus Implementation, which enables message driven arc

EcotoneFramework 308 Dec 29, 2022
Xenon\LaravelBDSms is a sms gateway package for sending text message to Bangladeshi mobile numbers using several gateways like sslcommerz, greenweb, dianahost,metronet in Laravel framework

Xenon\LaravelBDSms is a sms gateway package for sending text message to Bangladeshi mobile numbers using several gateways for Laravel. You should use

Ariful Islam 95 Jan 3, 2023
Magento 2 Message Queue Open Source Module

Magento 2 Message Queue Module Lightweight implementation of message queue for Magento 2 Community Edition. System requirements This extension support

Renato 36 Sep 30, 2021
This is an implementation of PSR specification. It allows you to send and consume message with Redis store as a broker.

This is an implementation of PSR specification. It allows you to send and consume message with Redis store as a broker.

Enqueue 35 Nov 4, 2022
Magento 2 Message Queue OS AMQP Broker Implementation

Magento 2 Message Queue AMQP Backend AMQP message queue backend implementation for Rcason_Mq. Installation Require the module via Composer $ composer

Renato 8 Jul 12, 2022
Ask your friends to send you an anonymous message without knowing them

Ask your friends to send you an anonymous message without knowing them. ????????

Siavash 1 Apr 16, 2022
Promoting the interoperability of message queue objects.

Queue Interoperability About queue-interop tries to identify and standardize a common way for PHP programs to create, send, receive and read MQ messag

null 446 Jan 3, 2023
WordPress block that displays a random "powered by" message, generally meant for footers.

X3P0 Powered By A block that generates a random "Powered by" message. It is meant to replace the typical "Powered by Theme/WordPress" message in foote

X3P0 4 Nov 4, 2022