How to use "Custom" body type in Service Node

(Karthik N) #1

Hi Team,

I have two questions here, both are relate to “Service Node” request body.

  1. Please help me out on how to use the “Custom” body type .

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


(swathi vadlamani) #2

@karthik.nagulapally The values of data type number or date can be passed by selecting application/json type at request . And custom type helps developers to send the request payload in a format other than JSON say XML for instance. date and numbers can be passed in the payload for request payload type as application/json. Refer for more details.

Having said that, please provide us with the CURL so that we could look into your issue further and get back.


(Karthik N) #3

@swathi.vadlamani, thank you for the reply.

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.

Does the above param will be converted to Number during the API request ? Please look into this, and let me know your comments.


(Subrahmanyam Donepudi) #4

Hi @karthik.nagulapally,
Please follow the below steps to pass the data to the endpoint:

  1. Select the type of request data being sent as “Custom”
  2. Mention the values at keys which are stored in the context.entities.entityname without the quotes as shown in above snip.
  3. Now provide a value at the entity for testing and click test
  4. Below snip show the request body which is passed to the end point

Do let us know if you are still facing the issue and we could debug further.


(Karthik N) #5

Hi @Subrahmanyam, thank you for the detailed information.

I have followed the mentioned steps, and here is my observation,


  1. Tried by providing content-type as application/json and body as Custom
  2. Executed the API as expected.
  3. Moved out of service node and came back again
  4. Observed “Custom” changed to “application/json” and showing error in the payload

Scenario-2: (Just tried, not recommended)

  1. Tried by not providing the content-type, but body as Custom
  2. 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.


(Karthik N) #6

Hi @Subrahmanyam @swathi.vadlamani,

Script node is really worked for preparing the request body. Though bot builder showing error it is executing the API request and working as expected.


(Subrahmanyam Donepudi) #7

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.

(swathi vadlamani) #8

Glad, we could help you @karthik.nagulapally!

(shobhit singh) #9

Hi @Subrahmanyam,
Thanks for your detailed steps.
By following your steps , I was able to make API call, and getting following response.

“statusCode”: 200,
“body”: “<result>Incident Created Successfully</result>”,
“headers”: {
“date”: “Wed, 30 Jan 2019 09:40:38 GMT”,
“x-powered-by”: “Servlet/3.0”,
“connection”: “close”,
“transfer-encoding”: “chunked”,
“content-type”: “text/plain”,
“content-language”: “en-US”


Service node CallINCService is default connected to message node.

Further I need to provide message to user for Body response.
I am providing following message response, But it is not working ,

Print(“This is your ticket information: +context.CallINCService.response.body.result”)

Could you please guide here. If anything wrong.

Thanks in advance.

(Subrahmanyam Donepudi) #10

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

(shobhit singh) #11

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.

Thanks in advance.

(Subrahmanyam Donepudi) #12

Hi @shobhit1.singh, I have verified the issue from my side by storing the below data into context.result at a script node:


Then, at the message node, I am using the adv editor to print the below:
print("This is your ticket information: " + context.result.response.body);


Below is the snapshot showing that message is resolving fine during run time.