Reputation: 31
I am developing google home supported api, here I have facing issue with session. I like to add some object values with response of conversation. example : {last_intent: 'sampleintetn'}
I want to get back this data in request while user continue that same conversion.
I'm setting the contextOut
parameter with an array of values such as
[
{
"name": "my_session_data",
"lifespan": 0,
"parameters": {
"myprop": "sample property",
"orbitaSession": {}
}
}
]
Upvotes: 0
Views: 336
Reputation: 50701
Contexts are slightly different than Alexa properties. The biggest difference that is relevant to what you're trying to do is that a Context can have a lifetime, expressed in number of user responses during the conversation.
A lifespan of 0 means to clear this Context. Sending the context again in your next response resets the lifetime counter.
Parameter values must also be strings, so you can't store another object in there. You can, however, convert that object to a string and store it, and convert it back to an object when you read it again later.
So something like this is more valid and will more likely do what you want:
[
{
"name": "my_session_data",
"lifespan": 5,
"parameters": {
"myprop": "sample property",
"orbitaSession": "{}"
}
}
]
Upvotes: 1