NluAdapter::Dialogflow

Adapter for Google Dialogflow

Setup

Please check the documentation.

Examples

  1. Parse a text and identify intent from an existing Dialogflow bot
require 'nlu_adapter'

d = NluAdapter.new(:Dialogflow, {project_id: "test-1-NNNN", session_id: 'SESSION1'})

puts d.parse('I want to book a hotel')

{:intent_name=>"BookHotel"}
  1. Create an intent
require 'nlu_adapter'

d = NluAdapter.new(:Dialogflow, {project_id: "test-1-NNNN", session_id: 'SESSION1'})
i = d.new_intent('BookHotel', ['please book a hotel', 'I want to book a hotel'])

d.create_intent(i)

  1. Create an intent collection

Create an Agent from Dialogflow console.

Running examples

$ cat test-df-1.rb
require 'nlu_adapter'

d = NluAdapter.new(:Dialogflow, {project_id: "test-1-NNNN", session_id: 'SESSION1'})

puts d.parse('I want to book a hotel')

$ GOOGLE_APPLICATION_CREDENTIALS='./test-1-NNNN.json' ruby ./test-df-1.rb
{:intent_name=>"BookHotel"}