Custom Output payload not uttered by bot on server

I am trying to read bot utterances on my JS server and display it on my web app. However, the custom json file is not returned on the server, is there any way I could access it in my JS code?

Running server.js [ 'b0bac919c443411981683f2c8b5b5f79',
  '871',
  '301',
  'true',
  '--port',
  '5069',
  'http://127.0.0.1:5000' ]
2019-09-27 10:39:24 INFO     engineio.server  - 86c6bf59bae3445daf4725be1e42eeaf: Sending packet OPEN data {'sid': '86c6bf59bae3445daf4725be1e42eeaf', 'upgrades': ['websocket'], 'pingTimeout': 60000, 'pingInterval': 25000}
2019-09-27 10:39:24 INFO     engineio.server  - 86c6bf59bae3445daf4725be1e42eeaf: Sending packet MESSAGE data 0
Send to Rasa =========> 
2019-09-27 10:39:24 INFO     engineio.server  - 86c6bf59bae3445daf4725be1e42eeaf: Received request to upgrade to websocket
2019-09-27 10:39:24 INFO     engineio.server  - 86c6bf59bae3445daf4725be1e42eeaf: Received packet MESSAGE data 2["session_request",{"session_id":"a9dc46a216ffbe69ed315ab1bc8751ff32f531d78627cd929d84a4408f51fdb0"}]
2019-09-27 10:39:24 INFO     socketio.server  - received event "session_request" from 86c6bf59bae3445daf4725be1e42eeaf [/]
2019-09-27 10:39:24 INFO     socketio.server  - emitting event "session_confirm" to 86c6bf59bae3445daf4725be1e42eeaf [/]
2019-09-27 10:39:24 INFO     engineio.server  - 86c6bf59bae3445daf4725be1e42eeaf: Sending packet MESSAGE data 2["session_confirm","a9dc46a216ffbe69ed315ab1bc8751ff32f531d78627cd929d84a4408f51fdb0"]
2019-09-27 10:39:24 INFO     engineio.server  - 86c6bf59bae3445daf4725be1e42eeaf: Upgrade to websocket successful
Send to Rasa =========> 
2019-09-27 10:39:24 INFO     engineio.server  - 86c6bf59bae3445daf4725be1e42eeaf: Received packet MESSAGE data 2["user_uttered",{"message":"start conversation","session_id":"a9dc46a216ffbe69ed315ab1bc8751ff32f531d78627cd929d84a4408f51fdb0"}]
2019-09-27 10:39:24 INFO     socketio.server  - received event "user_uttered" from 86c6bf59bae3445daf4725be1e42eeaf [/]
Send to Rails =========> 
2019-09-27 10:39:24 INFO     socketio.server  - emitting event "bot_uttered" to 86c6bf59bae3445daf4725be1e42eeaf [/]
2019-09-27 10:39:24 INFO     engineio.server  - 86c6bf59bae3445daf4725be1e42eeaf: Sending packet MESSAGE data 2["bot_uttered",{"text":"Welcome to Shayan!"}]
2019-09-27 10:39:24 INFO     socketio.server  - emitting event "bot_uttered" to 86c6bf59bae3445daf4725be1e42eeaf [/]
2019-09-27 10:39:24 INFO     engineio.server  - 86c6bf59bae3445daf4725be1e42eeaf: Sending packet MESSAGE data 2["bot_uttered",{"text":"How are you?"}]
{ text: 'Welcome to Shayan!' }
{ text: 'How are you?' }
Send to Rails =========> 
Send to Rails =========> 
Send to Rasa =========> 
2019-09-27 10:39:33 INFO     engineio.server  - 86c6bf59bae3445daf4725be1e42eeaf: Received packet MESSAGE data 2["user_uttered",{"message":"Good","sender_id":217,"session_id":"a9dc46a216ffbe69ed315ab1bc8751ff32f531d78627cd929d84a4408f51fdb0"}]
2019-09-27 10:39:33 INFO     socketio.server  - received event "user_uttered" from 86c6bf59bae3445daf4725be1e42eeaf [/]
2019-09-27 10:39:33 INFO     socketio.server  - emitting event "bot_uttered" to 86c6bf59bae3445daf4725be1e42eeaf [/]
2019-09-27 10:39:33 INFO     engineio.server  - 86c6bf59bae3445daf4725be1e42eeaf: Sending packet MESSAGE data 2["bot_uttered",{"text":"Is there anything you need?"}]
{ text: 'Is there anything you need?' }
Send to Rails =========> 
Send to Rasa =========> 
2019-09-27 10:39:36 INFO     engineio.server  - 86c6bf59bae3445daf4725be1e42eeaf: Received packet MESSAGE data 2["user_uttered",{"message":"Yes","sender_id":217,"session_id":"a9dc46a216ffbe69ed315ab1bc8751ff32f531d78627cd929d84a4408f51fdb0"}]
2019-09-27 10:39:36 INFO     socketio.server  - received event "user_uttered" from 86c6bf59bae3445daf4725be1e42eeaf [/]
2019-09-27 10:39:36 INFO     socketio.server  - emitting event "bot_uttered" to 86c6bf59bae3445daf4725be1e42eeaf [/]
2019-09-27 10:39:36 INFO     engineio.server  - 86c6bf59bae3445daf4725be1e42eeaf: Sending packet MESSAGE data 2["bot_uttered",null]
null
/home/shayan/botengine/server.js:95
  let message = parseIfJSON(data.text)

The following is the conversation in the rasa shell that works perfectly:

Your input ->  start conversation                                                                                                                                                        
Welcome to Shayan!
How are you?
Your input ->  Good                                                                                                                                                                      
Is there anything you need?
Your input ->  Yes                                                                                                                                                                       
Custom json:
{
  "input_type": "Name",
  "text": "What is your name?"
}
Your input ->  Shayan                                                                                                                                                                    
Custom json:
{
  "input_type": "Phone",
  "text": "Great! I need your phone number for verification."
}
Your input ->  9999978541        

I want to be able to access this custom JSON in my JS code just like I am able to access the other utterances like ‘text:’

What input channel are you using? If you have a custom server you’ll likely have to write a custom input/output channel to send that information out to your JS code.

After going through the rasa code I figured out why the custom JSON payload is not working.

Following is the signature for the emit function in socketio that expects a keyword ‘data’ - None of this mentioned in the documentation so I had to do my own debugging by reading the rasa files and figured out adding ‘data:’ keyword helped emit the message. My understanding is that custom output payloads are entirely channel-specific, and the whole idea is that you want to be able to take a full json payload that you could send to the server not through Rasa and send it to the output channel.

Anyway, I got it working for now. Thank you for your reply.