Hi Using REST I have integrated chatbot with website.for fetching data from API I require jwt token so with each msg request I want to send it ,so How I can do this and get it into actions.py file ? I tried with adding metadata but in channel.py.please let me know what I’m doing wrong
script.js
function send(message) {
$.ajax({
url: "http://localhost:5005/webhooks/rest/webhook",
type: "POST",
contentType: "application/json",
data: JSON.stringify({ message: message, sender: user_id, metadata:{"tokn":123456} }),
success: function (botResponse, status) {
console.log("Response from Rasa: ", botResponse, "\nStatus: ", status);
actions.py
def extract_metadata_from_tracker(tracker):
events = tracker.current_state()['events']
print(events)
user_events = []
for e in events:
if e['event'] == 'user':
user_events.append(e)
return user_events[-1]['metadata']
class ActionHello(Action):
def name(self) -> Text:
return "action_hello"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
metadata = extract_metadata_from_tracker(tracker)
print("MetaData: ", metadata)
dispatcher.utter_message(text="Hello World!")
return []
credentials.yml
channel.RestInput:
channel.py
Thanks in advance