I want to connect my dialogflow chatbot to this API. so that, whenever I write "Where does Quran talk about Allah", it goes to this api and make HTTP get request to https://islam360api.herokuapp.com/Allah and returns the response.
I have turned on the "Webhook" in the intent and added the api link in as dialogflow fulfilment url. But how to teach dialogflow to concatenate the word "Allah" after or anything else user might say with each api call to https://islam360api.herokuapp.com and make HTTP get request and returns the response? Do I need to use action? What for? or Do I need to use inline editor, instead of "Webhook" under fulfillment?
EDIT
app.js
const sqlite3 = require('sqlite3').verbose();
const express = require("express");
// Notice that the execution mode is set to verbose to produce long stack traces.
var app = express();
var ayats=[];
app.get("/:find",function(request, response)
{
let db = new sqlite3.Database("./file.db",(err) => {
if (err){
console.log("Not connected to sqlite")
}
else{
console.log("Connected to sqlite")
}
});
// The sqlite3.Database() returns a Database object and opens the database connection automatically.
let sql = `SELECT SuratNameEng, AyatNo, English FROM surah`;
db.all(sql, [], (err, rows) => {
if (err) {
throw err;
}
rows.forEach((row) => {
ayats.push(JSON.stringify({Translation: row.English,SuratName: row.SuratNameEng,AyatNo: row.AyatNo}));
});
console.log(ayats);
ayats.forEach(function(element) {
if (element.toLowerCase().includes(request.params.find.toLowerCase())===true)
{
element=JSON.parse(element)
response.write(JSON.stringify({speech: "In"+ element.SuratName+", Ayat Number: "+element.AyatNo+", Quran says: "+ element.Translation, displayText: "In"+ element.SuratName+", Ayat Number: "+element.AyatNo+", Quran says: "+ element.Translation}))
}
});
response.send();
});
empty();
function empty() {
ayats.length = 0;
}
db.close((err) => {
if (err) {
return console.error(err.message);
}
console.log('Close the database connection.');
});
})
// It is a good practice to close a database connection when you are done with it.
var port = process.env.PORT || 3000;
app.listen(port,()=>console.log("Active"));
Github repository: https://github.com/ukashasohail/i360-api