Coder Social home page Coder Social logo

googleapis / python-dialogflow Goto Github PK

View Code? Open in Web Editor NEW
393.0 56.0 140.0 10.42 MB

This library has moved to https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-dialogflow

Home Page: https://dialogflow.com/

License: Apache License 2.0

python machine-learning dialogflow

python-dialogflow's Introduction

NOTE

This github repository is archived. The repository contents and history have moved to google-cloud-python.

Python Client for Dialogflow API

stable pypi versions

Dialogflow API: is an end-to-end, build-once deploy-everywhere development suite for creating conversational interfaces for websites, mobile applications, popular messaging platforms, and IoT devices. You can use it to build interfaces (such as chatbots and conversational IVR) that enable natural and rich interactions between your users and your business. Dialogflow Enterprise Edition users have access to Google Cloud Support and a service level agreement (SLA) for production deployments.

Quick Start

In order to use this library, you first need to go through the following steps:

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the Dialogflow API.
  4. Setup Authentication.

Installation

Install this library in a virtual environment using venv. venv is a tool that creates isolated Python environments. These isolated environments can have separate versions of Python packages, which allows you to isolate one project's dependencies from the dependencies of other projects.

With venv, it's possible to install this library without needing system install permissions, and without clashing with the installed system dependencies.

Code samples and snippets

Code samples and snippets live in the samples/ folder.

Supported Python Versions

Our client libraries are compatible with all current active and maintenance versions of Python.

Python >= 3.7

Unsupported Python Versions

Python <= 3.6

If you are using an end-of-life version of Python, we recommend that you update as soon as possible to an actively supported version.

Mac/Linux

python3 -m venv <your-env>
source <your-env>/bin/activate
pip install google-cloud-dialogflow

Windows

py -m venv <your-env>
.\<your-env>\Scripts\activate
pip install google-cloud-dialogflow

Next Steps

python-dialogflow's People

Contributors

b-loved-dreamer avatar busunkim96 avatar crwilcox avatar dandhlee avatar danoscarmike avatar deliaqi avatar dependabot[bot] avatar dizcology avatar dpebot avatar galz10 avatar gcf-owl-bot[bot] avatar google-cloud-policy-bot[bot] avatar jhoelzl avatar justinbeckwith avatar kurtisvg avatar leahecole avatar lukesneeringer avatar martini9393 avatar nicain avatar nnegrey avatar parthea avatar reichenbch avatar release-please[bot] avatar renovate-bot avatar rogers140 avatar slowy07 avatar surferjeffatgoogle avatar vchudnov-g avatar yil532 avatar yoshi-automation avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-dialogflow's Issues

Where is documentation on query_result instance

I have received the response as a <class 'google.cloud.dialogflow_v2.types.DetectIntentResponse'>

response.query_result give me another object with the information that I would like to access.
But how do i do that? Is there any documentation for the object?

e.g. How do I access the list of parameters?

Update an Intent

Hi,
can anyone please tell how to update an intent using update_intent? for example, if I want to add some more training phrases after intent has been created or to add message text after intent creation
Thanks

Ability to convert elements to more basic data structures (FeatureRequest)

(NOTE: for those looking for the answer look into from google.protobuf.json_format.MessageToDict)

I use SessionsClient.detect_intent to communicate with dialogflow. But if you like me need to analyse the custom payload by digging into query_result you find that it uses a non-trivial, barely documented datastructure.

I would like a way to convert this structure into pythons standard data types (enabling things like quick serialisation and analysis with less code).

I currently do it with this code:

def parse_messages(x):
    if isinstance(x, RepeatedCompositeFieldContainer) or isinstance(x, RepeatedScalarFieldContainer) \
            or isinstance(x, ListValue):
        return list([parse_messages(y) for y in list(x)])
    if isinstance(x, Value):
        return parse_messages(x.ListFields()[0][1])
    if isinstance(x, Struct):
        return parse_messages(x.fields)
    if isinstance(x, Message):
        return {y[0].name: parse_messages(y[1]) for y in x.ListFields()}
    if isinstance(x, MessageMap):
        return {y: parse_messages(z) for y, z in x.items()}
    return x

But I don't know if this is secure or wise. Also since I expect the response format from the server to be json it is overly complex to first convert it to the complex data type and afterwards having to convert it back.

I understand that this might not have the highest priority but I do believe it would greatly improve the usability of the library if elements like this were build in.

