0

I am able to call site24x7api to fetch all the customers details (E.g user_id, name, zaaid) in terminal with the help of .js file

INPUT :

var request = require('request');

var headers = {
    'Content-Type': 'application/json;charset=UTF-8',
    'Accept': 'application/json; version=2.0',
    'Authorization': 'Zoho-authtoken xxx12sdc231xx'
};

var options = {
    url: 'https://www.site24x7.com/api/short/msp/customers',
    headers: headers
};

function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body);
    }
}

request(options, callback);

OUTPUT(In terminal) :

{
"user_id":"12345678912123",
"name":"abc",
"zaaid":"12341234"
},
{
"user_id":"98123141231233",
"name":"Xyz",
"zaaid":"43241123"
} ... and many more

Now suppose, BOT asks user for name and user enter name as

abc

The program should match the name which user enters (stored in '${session.dialogData.Companyname}' ) and the name present in the terminal and BOT should return the zaaid(int) or user_id(int) related to that particular user that is 12341234 in this case to the BOT interface

I've tried

Link 1

Link 2

Link 3

1 Answer 1

0

Use Array to loop through your json file, For Example:

var users = [{
"user_id":"12345678912123",
"name":"abc",
"zaaid":"12341234"
},
{
"user_id":"98123141231233",
"name":"Xyz",
"zaaid":"43241123"
}]

for (i=0; i<users.length; i++) {
  if (users[i].name = "the_name") {
    do_something....
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.