how to find data on chatbot dialogflow from mysql using pyhon?

I’ve develop chatbot using dialogflow and python as a webhook, chatbot will show data when user input their unique code. The problem is i can’t find data depend on what user say, so far i’ve created script that chatbot can get data staticly, but i still can’t when i’m trying to make it dynamicly depend on what user say. i appreciate any help from you, here is my script

from __future__ import print_function  from urllib.parse import urlparse, urlencode from urllib.request import urlopen, Request from urllib.error import HTTPError  import json import os import dialogflow  from flask import Flask from flask import request from flask import make_response import mysql.connector from mysql.connector import Error  app = Flask(__name__)  @app.route('/static_reply', methods=['POST']) def static_reply():     mydb = mysql.connector.connect(       host="",       user="uzhug8pu84giiaza",       password="a6CGkN4luNOdm9Fmz1v",       database="buw1jkooog32vteyvtjm",       port='3306'     )      mycursor = mydb.cursor()      sql = 'SELECT nama FROM jadwalPraktikan WHERE npm="456"'      mycursor.execute(sql)      myresult = mycursor.fetchall()      for x in myresult:       speech = x        my_result =  {         "fulfillmentText": speech,         "source": speech         }        res = json.dumps(my_result, indent=4)        r = make_response(res)        r.headers['Content-Type'] = 'application/json'       return r    if __name__ == '__main__':      port = int(os.getenv('PORT', 5000))      print("Starting app on port %d" % port), port=port, host='') 
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.