How to read the parameters that a query returns?

I'm currently programming with the dialogflow library for python, but when I get the list of parameters I get from an attempt, it returns me a Struct object that I don't know how to read.

 fields {
  key: "apellido1"
  value {
    string_value: "Baena"
  }
}
fields {
  key: "apellido2"
  value {
    string_value: "P\303\251rez"
  }
}
fields {
  key: "nombre"
  value {
    string_value: "Rub\303\251n"
  }
}

the documentation of the dialogflow library is very limited and there are no examples.

The best I can guess is that Struct is from the following route

google.protobuf.struct_pb2

Thank you very much for your help

Create followup intent

Hi,
can any one tell how to create followup intent of an intent?
I have created a welcome-intent and I want to create a followup intent of welcome-intent.
My code is:

followup_intent=dialogflow.types.Intent.FollowupIntentInfo(followup_intent_name="custom- followup")
 intent = dialogflow.types.Intent(
     display_name=display_name,
     training_phrases=training_phrases,
     messages=message,
     output_contexts=[
     dialogflow.types.Context(
     name=contexts_client.context_path("fir-chatbot-ccc2d", "-", "next-output"),lifespan_count=1)],
     input_context_names=["projects/project_id/agent/sessions/-/contexts/name"],
     webhook_state=dialogflow.enums.Intent.WebhookState.WEBHOOK_STATE_ENABLED,
     #is_fallback=True,
     parent_followup_intent_name="projects/project_id/agent/intents/id",
     followup_intent_info=[followup_intent]
)

It is showing this error google.api_core.exceptions.InvalidArgument: 400 'id' is not a valid intent ID
and when I print Intent_id by following:

intent_id=_get_intent_ids(project_id,"welcome-intent")
    print("intent_id:")
    id=intent_id[0]
    print(id)

I got an valid Id.I don't what I am doing wrong.I am referring this
https://github.com/dialogflow/dialogflow-python-client-v2/blob/master/samples/intent_management.py
I am beginner to dialogflow please help
Thanks

Create entity of agent

Hi,
Can anyone please tell me how to create entity in an agent? I am able to create entity_type using following.


def create_entity_type(project_id, display_name, kind):
    """Create an entity type with the given display name."""
    print("kind:")
    print(kind)
    project_id="fir-chatbot-ccc2d"
    entity_types_client = dialogflow.EntityTypesClient()
    parent = entity_types_client.project_agent_path(project_id)
    entity_type = dialogflow.types.EntityType(
        display_name=display_name, kind=kind)
    response = entity_types_client.create_entity_type(parent, entity_type)
    print('Entity type created: \n{}'.format(response))

But above code doesn't generate name field which should be automatically as given here.
https://cloud.google.com/dialogflow-enterprise/docs/reference/rpc/google.cloud.dialogflow.v2#google.cloud.dialogflow.v2.EntityType

Therefore entity_type which i created doesn't have any entity_type_id and when i run _get_entity_type_ids defined here.
https://github.com/dialogflow/dialogflow-python-client-v2/blob/master/samples/entity_type_management.py
I got entity_type_id as [].
so to create an entity I need entity_type_id as defined here.
https://github.com/dialogflow/dialogflow-python-client-v2/blob/master/samples/entity_management.py
But entity_type_id is empty.
please help
Thanks

Unable to import dialogflow_v2beta1

$ python --version
Python 2.7.13
$ python
Python 2.7.13 (default, Nov 24 2017, 17:33:09)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import dialogflow_v2beta1
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/dialogflow_v2beta1/init.py", line 17, in
from dialogflow_v2beta1 import types
File "/usr/local/lib/python2.7/dist-packages/dialogflow_v2beta1/types.py", line 21, in
from dialogflow_v2beta1.proto import agent_pb2
File "/usr/local/lib/python2.7/dist-packages/dialogflow_v2beta1/proto/agent_pb2.py", line 73, in
options=None, file=DESCRIPTOR),
TypeError: new() got an unexpected keyword argument 'file'

Raise coverage numbers to > 90%

After regenerating the v2 and v2beta1 endpoints coverage has declined to below 90%. Investigate the paths currently not covered by the generator outputted tests.

#73

Voice activity detection

How can I detect end of the voice command in the similar way as it is done in the web interface when testing the voice input?

Insufficient tokens for quota 'dialogflow.googleapis.com/requests'

