Hello everyone, I am using a HTTPInputComponent for serving the bot as an API similar to how it was highlighted in this github issue https://github.com/RasaHQ/rasa_core/issues/119.
The code for my class is like this
class SimpleWebBot(HttpInputComponent):
"""A simple web bot that listens on a url and responds."""
def blueprint(self, on_new_message):
custom_webhook = Blueprint('custom_webhook', __name__)
@custom_webhook.route("/status", methods=['GET'])
def health(): # pylint: disable=unused-variable
return jsonify({"status": "ok"})
@custom_webhook.route("/", methods=['POST'])
def receive(): # pylint: disable=unused-variable
payload = request.json
sender_id = payload.get("sender", None)
text = payload.get("message", None)
out = CollectingOutputChannel()
on_new_message(UserMessage(text, out, sender_id))
response = {
'messages': [m['text'] for m in out.messages],
'sender': sender_id
}
if is_goodbye_message(response['messages']):
response['status'] = 'END'
return jsonify(response)
return custom_webhook
This API endpoint is used by a web server (referred to as nlp-core from now) which forwards relevant customer queries to the bot. nlp-core stores preferences like preferred weather units (metric vs imperial) etc. which I would like to forward to rasa but I can’t find a way. One workaround would be to store the preferences in an in memory database like redis and have rasa_core actions read the preferences. But this might not work elegantly in my design as rasa_core only takes an id for a conversation, and further information may be required to get the correct preferences. Is there a way to send some data to the bot? Or set some slots manually for a conversation?