Code Monkey home page Code Monkey logo

dialogflow-log-parser-dataflow-bigquery's Introduction

Dialogflow Log Parser

This repository contains an example of how to leverage Cloud Dataflow and BigQuery to view Dialogflow interactions.

The Pipeline Steps are as follows:

  1. Dialogflow Interactions are logged to Google Cloud Logging
  2. A Cloud Logging sink sends the log messages to Cloud Pub/Sub
  3. Dataflow process the textpayload and streams it to BigQuery
  4. Access to the log interactions are now available in BigQuery

Dialogflow Log Parser Diagram

Note: Dialogflow Interactions Logging is sent to Cloud Logging as a Text Payload, this code will parse the Text Payload to a structured format within BigQuery which is defined in the Dataflow code.

BigQuery Schema

You can change the schema as required in the Dataflow code to include other key:value pairs extracted from Cloud Logging. Here is a reference to the current schema:

Field name Type
session_id STRING
trace STRING
caller_id STRING
email STRING
timestamp TIMESTAMP
receiveTimestamp TIMESTAMP
resolved_query STRING
string_value STRING
speech STRING
is_fallback_intent STRING
webhook_for_slot_filling_used STRING
webhook_used STRING
intent_name STRING
intent_id STRING
action STRING
source STRING
error_type STRING
code STRING
insertId STRING
logName STRING
lang STRING
textPayload STRING

Installation

  1. Enable the Dataflow API

    gcloud services enable dataflow
  2. Create a Storage Bucket for Dataflow Staging

    gsutil mb gs://[BUCKET_NAME]/
  3. Create a folder in the newly created bucket in the Google Cloud Console Storage Browser called tmp

  4. Create a Pub/Sub Topic

    gcloud pubsub topics create [TOPIC_NAME]
  5. Create a Cloud Logging sink

    gcloud logging sinks create [SINK_NAME] pubsub.googleapis.com/projects/[PROJECT_ID]/topics/[TOPIC_NAME] --log-filter="resource.type=global"
  6. Install the Apache Beam GCP Library

    python3 -m virtualenv tempenv
    source tempenv/bin/activate
    pip install apache-beam[gcp]
  7. Create BigQuery dataset

  8. Deploy Dataflow Job

    python3 stackdriverdataflowbigquery.py --project=[YOUR_PROJECT_ID] \ 
    --input_topic=projects/[YOUR_PROJECT_ID]/topics/[YOUR_TOPIC_NAME] \ 
    --runner=DataflowRunner --temp_location=gs://[YOUR_DATAFLOW_STAGING_BUCKET]/tmp \
    --output_bigquery=[YOUR_BIGQUERY_DATASET.YOUR BIGQUERY_TABLE] --region=us-central1
  9. Enable Dialogflow Logs to Cloud Logging

    Enable Log interactions to Dialogflow and Google Cloud https://cloud.google.com/dialogflow/docs/history#access_all_logs

Once you enable Enable Log interactions, your new Dialogflow interactions will be available in BigQuery

This is not an officially supported Google product

dialogflow-log-parser-dataflow-bigquery's People

Contributors

ruiscosta avatar

Stargazers

 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

dialogflow-log-parser-dataflow-bigquery's Issues

Big Query Empty result For Dialog Flow CX

Greetings, Thanks for sharing this code. The log parser is able to get the records, process and stream to the Big Query. But in big query the result is null in all columns except for timestamp, receive timestamp, insert_id and log_name.
Big Query Results Attached:
image
image
image
image

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.