Giter Club home page Giter Club logo

Comments (9)

zonder129 avatar zonder129 commented on July 21, 2024 1

Hi @Fleker, is there any update coming to solve this bug? There is still no way to properly clone userStorage map or create your own ResponseBuilder, as you did in the example above. Try it your self:

val actionRequest = MockRequestBuilder().setUserStorage(mapOf(Pair("userId","someId"))).build()
val userStorage = mutableMapOf<String, Any>()
userStorage.putAll(actionRequest.userStorage)
userStorage["key"] = "value"
println(userStorage)

The output will be only:
{key=value}

ResponseBuilder is also unavailable to be created because its constructor is internal. So there is no way to create it outside com.google.actions.api.response package.

from actions-on-google-java.

taycaldwell avatar taycaldwell commented on July 21, 2024

Hi @alisonthemonster,

Thank you for the report. This seems to be an issue with the API returning an immutable Map as you mentioned.

I will look into a fix to update this for Kotlin developers using User Storage.

Thanks,

from actions-on-google-java.

zonder129 avatar zonder129 commented on July 21, 2024

Hi!
Is there still no solution for that issue? Maybe there is a workaround, cause I can't use userStorage for Kotlin. :(

from actions-on-google-java.

Fleker avatar Fleker commented on July 21, 2024

You can create a new map for the response and clone the data from the request to the response. This would probably be the better approach, as it would keep the Request immutable.

val userStorage = mutableMapOf<String, Any>()
userStorage.putAll(aogRequest.userStorage)
userStorage.set("key", "value")
val responseBuilder = ResponseBuilder(usesDialogflow = false, userStorage = userStorage)
val aogResponse = responseBuilder.build()

from actions-on-google-java.

zonder129 avatar zonder129 commented on July 21, 2024

@Fleker looks like there is another bug - aogRequest.userStorage is always empty, but aogRequest.user?.userStorage, which is String, is implemented. I am supposed to create a Map, parse a String, and only then I may use your approach. Can I add another issue for that?

P.S. Also, I can't create ResponseBuilder manually, cause its constructor is internal. Only through getResponseBuilder(request: ActionRequest) in DialogflowApp or ActionsSdkApp, but it passes all arguments from request by itself.

from actions-on-google-java.

Fleker avatar Fleker commented on July 21, 2024

If your userStorage already exists, it should automatically parse your string from JSON to a Map.

from actions-on-google-java.

Fleker avatar Fleker commented on July 21, 2024

I was writing the code as a library test, so I must've missed the internal constructor issue.

from actions-on-google-java.

taycaldwell avatar taycaldwell commented on July 21, 2024

Hi all,

We identified that the workaround is not feasible and are working to address this issue. In the meantime, please open new issues for any other unrelated bugs.

Thanks!

from actions-on-google-java.

taycaldwell avatar taycaldwell commented on July 21, 2024

Hello,

This issue has been addressed as of v1.7.0.

If you run into any other issues, please open a new issue.

Thanks.

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.