0
votes

My question is very similar to this one Keeping data between intents from WebHook in Dialogflow answer by @prisioner But unlike the original one, I am already using context in my c# web API v2 implementation, in my context I set an attribute that store the current episode my action is playing (it is kind of media player), so the first time my action gets invoked, we randomly pick an episode to play, I added a next and previous followup intents that are using the previously set context with lifespan of 5 (just to be on the safe side)

I try to include #context.episdeId as part of my intent request parameters, but that returns a 500 error, but as soon as I remove that request parameter the request is executed, however, my context is empty in my followup intents.

this is how my response to the first intent looks like.

{
  "Payload": {
    "google": {
      "richResponse": {
        "Items": [
          {
            "simpleResponse": {
              "TextToSpeech": "Playing episode",
              "DisplayText": "Playing episode 123"
            }
          },
          {
            "mediaResponse": {
              "mediaType": "AUDIO",
              "mediaObjects": [
                {
                  "Name": "Playing episode 123",
                  "Description": "Image from Episode 123",
                  "LargeImage": {
                    "url": "https://mydomain/640x480.jpg",
                    "accessibilityText": "Image from episode 123"
                  },
                  "ContentUrl": "https://mydomain/epidode123.mp3"
                }
              ]
            }
          }
        ]
      }
    }
  },
  "OutputContexts": [
    {
      "Name": "projects/{projectId}/agent/sessions/2d2851bc-fc56-d7dc-c18a-588d42a77360/contexts/playerstarter-followup",
      "LifespanCount": 5,
      "Parameters": {
        "playerTypeOriginal": null,
        "playerType": null,
        "playerType1Original": null,
        "playerType1": null,
        "episodeIdOriginal": 761198,
        "episodeId": 761198,
        "showIdOriginal": 0,
        "showId": 378
      }
    }
  ]
}

But, in my followup (next) intent, this is what my endpoint gets, check how the same sessionId it is been used.

{
  "QueryResult": {
    "QueryText": "next",
    "Parameters": {
      "PlayerType": null,
      "PlayerType1": null,
      "ShowId": 378,
      "EpisodeId": 0
    },
    "AllRequiredParamsPresent": true,
    "Intent": {
      "Name": "projects/{projectId}/agent/intents/66f12b74-93cc-450e-9ca2-0b119c5674ea",
      "DisplayName": "player.starter - next"
    },
    "IntentDetectionConfidence": 1,
    "LanguageCode": "en",
    "OutputContexts": [
      {
        "Name": "projects/{projectId}/agent/sessions/2d2851bc-fc56-d7dc-c18a-588d42a77360/contexts/playerstarter-followup",
        "LifespanCount": 5,
        "Parameters": {
          "playerTypeOriginal": "",
          "playerType": "previous",
          "playerType1Original": "",
          "playerType1": "",
          "episodeIdOriginal": 0,
          "episodeId": 0,
          "showIdOriginal": 0,
          "showId": 378
        }
      }
    ]
  },
  "ResponseId": "8088377a-c297-49a2-bb7e-c3a60a4c2e07-68e175c7",
  "Session": "projects/testing-c58c3/agent/sessions/2d2851bc-fc56-d7dc-c18a-588d42a77360",
  "IsMinistryAction": false,
  "EpisodeId": 0
}

Thanks for the quick reply @prisoner here you can find the screenshot https://i.imgur.com/JwWFNma.png

1
Can you update your question to include a screen shot of the Intent that is triggering the second request? - Prisoner

1 Answers

0
votes

Using https://www.mockable.io as my new end point and returning a predefined response that will set the output context, I was able to see that the error was on my web API class mapping, to verify that, I read the raw request on my end point using something like this.

    //Getting the raw request
    var bodyStream = new StreamReader(HttpContext.Current.Request.InputStream);
    bodyStream.BaseStream.Seek(0, SeekOrigin.Begin);
    var rawRequest = bodyStream.ReadToEnd();

Then I just de-serialize the rawRequest object.

    var requestJobj = JsonConvert.DeserializeObject<GoogleHomeRequest>(rawRequest);

I am posting this just in case somebody else runs into the same situation.