Unable to access valid sample response for Service Node

(Javier Otero) #1


I’ve been working with the Service Node and have run into an issue where valid JSON sample responses are not accessible via the Context as expected. The steps I followed are (bot in offline mode serving sample data only):

Set up a Service Node with a GET request (using an OAuth v2 Authorization Profile I setup)

Add a Sample Response
This example is directly from the Microsoft Graph documentation (and service calls using Postman return in the same format). Here’s the link to the documentation article in case it’s helpful: https://docs.microsoft.com/en-us/graph/auth-v2-user


Trigger the Service Node via a task and observe

  • You can see the GetUser Service Node has completed Service Execution and is printing the sample response as expected.
  • The ParseGetUser Script Node performs the following script print(JSON.stringify(context.GetUser)); which shows the response is empty.
  • In chat, the response displays as empty:

Adjust the sample response JSON

  • If I wrap the results of the sample JSON response in a “body” object, I can then access it through context.GetUser. The problem with this is that I do not control the response from the Microsoft Graph API, so this needs to work with the sample I provided (shown above).

  • When attempting the same Service Node and task, the result shows. Based on this scenario, it looks like it searches for an enclosing key (in this case “body”) to populate the Context.

I have several questions to help me move forward.

  • Does the Service Node depend on JSON responses enclosed in a “body” object?
  • Am I missing something when setting up the Service Node that will allow me to work with the JSON variables from the service response?

Thank you in advance for your guidance and support. Please let me know if I can clarify anything in regard to this issue.

(Subrahmanyam Donepudi) #2

Hi @javier, The response received from the service used at service node will be available under context..response.body when the dialog is executed.

You could view the entire context object at any point of time by accessing the session and context tab of debug console. Please refer to the below link for more details


(Javier Otero) #3

Hi @Subrahmanyam,

Thanks for your prompt reply. I realized after submitting this that I may have misunderstood how the Request was sending real responses back, which caused some confusion on how best to create a Sample Response. To avoid this, it would be helpful if your documentation stated that adding a Sample Response needs to be nested in a “body” key.