Unable to access valid sample response for Service Node

Hello!

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)
35%20AM

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

05%20AM

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.
    41%20AM
    57%20AM
  • In chat, the response displays as empty:
    15%20AM

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).
    05%20AM

  • 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.
    51%20AM

Conclusion
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.

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

https://developer.kore.ai/docs/bots/bot-builder/develop/dialog-tasks/context-object/

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.

I understand its been awhile, but since it was relevant to this thread posting it. I was trying to setup the oAuth2 Authorization Profile with connection to Azure AD. However seems to end up with an error “AzureOAuthStrategy requires a tenant id.” I am unsure where the profile is trying to read the TenantID from. Please advise.

koreai_oauth_issue2 koreai_oauth_issue1