ticketmaster / actions-on-google-kotlin

Unofficial Actions on Google SDK for Kotlin and Java
Apache License 2.0
119 stars 20 forks source link

action not recognized? #52

Closed davidmarinangeli closed 6 years ago

davidmarinangeli commented 6 years ago

Hello, I'm experiencing some problem with your library. I'm using your code to recognize the action after a request:

My intent action return "tell.popular" (this is the request that Dialogflow sends):

{
  "responseId": "589e1fb4-56b6-4377-8944-16b442090958",
  "queryResult": {
    "queryText": "popolare",
    **"action": "tell.popular",**
    "parameters": {
      "Filtro": "Popolarità"
    },
    "allRequiredParamsPresent": true,
    "fulfillmentMessages": [
      {
        "text": {
          "text": [
            ""
          ]
        }
      }
    ],
    "intent": {
      "name": "projects/nespressoadvisor/agent/intents/bb7a2662-2851-4d68-bb86-92d368b6d195",
      "displayName": "choose_popular"
    },
    "intentDetectionConfidence": 1,
    "diagnosticInfo": {},
    "languageCode": "it"
  },
  "webhookStatus": {
    "message": "Webhook execution successful"
  }
}

and here is the code. Unfortunately it doesn't work and I can't find a way to check the whole flow from handleRequest(actionMap) and check how is managed the request.

Furthermore, if I try to evaluate the DialogflowAction(req, res).handleRequest(actionMap) line during debug, it returns me "undefined". (???)

Could you help me?

const val POPULAR = "tell.popular"

@WebServlet(name = "Hello", value = "/")
class HomeController : HttpServlet() {

    val actionMap = mapOf(POPULAR to ::popular)

    fun popular(app: DialogflowApp) =
            app.ask(app.buildRichResponse()
                    .addSimpleResponse(speech = "Hi there!", displayText = "Hello there!")
                    .addSimpleResponse(
                            speech = """I can show you basic cards, lists and carousels as well as suggestions on your phone""",
                            displayText = """I can show you basic cards, lists and carousels as well as suggestions""")
                    .addSuggestions("Basic Card", "List", "Carousel", "Suggestions"))

    override fun doPost(req: HttpServletRequest, res: HttpServletResponse) {

        DialogflowAction(req, res).handleRequest(actionMap)

    }
MrDyro commented 6 years ago

@davidmarinangeli It looks like you're using Dialogflow api version 2 which is not supported by this framework yet.

patjackson52 commented 6 years ago

@MrDyro Thanks for the input. Was that indeed the case @davidmarinangeli ? If so we can close this issue. V2 support is in the works.

davidmarinangeli commented 6 years ago

Yes, seems that this was the main problem. The following problem was the one opened here but, as you mentioned, we will wait for V2.

patjackson52 commented 6 years ago

This will be resolved once V2 is live https://github.com/Ticketmaster/actions-on-google-kotlin/issues/54