Hi,
I am trying to create intetn and delete using dialogflow python sdk and getting this following error.

ResourceExhausted at /intervention/
429 Insufficient tokens for quota 'dialogflow.googleapis.com/requests' and limit 'RequestsPerMinutePerProject' of service 'dialogflow.googleapis.com' for consumer 'project_number-*********

please help me out here.
Thanks

Calling webhook through gRPC

Is it possible to use gRPC in place of HTTP, to make a webhook to receive the user's intent, their captured parameters and create a response text?

Create Context

How to send a dictionary in create_context(). As mentioned in documentation, dict should be of protobuf message. I am unable to create context. Please help.

Enable webhook for a intent

can anyone please tell how to enable webhook of a intent as defined here:
https://cloud.google.com/dialogflow-enterprise/docs/reference/rpc/google.cloud.dialogflow.v2#google.cloud.dialogflow.v2.Intent.WebhookState

I am not able to access how to use webhookstate enum.
I am doing
intent = dialogflow.types.Intent(
display_name=display_name,
training_phrases=training_phrases,
messages=[message],
output_contexts=[
dialogflow.types.Context(
name=contexts_client.context_path("fir-chatbot-ccc2d", "-", "next-output"),lifespan_count=1)],
input_context_names=["projects/project_id/agent/sessions/-/contexts/name"],
webhook_state=webhookstate.WEBHOOK_STATE_ENABLED
)

it is showing following error NameError: name 'webhookstate' is not defined.
please help!
Thanks

Integrate fullfillment(webhook enable for an agent) and call webhook

Hi,
I just want to know as we can set webhook in fulfillment section in dialogflow console and it automatically make a post request on provided url and if a webhook is enabled for particular intent then it takes the response from that webhook.
so my doubt is how to do this using sdk?
how can I set fulfillment or enable webhook in an agent so that request and response can be done using a webhook.
Please help
Thanks

Problems on trying to explicitly use credentials by specifying the private key file on SessionsClient.

Hi,

I`m using the SDK dialogflow V2 beta1 for python 2.7 on a CentOS 7 server and when I try to explicitly pass the private key file for creating a session like this:
session_client = dialogflow.SessionsClient(credentials='credentials path')

I get the following error (final line. I can add the whole stack if needed):
"Getting metadata from plugin failed with error: 'str' object has no attribute 'before_request'"

If no credentials is passed, setting the GOOGLE_APPLICATION_CREDENTIALS env variable works, but it does not fit for me, since I'd like to use many agents (project-id) on the same server.

Is it a known issue, or should I make it in a different way?

I`d appreciate any help.

Thanks!

Google assistant audio autput

Hi, there is a way to get the assistant response as a google assistant audio output? Now i get only text output. I enalbed the google assistant in the response section of the intent.

No response from API

Hi,

I am facing a specific issue which I thought you may shed some light on.
I am using Dialogflow to detect intents based on a text query. After setting up, I call:

response = session_client.detect_intent(
session=session, query_input=query_input)

This works fine locally. However, on my AWS Elastic Beanstalk instance, it either works or the script times out. There is no debug information nor errors.

Do you know what the issue may be?

The code used is directly from:
http://dialogflow-python-client-v2.readthedocs.io/en/latest/?#using-dialogflow

Note that I set my session_id to None because I don't care about tracking sessions currently.

Message type "google.cloud.dialogflow.v2.OriginalDetectIntentRequest" has no field named "version"

I was trying to parse a Dialogflow webhook request from Actions on Google to a dialogflow_v2beta1.proto.webhook_pb2.WebhookRequest(), using the example request given in the official dialogflow/fulfillment-webhook-json repo:

google.protobuf.json_format.ParseDict(request_dict, dialogflow_v2beta1.proto.webhook_pb2.WebhookRequest())

This failed with the following error:

ParseError: Failed to parse originalDetectIntentRequest field: Message type "google.cloud.dialogflow.v2beta1.OriginalDetectIntentRequest" has no field named "version".
 Available Fields(except extensions): <MessageFields sequence>

Looking at the google.cloud.dialogflow.v2.OriginalDetectIntentRequest protobuf definition (and also the compiled python descriptor) it seems that it is indeed missing the version field that is included in the request example, i.e. that either the protobuf or the example is wrong.

Permission Denied: 403 Dialogflow API has not been used in project before or it is disabled.

