Giter Club home page Giter Club logo

Comments (7)

Fleker avatar Fleker commented on July 21, 2024

This is the same as #17, where you can clone the object to a mutable implementation.

from actions-on-google-java.

cbeaujoin avatar cbeaujoin commented on July 21, 2024

As said in #17 userStorage works fine when cloned.

But conversationData doesn't works.

The conversationData is overrided in ResponseSerializer.kt

contexts?.forEach { setContext(it, webhookResponse) }

You should put it before line 86

As workaround you can try to access and modify conversationData trough context

ActionContext context = request.getContext(request.getSessionId() + "/contexts/" + "_actions_on_google");
String serializedData = (String) context.getParameters().get("data");
Type empMapType = new TypeToken<Map<String, Object>>() {}.getType();
Map<String, Object> conversationData = new Gson().fromJson(serializedData, empMapType);
...
conversationData.put("test", test);
responseContext.getParameters().put("data", conversationData);

Edit:
The workaround was a bad idea, once the conversationData has been set it can't be parse in the next request due to a class cast exception (String <=> LinkedTreeMap).

val serializedData = parameters?.get("data") as String

from actions-on-google-java.

Fleker avatar Fleker commented on July 21, 2024

The same thing seems to work for conversation data in Kotlin

val sessionData = mutableMapOf<String, Any>()
sessionData.putAll(aogRequest.conversationData)

val headquarters = sessionData["headquarters"] as MutableList<String>
assertEquals("google1", headquarters[0])
headquarters[0] = "google2"

sessionData["headquarters"] = headquarters
val responseBuilder =
        ResponseBuilder(usesDialogflow = false, conversationData = sessionData)

val aogResponse = responseBuilder.build()
val jsonOutput = aogResponse.toJson()

from actions-on-google-java.

cbeaujoin avatar cbeaujoin commented on July 21, 2024

Have you noticed that conversationData is overided by the context: [sessionId]/contexts/_actions_on_google

from actions-on-google-java.

Fleker avatar Fleker commented on July 21, 2024

When using Dialogflow?

from actions-on-google-java.

cbeaujoin avatar cbeaujoin commented on July 21, 2024

When using Dialogflow?

Yes

from actions-on-google-java.

taycaldwell avatar taycaldwell commented on July 21, 2024

Closing as a duplicate of #17

For separate/unrelated bugs, please open a new issue.

from actions-on-google-java.

Related Issues (20)

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.