def main(): logger.error('Request: %r', request.json) response = { 'version': request.json['version'], 'session': request.json['session'], } json_body = request.json user_id = json_body['session']['user_id'] session_obj = session.get(user_id) dm_obj = dm.DialogManager(session_obj) message = json_body['request']['command'].strip() if not message: message = json_body['request']['original_utterance'] dmresponse = dm_obj.handle_message(message) response['response'] = { 'text': dmresponse.text, 'end_session': dmresponse.end_session, } if dmresponse.tts is not None: response['response']['tts'] = dmresponse.tts logger.error('Response: %r', response) return json.dumps(response)
def say(message): return dm.DialogManager(session_obj).handle_message(message).text
def bot_handler(bot, update): session_obj = session.get(update.message.chat_id) dm_obj = dm.DialogManager(session_obj) dmresponse = dm_obj.handle_message(update.message.text) bot.send_message(chat_id=update.message.chat_id, text=dmresponse.text)