Issue:
Getting permission error when testing using "detect_intent_texts.py" from samples

google.api_core.exceptions.PermissionDenied: 403 Dialogflow API has not been used in project 563584335869 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/dialogflow.googleapis.com/overview?project=563584335869 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

I followed the instructions from "https://dialogflow.com/docs/reference/v2-auth-setup" to set up authentication & was able to trigger the final http post request successfully.

My project Id is not "563584335869", so when I visit that link it shows that I don't have access. Do I need to do some extra setting to point it to my project or something?

Sorry if I missed out some information, do let me know what else is needed, thanks!

training_phrases always missing for intent

While trying to obtain training phrases from my intents I found they are always missing.

This issue occurs for both list_intents as well as get_intent and both when trying to analyse intent.training_phrases as well as when inspecting intent.TrainingPhrases.

I've also tested this for multiple (populated) projects with multiple language codes.

intent.training_phrases always returns []

No proxy support

Can not use proxy settings. Any plans to provide support for proxies?

Install not working

Hi,

Just tried to install via pip ina CentOS 7 and got the following error:

[root@server~]# pip install dialogflow
Collecting dialogflow
  Downloading https://files.pythonhosted.org/packages/41/c7/fb3ea0db6f9754dbf498f1204c4013f7c43bed42049a86706d499825c930/dialogflow-0.2.0.tar.gz (155kB)
    100% |████████████████████████████████| 163kB 2.1MB/s
    Complete output from command python setup.py egg_info:
    error in dialogflow setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers

Any idea?

Thanks

Intermediate results on using session_client.streaming_detect_intent()

Hi,

Please, is there a way to get intermediate results on using session_client.streaming_detect_intent()?

I explain. I'd like to pass small recorded files which added (appended) compound an audio input stream.

I noticed that if you don't group the audio chunks in a iterator collection (yield), they will not be handled as an unique stream when calling streaming_detect_intent(), so you need to process the stream until you somehow detects the audio input stopped or something similar and then deliver the iterator collection for detection, which is kind of silly since we could have detected intents prior to the end of the streaming (almost the same effect of recording the audio and then calling detect_intent()).
Is there a way to call it separately and inform it is the same stream for getting intermediate results, thus dynamically decide to stop streaming and process the results?

Thanks a lot!

Using PyAudio streams

Hello!

I have taken your 'audio stream' example and replaced the reading of the file with a pyaudio stream instead from the Google Speech API Example. I am having issues with the data returned by the stream, my final response contains the following:

recognition_result {
  message_type: TRANSCRIPT
  transcript: "turn the lights off in the kitchen"
  is_final: true
}

But it does not include the query_result object that it's expecting, almost like it asked Google Speech fine for the STT but it did not flow through DialogFlow for intent parsing. Do you think you could either provide a pyaudio example or look at this file: https://paste.ofcode.org/pwqLWHVZ4mWHCYDsjmJa8f

Thanks!

Phil

Add example of using contexts with parameters

My team is having difficulty using the SDK with contexts that have parameters.

The documentation is messed up.
On
http://dialogflow-python-client-v2.readthedocs.io/en/latest/gapic/v2beta1/types.html?
highlight=QueryParameters#dialogflow_v2beta1.types.Context

section: dialogflow_v2beta1.types.Context

It says to go to "https://dialogflow.com/docs/actions-and-parameters" to get the format for parameters. The URL it links to does nothing to explain the format.

Simply passing the key/value pairs as in the context doesn't work. It generates the error:

`KeyError: 'foo'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/user/venv/chalicelib/df_driver/init.py", line 727, in
"parameters": inner_parameters
File "/Users/user/venv/lib/python3.6/site-packages/dialogflow_v2beta1/gapic/sessions_client.py", line 204, in detect_intent
input_audio=input_audio)
File "/Users/user/venv/lib/python3.6/site-packages/google/protobuf/internal/python_message.py", line 516, in init
new_val = field.message_type._concrete_class(**field_value)
File "/Users/user/venv/lib/python3.6/site-packages/google/protobuf/internal/python_message.py", line 503, in init
copy.add(**val)
File "/Users/user/venv/lib/python3.6/site-packages/google/protobuf/internal/containers.py", line 372, in add
new_element = self._message_descriptor._concrete_class(**kwargs)
File "/Users/user/venv/lib/python3.6/site-packages/google/protobuf/internal/python_message.py", line 516, in init
new_val = field.message_type._concrete_class(**field_value)
File "/Users/user/venv/lib/python3.6/site-packages/google/protobuf/internal/python_message.py", line 484, in init
field = _GetFieldByName(message_descriptor, field_name)
File "/Users/user/venv/lib/python3.6/site-packages/google/protobuf/internal/python_message.py", line 548, in _GetFieldByName
(message_descriptor.name, field_name))
ValueError: Protocol message Struct has no "foo" field.`

