0

Api.ai request body does not contain the originalRequest object from which the access_token can be sent to the fulfillment webhook. Can anybody please let me know why I am not seeing the originalRequest body?

I have successfully completed the Account Linking for my app and in fact, the actions web simulator does show the expected access_token in the debug window but the Api.ai json request body does not have it.

I am using python for fulfillment logic. Any help on this is greatly appreciated.

It would be very helpful, if there is some documentation or sample app (in python specifically) around how to grab the access_token from the api.ai json request so that it can be used in the webhook fulfillment logic. In my specific case, I need to do the below:

  1. Grab the access_token from the api.ai request (which upon reading through a bunch of articles/docs, it seems like it will only be seen in originalRequest json object which I am not seeing in my request at all)
  2. Use the access_token in the bearer header of my API calls

FYI, I am testing this on actions web simulator and the debug window in web simulator shows the access token which tells me that account linking is successful. I only need to know how to get that access_token from the api.ai request.

Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • Can you show the JSON that you think you're getting? – Prisoner Jul 19 '17 at 01:36
  • In the api ai console, when I click on Show JSON button it gives me the json request but I realized yesterday that it is the JSON of the response coming back from webhook may be? I dont know how to get the request JSON. – Sandeep Anjaneya Jul 19 '17 at 14:06

1 Answers1

1

The easiest way to see the contents of the JSON that your webhook is getting is to print or log it in the webhook itself. This should come in as the body in the request object.

Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • Great. That is exactly what I did and I do see the userid object being passed to the webhook. Thanks so much for the tip. I just didn't think that I could do that too :) You saved me a lot of trouble. – Sandeep Anjaneya Jul 19 '17 at 17:16
  • Glad you got the info you needed! If the answer helped, please accept it and/or vote it up. Even better would be if you edited the answer to provide details about how you printed/logged it so others can learn from it. – Prisoner Jul 19 '17 at 19:06