Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to using Dialogflow framework within website . I know dialogflow offers the website integration as widget but.I want to use in it a custom designed floating chatbox in website.Like a chatbox which hovers in the corner of the page.How can i integrate with such chatUI
Yes, there is a way in dialogflow to do so. You will just have to create a simple chat window in html/angular or in any framework you want to design. You can just capture user-entered query & make an ajax call & pass it to dialogflow. Again that depends on the api version that you're using. Dialogflow offers you v1/v2 apis, which itself changes the request format. Please have a look at code below (used v1 api):
function captureUserQuery() {
var text = jQuery(".my-text").val();
dialogflowApi(text);
}
function dialogflowApi(text) {
jQuery.ajax({
type: "POST",
url: "https://api.dialogflow.com/v1/query?v=20170712",
contentType: "application/json; charset=utf-8",
headers: {
"Authorization": "Bearer " + access_token
},
data: JSON.stringify({
query: text,
lang: "en",
sessionId: "chatbot"
}),
success: function(response) {
console.log("success");
// Here you will get the response to your query in json, you will have to parse it based on the type it has like text, image, card etc. & show it to user.
parseResponse(response); // function to parse your response.
},
error: function() {
console.log("Error");
}
});
}
Hope this answers your query. Let me know if you have any more.
You can do so by updating the iframe tag provided by dialogflow. You can put any html page you want inside the iframe tag. Also you can add a floating button/icon to activate it:
<iframe height="430" width="350" src="https://bot.dialogflow.com/kjhdfjhfjfh">
<your custom designed floating chatbox in website html>
</iframe>
Related
I am exploring api.ai now a days for one assignment to develop chat bot. Is there a way to add hyperlinks as a part of default response? I do not want to use Google Assistant, Facebook Messanger, KIK,Slack etc but I want to include hyperlink as a part of Default Response. I explored various blogs but could not find desired answer.
Practically you can't, but there is a hack:
Choose the response to be card.
Choose a custom image.
Embed link in the "next".
No, ideally you can not add a hyperlink in default response of api.ai but there is a workaround that I used in my code. In my case, I have developed my own chat window where before printing, I'm running a check on the response that is coming from api.ai using following function & get that link converted into the clickable format.
if(!String.linkify) {
String.prototype.linkify = function() {
// http://, https://, ftp://
var urlPattern = /\b(?:https?|ftp):\/\/[a-z0-9-+&##\/%?=~_|!:,.;]*[a-z0-9-+&##\/%=~_|]/gim;
// www. sans http:// or https://
var pseudoUrlPattern = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
// Email addresses
var emailAddressPattern = /[\w.]+#[a-zA-Z_-]+?(?:\.[a-zA-Z]{2,6})+/gim;
return this
.replace(urlPattern, '<a target="_blank" href="$&">$&</a>')
.replace(pseudoUrlPattern, '$1<a target="_blank" href="http://$2">$2</a>')
.replace(emailAddressPattern, '$&');
};
}
I have a perhaps simple question. What would be the difference between an <a> tag and a normal GET request with any element. I know the <a> tag automatically sends you to the url specified in its href attribute. So I assume that a Get request does something similar in it's success callback (as demonstrated below)
But let's say that I also want to send some information along with a normal get request when a for example <span> element is clicked on so I write:
$('span').click(() => {
$.ajax({
url: '/someurl',
type: 'GET',
data: {
title: someTitle,
email: someEmail
},
success: (data) => {
window.location = '/someurl';
}
});
});
Is there any way to achieve this with an <a> tag? Sending information to the server so it's available in req.query.title and req.query.email ?
Doing the ajax request above will run my app.get('/someurl',(req,res)=>{})twice because I am sending a GET request to send the data (title and email) and then I am making another GET request when I write window.location = '/someurl' How can I redo this so that it only sends the GET request ONCE but also allows for the sending and storing information to the req object AND ensures that the browser is now displaying /someurl.
Just create the appropriate query string in the URL you put in the href of the <a> tag and it will work just like your ajax call. Suppose someTitle has the value of "The Hobbit" and someEmail has the value of foo#whatever.com, then you can construct that URL like this:
Click Me
A number of non-letter characters have to be escaped in URLs. In the above URL, the space is replaced with %20 and the # with %40. In your particular example, you could open the network tab in the chrome debugger and see the EXACT URL that Chrome was sending for your ajax call, copy that to the clipboard and insert it into your <a> tag.
Here's a table that shows what characters have to be replaced in a query string component (the part after & or after =):
I'm just wondering then, aside from semantic reasons, is there any other advantages to using an a tag instead of anything else?
<a> tags are understood by all sorts of machines that may read your page such as screen readers for the disabled or crawlers indexing your site. In addition, they work automatically with browser keyboard support, Ctrl-click to open a new tab. Whereas a piece of Javascript may not automatically support any of that functionality. So, basically, if the <a> tag can do what you need it is widely preferred because it has so much other default functionality that can be necessary or handy for users.
Hello
I am working upon the project using node.js with express.js framework and view engine set to "ejs". The project's functions is to:
1. Get an input from a user.
2. Using the input send the request to the website's API.
3. Print the certain data from that API (including the ID to be used later).
4. When user clicks on the item (that is an 'a' tag) in the list consisting of the aforementioned data - use the ID of this item to send another request to the same website to get a more detailed info about the item.
I am stuck at the step 4. And the question is: How to send this id from the .ejs file to post request in node.js when the user clicks on the item?
Doing it the other way is simple: response.render("view name", {nodeJsVar: ejsVar}); But how to pass it back?
Thanks for the help!
First of all, you cannot send any data "from the .ejs file" - what you can do is to send it from the browser, that has a rendered HTML (and possibly JavaScript) and not EJS.
You can do it with some client-side JavaScript in which case you can do whatever you want.
You can do it by embedding the variable's value in a URL as a route parameter or a query parameter if you're using standard <a href="..."> links.
You can put a hidden input in a form if you're using forms and buttons.
You can put it in any part of the request if you're using AJAX.
Just to make sure you know what is what because it can be confusing - here X is a path parameter:
http://localhost/something/X
and here X is a query parameter:
http://localhost/something?x=X
try this (assuming you use jQuery):
$.ajax({
url: '/routename_to_handle_id',
type: 'POST',
data: { id: id }
}).done(function(response){
//callback to handle if it's successful
})
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
hi i am using FLOT charts API to show data in the form of bar charts in my application. I have got requirement to show the data in bar chart and in categories with Pre Data and Post data some thing as shown in the picture like this
Sample Diagram
Please tell me how to take the data to plot the bar chart
You need a plugin for this.
Check OrderBars and then use data like:
var series = [];
series.push({
data: [], // your raw data
bars: {
order: 0
}
});
series.push({
data: [], // your raw data
bars: {
order: 1
}
});
Example: http://jsfiddle.net/ZRXP5/
My example uses Mootools, but you find the jQuery version (.js file) in the link above.
Basically what I have a List that will be maintained by the user that has a field that contains a link to an RSS feed.
I tried using the OOTB RSS and it's great, but you have to specify the feed URL and I need that to be based on user selection. For example, the user will select from a list a feed they want to view and this should take them to the feed reader page which will use their selection to get the feed URL and display this on the page.
An alternative which is not a general Sharepoint solution is to use jquery.
Is the list visible on the page or is it "just" a list in Sharepoint?
Of course you might need some kind of proxy to do this in order to call the rss-feeds if they are placed on another server. But you will send the performance to the client instead of the server which is a plus..
My solution was to use the WebPartPages Web Service (SaveWebPart) to change the definition of the web part to use the new feed URL whenever a feed is clicked on.
I created a javascript function the will accept the feed URL and proceed to the page where the feed is displayed. The new feed will not be loaded until the next time you visit the page, therefore if you are already on it you will need to reload, thus the redirect.
For more information on the format of the request and the web part XML format see the following page.
http://msdn.microsoft.com/en-us/library/ms774839%28v=office.12%29.aspx
function SetFeed(feedURL){
var webPartGUID = $("#<WebPartID>").attr('webpartid');
// This is where you set the page URL, Full Web Part XML (including path to FEED),
// storageKey (webPart GUID), and storage type (none, personal, shared)
var soapEnv = "<FULL SOAP XML>";
jQuery.ajax({
url: "http://<SITE PATH>/_vti_bin/WebPartPages.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
beforeSend: function(xhr) {
xhr.setRequestHeader("SOAPAction",
"http://microsoft.com/sharepoint/webpartpages/SaveWebPart")
},
complete: function(xData, status){
window.location='REDIRECT TO FEED PAGE';
},
contentType: "text/xml;charset='utf-8'"
});
}