The detect_intent docs say:

...
query_params (Union[dict, ~dialogflow_v2beta1.types.QueryParameters]): Optional. The parameters of this query.
If a dict is provided, it must be of the same form as the protobuf
message :class:~dialogflow_v2beta1.types.QueryParameters
...

This format isn't documented anywhere. So unless the user has a really deep understanding of protocol buffers, users can't pass parameters in contexts while calling detect_intent.d

The sample code should really include a call to detect_intent that passes in a context with parameters.

In the absence of adding this to the sample code, could you at least respond to this request with an example of how to call detect_intent with a context that has parameters {"foo": ["bar", "baz"]}?

Setting Input context

Hi all,
I am trying to create a followup intent and trying to set its input context. but it is showing me following error.

TypeError: ('projects/project_id/agent/intents/25a5f667-c9d5-44b4-83f3-d611869f886c',) has type tuple, but expected one of: bytes, unicode
[27/Jun/2018 10:57:55] "POST /intervention/ HTTP/1.1" 500 16952

My code is following:

intent = dialogflow.types.Intent(
        #parameters= [parameter],
        display_name=display_name,
        training_phrases=training_phrases,
        messages=message,
        ml_disabled=False,
        root_followup_intent_name=root_followup_intent_name,
        parent_followup_intent_name=parent_followup_intent_name,        
        output_contexts=[
        dialogflow.types.Context(
        name=contexts_client.context_path(project_id, "-",output_context),lifespan_count=1)],
        input_context_names=[input_context_name]
  )

And my input_context_name is string as
projects/project_id/agent/sessions/-/contexts/question_1_followup
please help

Using V1 API with this?

My webhook can only handle V1 requests. Asking a question on the Dialogflow Console still works, since my agent is still V1. But using, for example, detect_intent_texts.py throws the error

{"id": "6152daac-c1f2-4d89-92b4-8ae15077e806",
"lang": "en",
"result": {
"action": "ask_for_hours",
"actionIncomplete": false,
"contexts": [],
"fulfillment": {
"messages": [],
"speech": ""
},
"metadata": {
"intentId": "e55fec4c-7937-4f75-be64-90e442e0cb8c",
"intentName": "get-office-hours",
"webhookForSlotFillingUsed": "true",
"webhookUsed": "true"
},
"parameters": {
"professor": [
"garrison"
]
},
"resolvedQuery": "When does garrison have office hours?",
"score": 1.0,
"source": "agent",
"speech": ""
},
"sessionId": "8904d38d-ad40-4e1d-82e1-d402965d84a4",
"status": {
"code": 200,
"errorType": "success"
},
"timestamp": "2018-06-07T19:44:59.788Z"
}
"Matched view func - get-office-hours"
['garrison']
['garrison']
{
"contextOut": [],
"data": {
"google": {
"expect_user_response": false,
"is_ssml": true,
"permissions_request": null
}
},
"displayText": null,
"messages": [
{
"speech": "garrison's office hours are at 5:30 p.m. Monday and Wednesday",
"type": 0
}
],
"source": "webhook",
"speech": "garrison's office hours are at 5:30 p.m. Monday and Wednesday"
}
127.0.0.1 - - [07/Jun/2018 15:44:59] "POST / HTTP/1.1" 200 -
dir
ras{
"id": "ab041b95-e6cd-44b4-8f6e-b5d2c6d27b91",
"lang": "en-us",
"originalRequest": {
"data": {},
"source": ""
},
"result": {
"action": "greet_and_start",
"actionIncomplete": false,
"contexts": [
{
"lifespan": 2,
"name": "greeting-followup",
"parameters": {}
}
],
"fulfillment": {
"messages": [],
"speech": ""
},
"metadata": {
"intentId": "fa5c4ed7-ba4c-4b3b-83b7-acf92e41b795",
"intentName": "greeting",
"webhookForSlotFillingUsed": "true",
"webhookUsed": "true"
},
"parameters": {},
"resolvedQuery": "hello",
"score": 1.0,
"source": "agent",
"speech": ""
},
"sessionId": "32287cf8-023e-4d08-baf1-c19d969875d8",
"status": {
"code": 200,
"errorType": "success"
},
"timestamp": "2018-06-07T19:55:55.767Z"
}
127.0.0.1 - - [07/Jun/2018 15:55:55] "POST / HTTP/1.1" 500 -
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2309, in call
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functionsrule.endpoint
File "/usr/local/lib/python3.6/site-packages/flask_assistant/core.py", line 291, in _flask_assitant_view_func
self.access_token = original_request['data']['user'].get('accessToken')
KeyError: 'user'

