Connection of custom data (from botfront rasa-webchat) to rasa custom action (customs.py)

Hi i across googling the solution to pass the data from the js rasa webchat to the custom action. Some of the solution using the steps :

  1. add this code to the credential.yml
socketChannel.SocketIOInput:
  user_message_evt: user_uttered
  bot_message_evt: bot_uttered
  session_persistence: false
  1. copy paste socketChannel.py (i don’t know where to put, so i put this to the root project folder/same location with credential.yml) socketChannel.py (6.9 KB) I already add this to the socketChannel.py :

message = UserMessage( data[“message”], output_channel, sender_id, input_channel=self.name(),metadata=data[“customData”] )

  1. this is my index.html codeindex.html (1.3 KB)

my custom data file code

customData: [{“language”: “en”, “sender_email":"freddy.yonata@gmail.com”}]

i want to pass “sender_email” but when i have stories like

  • story: init-webchat steps:
    • intent: greetWebchat
    • action: action_hello_world

in the action_hello_world i try to get metadata using this function

def extract_metadata_from_tracker(tracker): events = tracker.current_state()[‘events’] user_events = for e in events: if e[‘event’] == ‘user’: user_events.append(e)

return user_events[-1]['metadata']

but it is return the metadata by blank

could someone help me?

i already try to pass the sender_email in initPayload like initPayload : ‘/greetWebchat{“sender_email”:“freddy@mail.com”}’ this give me error in terminal as internal server eerror

Hi Freddy! I’m not super familiar with Botfront (it’s not built by us) so I might recommend asking in the Botfont support group instead: Spectrum

@Freddyonata I am stuck with something similar. Any help on how did u resolve this. ??