I have two questions here, both are relate to “Service Node” request body.
Please help me out on how to use the “Custom” body type .
JSON (application/json - content type) object is accepting only string variable not number or date variables it seems in, please correct me if I am wrong here.
Here is my observation, I have an API which is accepting amount as number and If I pass it as part of JSON, it is considering as String not as Number. May I know where I can see the actual API request that is making by Kore.AI(I could not see the complete request from the Kore Debugger).
Here is what I have found from the browser console,
"{“context”:{“entities”:{“OpportunityName”:“Opp Kore 2”,“SelectedAccount”:“accounts(9248bda7-d435-e311-8795-78e7d1620f53)”,“Amount”:“20000”,“OpportunityCloseDate”:“2018-11-09”},“accountidtouse”:“su-2d878281-28df-5ad0”}} "
Look at the “Amount”, which is a Number entity but it sent as a String from Kore.
Please find the attached Service Node Body that I have configured.
"budgetamount":"{{context.entities.Amount}}"
Does the above param will be converted to Number during the API request ? Please look into this, and let me know your comments.
Hi @Subrahmanyam, thank you for the detailed information.
I have followed the mentioned steps, and here is my observation,
Scenario-1:
Tried by providing content-type as application/json and body as Custom
Executed the API as expected.
Moved out of service node and came back again
Observed “Custom” changed to “application/json” and showing error in the payload
Scenario-2: (Just tried, not recommended)
Tried by not providing the content-type, but body as Custom
Error thrown by Kore regarding Content-Type.
But there is one more scenario I want to try with is, use Script node to prepare payload, save it in context variable and use the variable as payload for content type “application/json”. I have yet to try it, I’ll let you know the update.
Thanks @karthik.nagulapally. While we look into the observations you have with the request type on bot builder, we are happy your issue is resolved and you are able to execute the API fine during run time.
@shobhit1.singh, I see the data under body of service node coming as text with some xml tags in it. You could possibly create a JS node to create a context variable and store the extracted value “Incident Created Successfully” from the body of the service node by trimming off the rest of the data. Further you would be able to use this variable to print the message at the message node.
Thanks @Subrahmanyam. I have created script node to fetch the body response from service node.
and passing below script in Add script window.
(Sample response I already attached in my previous post)
Further checked on this from my side,
I am able to print the jsonstringobj in message node successfully with below script.
var jsonstringobj = JSON.stringify(context.CallINCService);
print(“This is your ticket information” +jsonstringobj);
and this is the output from BOT for message node:
{“response”:{“statusCode”:200,“body”:“Incident Created Successfully”,“headers”:{“date”:“Thu, 07 Feb 2019 12:38:05 GMT”,“x-powered-by”:“Servlet/3.0”,“connection”:“close”,“transfer-encoding”:“chunked”,“content-type”:“text/plain”,“content-language”:“en-US”}}}
But when I am trying to print the body response with below script, it is failing with following error
print(“This is your ticket information” +jsonstringobj.response.body);
Why it is saying, "can not property response and body and undefined.
Please help me on this. We are following on this since last 3-4 days.
Hi @m.satish512, Could you please use a script node at the dialog to apply logic, store the result onto a context variable and then send it directly from the payload being sent at service node?