Is there anyway to send a V1 request using the samples given?

App Engine - ImportError: No module named google.api_core

Importing dialogflow into App Engine standard environment raises an ImportError that is likely caused by a package namespace conflict.

Steps to reproduce:

Start with hello-world: https://cloud.google.com/appengine/docs/standard/python/getting-started/python-standard-env

pip install dialogflow==0.1.0

In main.py, add import dialogflow

Run: dev_appserver.py app.yaml

Open http://localhost:8080

  ...
  File "/home/adam/Projects/test/main.py", line 1, in <module>
    import dialogflow
  File "/home/adam/Projects/test/lib/dialogflow/__init__.py", line 17, in <module>
    from dialogflow_v2beta1 import AgentsClient
  File "/home/adam/Projects/test/lib/dialogflow_v2beta1/__init__.py", line 17, in <module>
    from dialogflow_v2beta1 import types
  File "/home/adam/Projects/test/lib/dialogflow_v2beta1/types.py", line 18, in <module>
    from google.api_core.protobuf_helpers import get_messages
  File "/home/adam/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/sandbox.py", line 1147, in load_module
    raise ImportError('No module named %s' % fullname)
ImportError: No module named google.api_core

Can I create a SessionsClient while explicitly passing a service_account.json?

I'd like to create a dialogflow.SessionsClient without having to define GOOGLE_APPLICATION_CREDENTIALS (as I'm consuming the package in another library).

Reading this document tells me I should be able to use a method like from_service_account_json to instantiate my client, but the library does not seem to expose such method.

I also looked at google.auth.credentials in order to pass acredentials arg to the constructor, but it looks like it doesn't know how to do this either.

Is there any way of passing the location of a credentials file to the SessionsClient constructor? Or could I read the file myself and create an instance of google.auth.credentials.Credentials myself?

Module 'dialogflow' has no attribute 'SessionsClient'

Using dialogflow-0.1.0

import dialogflow

session_client = dialogflow.SessionsClient()

Error message:

Traceback (most recent call last):
  File "dialogflow.py", line 1, in <module>
    import dialogflow
  File "dialogflow.py", line 3, in <module>
    session_client = dialogflow.SessionsClient()
AttributeError: module 'dialogflow' has no attribute 'SessionsClient'

Tested on both Windows 10 and Ubuntu 16.04 (Windows subsystem linux)

Connection Intialization failed, statuscode 401, reason: Access Denied

Hi,

My connection with dialogflow bot stopped working 2 days ago, with the error above.
Key is ok, account is still valid and assigned and I'm using version 2 protocol.

Any idea if something changed on oauth2 services account?
Other project on google cloud working fine at the same server.

How to debug it to discover why it stopped work?

Thanks a lot!

Segmentation fault on help(entity)

Calling help on an EntityType leads to a Segmentation fault: 11. See this iPython session:

$ ipython
Python 3.6.4 (default, Jan  6 2018, 11:51:59) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.3.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import dialogflow as df

In [2]: client = df.EntityTypesClient()

In [3]: name = client.entity_type_path('<project_id>', '<entity_id>')

In [4]: entity = client.get_entity_type(name)

In [5]: help(entity)
Segmentation fault: 11
$

Versions:

  • Python: 3.6.4
  • Pip: 9.0.1
  • OS: macOS 10.13.4
  • Dialogflow SDK: 0.2.0
  • Google Cloud SDK: 198.0.0

Add method to convert DialogFlow fulfillment requests to DetectIntentResponse objects

I use DialogFlow for Actions on Google, Facebook Messenger, and for bots on websites.
I use this SDK for Facebook, rather than DialogFlow's own integration method, because DialogFlow's automatic Facebook integration does not support deep links.

