0

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": {}
    }
  }
] 
Prisoner
  • 49,922
  • 7
  • 53
  • 105
Rajan
  • 31
  • 1
  • 4
  • Can you show the code you're using that you're having problems with? Are you using the Actions SDK or Dialogflow? – Prisoner Nov 20 '17 at 19:06
  • I am using Dialogflow @Prisoner – Rajan Nov 21 '17 at 09:23
  • I am using Dialogflow my primary expectation is in response body under which property name I want to send my session attribute like alexa @Prisoner – Rajan Nov 21 '17 at 09:29
  • I have tried with contextOut, but I did not get from next request: example: "contextOut": [ { "name": "my_session_data", "lifespan": 0, "parameters": { "myprop": "sample property", "orbitaSession": {} } } ] – Rajan Nov 21 '17 at 11:19

1 Answers1

1

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": "{}"
    }
  }
] 
Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • I have tried with lifespan: 5 buat still i did't get back my data in next response – Rajan Nov 27 '17 at 05:41
  • Can you update your question to add (1) how, exactly, you set this (2) what, exactly, you got on the next call and (3) a screen shot from the simulator illustrating the two parts of this conversation? – Prisoner Nov 27 '17 at 11:29