Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working on getting a simple v2 example going. Need some guidance #60

Open
scottlahay opened this issue Oct 16, 2018 · 2 comments
Open

Comments

@scottlahay
Copy link

I have been working on a google app engine project using the v2 branch. Looking for some guidence. I copied the DialogflowWebhook example and got a late init error that went away when I set Serializer.aogGson = Gson()

now I'm getting this exception

Uncaught exception from servlet
java.lang.Error: No response has been set. Is this being used in an async call that was not returned as a promise to the intent handler?
at actions.service.actionssdk.conversation.Conversation.response(Conversation.kt:391)
at actions.service.dialogflow.DialogflowConversation.commonPayload(Conv.kt:321)
at actions.service.dialogflow.DialogflowConversation.serialize(Conv.kt:366)
at actions.service.dialogflow.DialogflowSdk$handler$1.handle(Dialogflow.kt:450)
at actions.framework.StandardHandler$DefaultImpls.handle$default(Framework.kt:51)
at actions.expected.ServletHandler.handle(BuiltinFrameworks.kt:36)
at actions.service.dialogflow.DialogflowSdk$1.handle(Dialogflow.kt:463)
at actions.ServiceBaseApp.invoke(Assistant.kt:21)
at scott.servlets.FitnessAssistantServlet.simpleDialogFlowExample(FitnessAssistantServlet.kt:30)
at scott.servlets.FitnessAssistantServlet.doPost(FitnessAssistantServlet.kt:21)

My code

data class MyConversation(val temp: String? = null)
data class MyArgument(val temp: String? = null, var resultType: String? = null, var userDescision: String? = null)

class FitnessAssistantServlet: HttpServlet() {
    val logger = Logger.getLogger("TestServlet")

    @Throws(ServletException::class, IOException::class)
    override fun doPost(req: HttpServletRequest, resp: HttpServletResponse) {
        val dfApp = dialogflow<UserStorage<Any>, MyConversation, MyArgument>()
        dfApp.frameworks.add(ServletFramework())
        dfApp.intent("test") { conv -> conv.ask("Can you hear me?") }
        dfApp(req, res
    }
}

It feels like I'm missing some initialization logic somewhere, not sure where though.
Thoughts?

@scottlahay scottlahay changed the title V2 working on getting a simple example going. Need some guidance Working on getting a simple v2 example going. Need some guidance Oct 16, 2018
@patjackson52
Copy link
Contributor

only thing that stands out right now is possibly adding multiple ServletFrameworks . Can you ensure that only one is added and test again?

@scottlahay
Copy link
Author

scottlahay commented Nov 14, 2018

As you asked I ensured the servlet framework is only getting initialized once. I did have to add org.slf4j:slf4j-jdk14:1.7.25 as a dependency. Different error!

My code

class MainServlet : HttpServlet() {

data class MyConversation(val temp: String? = null)
data class MyArgument(val temp: String? = null, var resultType: String? = null, var userDescision: String? = null)
var hasAddedFramework = false

@Throws(ServletException::class, IOException::class)
override fun doPost(req: HttpServletRequest, resp: HttpServletResponse) {
    val dfApp = dialogflow<UserStorage<Any>, MyConversation, MyArgument>()
    if (!hasAddedFramework) {
        Serializer.aogGson = Gson()
        dfApp.frameworks.add(ServletFramework())
        hasAddedFramework = true
    }
    dfApp.intent("help") { conv -> conv.ask("Can you hear me?") }
    dfApp(req, resp)
}}

Log data

ava.lang.ClassCastException: org.eclipse.jetty.server.Request cannot be cast to actions.service.actionssdk.api.GoogleActionsV2AppRequest
at actions.service.dialogflow.DialogflowSdk$1.handle(Dialogflow.kt:466)
at actions.ServiceBaseApp.invoke(Assistant.kt:21)
at scott.servlets.MainServlet.actionsOnGoogleStuff(MainServlet.kt:38)
at scott.servlets.MainServlet.doPost(MainServlet.kt:26)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)

I'm taking a look now, to see if I can figure out whats causing the class cast

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants