I have been developing a chatbot for my android app using dialogflow and its working perfectly. But now I've a requirement to get a clickable response from my chabot. For example, let's say that the app user is asking for a specific location. I want Dialogflow chatbot to return a button or a link as the response so that the user could click on that and be redirected to the google maps.
I have went through a lot of tutorials, blogs and docs yet I've not been able to find a satisfying answer. If you could help me with a code example as well, that would be really appreciated.
Thank you in advance
If you are using Dialogflow to integrate with your own system (as opposed to something like Facebook Messenger, Actions on Google, or other bot platforms) using the Detect Intent API, then you can include any data you want in the payload object of your webhook response. This is passed back to you in the response to your Detect Intent call in the response body in the queryResult.webhookPayload object.
You can include in here any information you wish, and render it however you'd like.
Inside the Intent section in Dialogflow, click on "Google Assistant" in Responses.
Select "Link Out Suggestion" which is used for giving a clickable link.
In case if you just want the button without link then you can use "Suggestion Chips".
On the UI code you will need to parse it and render it as clickable button.
See screenshots below from dialogflow:
For more details, refer to https://www.kommunicate.io/blog/rich-message-button-response-dialogflow-chatbot/
You may have to use Google Maps URLs for this purpose. These provide a Universal Cross-platform solution.
Follow these steps:
Based on user Responses, encode a Map URL as shown in examples here https://developers.google.com/maps/documentation/urls/guide
For example, consider the URL from the guide above
https://www.google.com/maps/search/?api=1&query=47.5951518,-122.3316393&query_place_id=ChIJKxjxuaNqkFQR3CK6O1HNNqY
Then use
Buttons in Basic Card as follows
app.intent('demo', (conv, params) => {
// Create a basic card with the URL
conv.ask(new BasicCard({
text: `This is a basic card with Map Response.`,
subtitle: 'This is a subtitle',
title: 'Title: Open Map',
buttons: new Button({
title: 'Open Map as per URL',
url: 'https://www.google.com/maps/search/?api=1&query=47.5951518,-122.3316393&query_place_id=ChIJKxjxuaNqkFQR3CK6O1HNNqY',
})
}));
}
You can also use other Responses (such as linkOutSuggestion ) as described here:
https://developers.google.com/actions/assistant/responses
Hope that helps!
Related
We have a social media kind of app where you can post content like messages, links, images etc. We would like to track when a link is pressed in the app, and which urls are opened through the app. The urls are detected in the textviews with the autolink "web" property. Is this possible to achieve with google/firebase analytics or similar?
although your question may not meet community standards.
I will try to answer, from my understanding ...
I believe that you are looking for URL tracking, this practice can be applied to applications and websites.
The most common method used today is:
Bit.ly
This tool, in addition to URL shortening. It can serve as an effective means of tracking and measuring.
but this tool also has its limitations. You have to study.
Google Analytics
With this tool you can create and use the Google Analytics tag.
So, follow this event.
It is understood that any url can be tracked with the created tag.
This practice becomes one of the most complex in metrics.
If you need to deepen your question further, be sure to comment.
Capture outbound links
Find out when users click a link to leave your site.
Note: This article applies only to sites tagged with the analytics.js snippet. (It does not apply to sites tagged with gtag.js.)
You can use Analytics Events to capture clicks on links that take users to a website other than your own.
Google Tag Manager
If you use Google Tag Manager to manage your Analytics installation, follow the instructions in Analytics Events to implement events.
Add the tag directly to your site
If you have added the Analytics tag directly to your site, you can copy and paste the script below into your own pages to set up Event measurement for outbound links. You should add this script in your page header, but not within the basic Analytics tag.
If you copy and paste this script exactly as it appears here, your outbound clicks will appear in your Analytics Events reports with a Category of "outbound" and an Action of "click". (In the snippet, these are shown in bold.) You can use these values, or change them and define your own values. Learn more about Event components.
This example assumes that you are using the analytics.js tag. See if you are using Classic Analytics (ga.js) or Universal Analytics (analytics.js).
<script>
/**
* Function that captures a click on an outbound link in Analytics.
* This function takes a valid URL string as an argument, and uses that URL string
* as the event label. Setting the transport method to 'beacon' lets the hit be sent
* using 'navigator.sendBeacon' in browser that support it.
*/
var captureOutboundLink = function(url) {
ga('send', 'event', 'outbound', 'click', url, {
'transport': 'beacon',
'hitCallback': function(){document.location = url;}
});
}
</script>
You'll also need to add (or modify) the onclick attribute to your links. Use this example as a model for your own links:
Check out example.com
I have to implement Invite and Earn functionality in my Android application.
What I have to do is : User can share the link to anyone on social media,
On receiving the link, another user can click the link to get the application installed using that link.
After the user installs the app using that link, the sender or the invitee can be rewarded. How this can be possible ?
So far, I go through the Firebase's Dynamic Link concepts and found some demo. But, still confused in it.
Can you please guide me what another stuffs I have to gone through to achieve such thing ?
Is it possible in react-native. If not then How can I achieve that in Android ?
Thanks
You can Integrate Refer & earn in your react native application using react-native-branch
Just following the documentation of integrating branch.io in your react-native application and you will be good to go.
Documentation for react-native-branch
Here is also a github example for your reference Example
Since you have already gone through firebase, therefore it would be easy for you to use the procedure based on the same.
Here's the roadmap for getting started
Set Up
Follow the Initial Setup Guide to configure adding the project to Firebase
Configure the android/app/build.gradle and MainApplication.java to add the firebase dynamic links
Configure the Firebase invites package
If you haven't configured deep link , take a look at this tutorial
Usage
SendInvitation Component
import firebase from 'react-native-firebase';
const title = 'Demo Firebase Invites'
const message = 'You have been invite to join the xxxxx app'
const invitation = new firebase.invites.Invitation(title, message);
invitation.setDeepLink(// Your App's Configured deep link)
invitation.setCustomImage(// Image Uri)
invitation.setCallToActionText(// Set the text on the invitation button on the email)
// ... On some button click
sendInvitation = async () => {
const invitationIds = await firebase.invites().sendInvitation(invitation)
// Invitation Id's can be used to track additional analytics as you see fit.
}
Handle Receive Invitation
Either use getInitialInvitation method or listen for invitations using the onInvitation listener.
At the root of your app you can add
import firebase from 'react-native-firebase';
firebase.invites()
.getInitialInvitation()
.then((invitation) => {
if (invitation) {
// app opened from an Invitation
// Set the rewards points here and update data in your firebase
} else {
// app NOT opened from an invitation
// No rewards for this user
}
});
The invitation contains the following objects which will help you with the queries on updating the sender reward points.
deepLink: string
invitationId: string
You can route to specific page using the deep link, and also get custom data passed from the invitee such as a random userId to create the user on the firebase.
Use invitationId to query other stuff.
For implementing this feature developers need to learn App links. And For implementing this you can use react-native-deep-linking.
I am giving you a little overview, You need to add some XML in the manifest file for android according to your needs and you will handle it using linking.
I have searched SO and the web for a similar issue, and while others appear to have encountered this problem, their solutions are not working for me.
DFL parameter in Firebase Dynamic Links Builder
Starting with Android, I'm attempting to implement the Dynamic Links for my app. The app requires additional parameters on the dynamic link, so I'm manually constructing the link based on the information here: https://firebase.google.com/docs/dynamic-links/create-manually.
I have created my link in the following manner (code abbreviated for purposes of this post)
Uri.Builder builder = new Uri.Builder()
.scheme("https")
.authority(AppPrivate.Invitation.APP_CODE + ".app.goo.gl")
.path("/")
.appendQueryParameter("link", link)
.appendQueryParameter("apn", AppPrivate.PACKAGE)
.appendQueryParameter("dfl", desktopLink);
For my use case the link and desktopLink parameters are the same - they are actual working URLs on my website. Regardless of what device the user hits with the dynamic link, it should perform the desired action. Again, for purposes of simply getting this working, I've linked to our primary website (https://www.mytravelerapp.com).
When I send the invitation from my Android device, I generate an intent based on the code sample here: https://github.com/firebase/quickstart-android/blob/master/invites/app/src/main/java/com/google/firebase/quickstart/invites/MainActivity.java
return new AppInviteInvitation.IntentBuilder(context.getString(R.string.content_trip_invitation_title))
.setMessage(message)
.setDeepLink(uri)
.setCustomImage(Uri.parse(AppPrivate.Invitation.TRIP_INVITE_DEEP_LINK_IMAGE))
.setCallToActionText(context.getString(R.string.content_trip_invitation_cta))
.build();
However, when I receive the invitation via email on my desktop, it always goes to the Play Store listing, no matter what I've added to the initial deep link (DFL, AFL). Here's a sample of the link from the "call to action" button from the email:
https://a3d4u.app.goo.gl/i/225742434763-3bd2c2fa-45f0-4ed8-aca3-37760d27d971
I've not yet implemented the receivers in the android app to listen for incoming links, so I cannot confirm whether or not the deep link behaves appropriately on that platform.
Any recommendations or suggestions on what I'm missing with the desktop link are greatly appreciated.
Thanks!
You're actually wrapping a dynamic link in another dynamic link. Invites itself generates a dynamic link, which doesn't have your DFL parameter, so it is redirecting to the store.
You could try shortening the dynamic link you generate, and sharing via the regular share dialog rather than using Invites.
Is it possible to have a share on Facebook link on a website that opens the share dialog in the native App?
Current behavior:
Right now clicking the Facebook share link opens the web-based share dialog, which is bad since most mobile Facebook user are using the native app, thus are not logged in on their browsers. Consequently the web share dialog prompts them to input their user credentials - which might lead them to not share after all.
Ideal behavior:
Clicking the share on Facebook link leads to the share dialog in the native Facebook app, where the user is already signed in.
Thanks in advance for the help!
As of now, there is no official way to achieve this. It could be implemented by Facebook though, forwarding their web share dialog using their custom URL scheme. So if you use the officially documented way to open this dialog you would get this functionality with no further changes as soon as it becomes available.
The easiest way to use the official web share dialog, without any prerequisites, is to link to this URL:
https://www.facebook.com/dialog/share?
app_id=145634995501895
&display=popup
&href=URL_TO_SHARE
&redirect_uri=RETURN_URL
where you replace URL_TO_SHARE and RETURN_URL with the proper URL-encoded values. Or you include the Facebook JS-SDK and use the classical share button or other ways described in sharing on the web.
Just for completeness: In native apps on iOS and Android it is possible to link to the Facebook app directly if the user has the Facebook app installed. See sharing from iOS or android. As this is not always the case you have to check using the respective platform's specific Facebook SDK and fallback to the web-based dialog as well.
On a sidenote: I would highly discourage you from using the not officially documented URL-schemes registered by the Facebook app. While they might work if the website is visited from a device with an installed Facebook app, they become dead links or weird browser warnings on devices without the Facebook app installed, especially any PCs or Macs. Even if you check for all these cases, Facebook has already changed their URL-Schemes and might do so again at any time, breaking your link(s) or - maybe worse - leading to undefined behavior.
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share
You could try this and let the user decide what native app to use when sharing your link.
It opens the native share-via of the user's device
const data = {
title: document.title,
text: 'Hello World',
url: 'https://your_site_url',
}
const shareVia = window.navigator.share(data);
<html>
<button onClick={shareVia}>Share Me!</button>
</html>
The following code will check if the app is installed, if installed you can share using the app, you don't have to open Facebook in your web browser and log in again. If the app is not installed it will simply use the Facebook sharer link then the user has to log in to Facebook in the browser if not logged in and the link gets shared.
onShare() {
console.log(order);
const title = 'Title';
const url = 'https://www.facebook.com/';
const text = "Share on native app if installed";
if (navigator.share) {
navigator
.share({ title: `${title}`, url: `${url}`,text: `${text}`})
.then(() => {
console.log('Thanks for sharing!');
})
.catch(console.error);
} else {
window.location.replace(
`https://www.facebook.com/sharer.php?u=${url.trim()}"e=${text}`
);
}
} //onShare ends here
<a href="fb://page/100623981381289">
This is My page (click on your Phone installed facebook)
</a>
I know it has been a couple of years, but for whom it may concern:
Have a look at this answer; Xcode : sharing content via Action Sheet.
Let me copy that answer overhere as well:
Swift
let shareText = "Hello, world!"
if let image = UIImage(named: "myImage") {
let vc = UIActivityViewController(activityItems: [shareText, image], applicationActivities: [])
presentViewController(vc, animated: true, completion: nil)
}
Try links for tutorials
http://nshipster.com/uiactivityviewcontroller/
http://www.codingexplorer.com/add-sharing-to-your-app-via-uiactivityviewcontroller/
http://roadfiresoftware.com/2014/02/how-to-add-facebook-and-twitter-sharing-to-an-ios-app/
I am creating a mobile app which connects to some jive based community using childbrowser.
I can easily open the community, login and do stuff.
But I also need to fetch session details in my app, so that I could use these to fetch JSON strings to show user image/info on my app showing that user is logged in.
I tried working on childbrowser, but couldn't investigate much.
It seems it won't work with my community URL. While using google url it shows popups on location changes, but not for my url.
Can any one help me in fetching the data I want ?
Here is the sample code I am using to detect location change:
function openURL() {
window.plugins.childBrowser.onLocationChange= function(loc){
alert('In index.html new loc = ' + loc);
};
window.plugins.childBrowser.showWebPage("https://communityName.jive-mobile.com/#jive-login", { showLocationBar: false });
}
I am getting my login page, but after login I can't see any alert coming !!
I need to get proof of user login and user session details.
Thanks
I have just updated the ChildBrowser plugin for my own use, following code given here: How do I get the web page contents from a WebView?
I am using this to log in on Google API oAuth2, watching for the right page to load. I am using the onPageLoaded(html) event that has the (computed) html source. You might want to use this to get the html that was loaded and check for "stuff". I don't use jive so I wouldn't know where to start, but I'll put up a sample Google oAuth2 project for you to try.
HTH
EDIT:
the code is at: https://code.google.com/p/filechunkreader/
Don't let yourself get fooled by the name, this project is the repo for my Java plugins experiments. It contains so far 2 plugins, FileChunkReader and a custom version of ChildBrowser.