I'd like to convert the JSON payload sent from DialogFlow to my webhook from JSON into a DetectIntentResponse object, so that I can use the same fulfillment logic for all platforms.

Could you please add and document a method for this? I'm trying to write my own, but I'm having difficulty understanding the best way to instantiate an instance of the DetectIntentResponse object.

Specify agent (environment) version when calling detect_intent_texts

DialogFlow environments allows users to publish different versions of their agent.

The Python SDK should add an argument to the detect_intent_texts that specifies the version of the agent that they wish to use.

For example, a user may wish to publish a version of their agent that does not call the fulfillment webhook with each request. This is a great DialogFlow feature. But, unless the SDK is updated to be able to specify the version of the agent, the feature can't be used.

Illegal Instruction on arm devices

Hey folks! Awesome library - its been working flawlessly on my laptop.

However, when installing the package through pip on a raspberry pi - sudo pip3 install dialogflow - and (presumably) downloading binaries through that, after importing the module I get an Illegal Instruction error, and the thread crashes. Typically it would look like this:

Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170124] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dialogflow
Illegal instruction

Incase it saves you a quick google here is a screenfetch detailing specs of the board I'm using.

    .',;:cc;,'.    .,;::c:,,.    pi@raspberrypi
   ,ooolcloooo:  'oooooccloo:    OS: Raspbian 9.4 stretch
   .looooc;;:ol  :oc;;:ooooo'    Kernel: armv6l Linux 4.14.30+
     ;oooooo:      ,ooooooc.     Uptime: 14m
       .,:;'.       .;:;'.       Packages: 515
       .... ..'''''. ....        Shell: 594
     .''.   ..'''''.  ..''.      CPU: ARMv6-compatible rev 7 (v6l) @ 1GHz
     ..  .....    .....  ..      RAM: 37MiB / 433MiB
    .  .'''''''  .''''''.  .    
  .'' .''''''''  .'''''''. ''.  
  '''  '''''''    .''''''  '''  
  .'    ........... ...    .'.  
    ....    ''''''''.   .''.    
    '''''.  ''''''''. .'''''    
     '''''.  .'''''. .'''''.    
      ..''.     .    .''..      
            .'''''''            
             ......       

Intent training phrases returning empty list

Having issues when I'm trying to print out the training phrases for the individual intents of the agent:

intents_client = dialogflow.IntentsClient()

parent = intents_client.project_agent_path(project_id)

intents = intents_client.list_intents(parent)

for intent in intents:
    print('=' * 40)
    print('Intent name: {}'.format(intent.name))
    print('Intent display_name: {}'.format(intent.display_name))
    print('Intent training phrases: {}'.format(intent.training_phrases))
    print('Intent messages: {}'.format(intent.messages))

The intent name, display name and message are all displayed apart from training phrases which always seems to be an empty list :(

TypeError on detect_intent with query_input specified as dict

According to the documentation SessionsClient.detect_intent should work with a dict as the query_input. The docs don't say what keys must be in that dict, but assuming they are the same as in the dialogflow_v2beta1.types.QueryInput classes I tried this example (which is taken almost word for word from the documentation):

$ ipython
Python 3.6.4 (default, Jan  6 2018, 11:51:59) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.3.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from dialogflow_v2beta1 import SessionsClient

In [2]: client = SessionsClient()

In [3]: session = client.session_path('MY_AGENT', 'abcdefg123')

In [4]: query_input = {'text': 'talk to MY_AGENT', 'language_code': 'en-US'}

In [5]: response = client.detect_intent(session, query_input)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-b6d5f075ffb7> in <module>()
----> 1 response = client.detect_intent(session, query_input)

~/<project_dir>/venv/lib/python3.6/site-packages/dialogflow_v2beta1/gapic/sessions_client.py in detect_intent(self, session, query_input, query_params, input_audio, retry, timeout)
    202             query_input=query_input,
    203             query_params=query_params,
--> 204             input_audio=input_audio)
    205         return self._detect_intent(request, retry=retry, timeout=timeout)
    206 

TypeError: Parameter to MergeFrom() must be instance of same class: expected google.cloud.dialogflow.v2beta1.TextInput got str.

Wrapping the input in a dialogflow.v2beta1.types.QueryInput works, but that requires two additional object instantiations and should not be necessary according to the current documentation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.