Support Center

Find your answer in our knowledge base

JSON API REQUEST PARAMETERS

Following are the parameter which will be sent to JSON API. {user_id} {first_name} {last_name} {gender} {timezone} {fbId} {last_user_msg} {bot_id} You can access these parameters based on your Request Method i.e, GET or POST. Example Code(PHP):
// GET REQUEST

<?php
   $user_id = $_GET[‘{user_id}’];
?>
// POST REQUEST

<?php
   $json = file_get_contents('php://input');
   $json = json_decode($json,true);
   $first_name = $json['{first_name}'];
   $message = "Hi, ".$first_name.". How are you?";
   echo json_encode(['text'=>$message]);
?>
DataStore/User Attributes Values: If you have used DataStore or User Attributes in your story, For example, you have created an DataStore of “color” and user says “I like red color”. The Parameter Key will be “color” and the value will be in array form:
<?php
   $json = file_get_contents('php://input');
   $json = json_decode($json,true);
   $color= $json['{color}'];
   $message = $color." is a beautiful color.";
   echo json_encode(['text'=>$message]);
?>