Skip to content

Latest commit

 

History

History

dialogflow-cx

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Dialogflow CX API Python Samples

https://gstatic.com/cloudssh/images/open-btn.png

This directory contains samples for Dialogflow CX API. The Dialogflow CX API enables you to create conversational experiences across devices and platforms.

Setup

Authentication

This sample requires you to have authentication setup. Refer to the Authentication Getting Started Guide for instructions on setting up credentials for applications.

Install Dependencies

  1. Clone python-docs-samples and change directory to the sample directory you want to use.

    $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
  2. Install pip and virtualenv if you do not already have them. You may want to refer to the Python Development Environment Setup Guide for Google Cloud Platform for instructions.

  3. Create a virtualenv. Samples are compatible with Python 3.6+.

    $ virtualenv env
    $ source env/bin/activate
  4. Install the dependencies needed to run the samples.

    $ pip install -r requirements.txt

Samples

Detect Intent Text

https://gstatic.com/cloudssh/images/open-btn.png

To run this sample:

$ python detect_intent_texts.py


usage: detect_intent_texts.py [-h] --agent AGENT [--session-id SESSION_ID]
                              [--language-code LANGUAGE_CODE]
                              texts [texts ...]

DialogFlow API Detect Intent Python sample with text inputs.

Examples:
  python detect_intent_texts.py -h
  python detect_intent_texts.py --agent AGENT   --session-id SESSION_ID   "hello" "book a meeting room" "Mountain View"
  python detect_intent_texts.py --agent AGENT   --session-id SESSION_ID   "tomorrow" "10 AM" "2 hours" "10 people" "A" "yes"

positional arguments:
  texts                 Text inputs.

optional arguments:
  -h, --help            show this help message and exit
  --agent AGENT         Agent resource name. Required.
  --session-id SESSION_ID
                        Identifier of the DetectIntent session. Defaults to a
                        random UUID.
  --language-code LANGUAGE_CODE
                        Language code of the query. Defaults to "en-US".

Detect Intent Audio

https://gstatic.com/cloudssh/images/open-btn.png

To run this sample:

$ python detect_intent_audio.py


usage: detect_intent_audio.py [-h] --agent AGENT [--session-id SESSION_ID]
                              [--language-code LANGUAGE_CODE]
                              --audio-file-path AUDIO_FILE_PATH

DialogFlow API Detect Intent Python sample with audio file.

Examples:
  python detect_intent_audio.py -h
  python detect_intent_audio.py --agent AGENT   --session-id SESSION_ID --audio-file-path resources/hello.wav

optional arguments:
  -h, --help            show this help message and exit
  --agent AGENT         Agent resource name. Required.
  --session-id SESSION_ID
                        Identifier of the DetectIntent session. Defaults to a
                        random UUID.
  --language-code LANGUAGE_CODE
                        Language code of the query. Defaults to "en-US".
  --audio-file-path AUDIO_FILE_PATH
                        Path to the audio file.

Detect Intent Stream

https://gstatic.com/cloudssh/images/open-btn.png

To run this sample:

$ python detect_intent_stream.py


usage: detect_intent_stream.py [-h] --agent AGENT [--session-id SESSION_ID]
                               [--language-code LANGUAGE_CODE]
                               --audio-file-path AUDIO_FILE_PATH

DialogFlow API Detect Intent Python sample with audio files processed as an audio stream.

Examples:
  python detect_intent_stream.py -h
  python detect_intent_stream.py --agent AGENT   --session-id SESSION_ID --audio-file-path resources/hello.wav

optional arguments:
  -h, --help            show this help message and exit
  --agent AGENT         Agent resource name. Required.
  --session-id SESSION_ID
                        Identifier of the DetectIntent session. Defaults to a
                        random UUID.
  --language-code LANGUAGE_CODE
                        Language code of the query. Defaults to "en-US".
  --audio-file-path AUDIO_FILE_PATH
                        Path to the audio file.

The client library

This sample uses the Google Cloud Client Library for Python. You can read the documentation for more details on API usage and use GitHub to browse the source and report issues.