-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBotCode.txt
64 lines (51 loc) · 2.95 KB
/
BotCode.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<script> var div = document.createElement('div'); div.className = 'fb-customerchat'; div.setAttribute('page_id', '299247230998305'); div.setAttribute('ref', ''); document.body.appendChild(div); window.fbMessengerPlugins = window.fbMessengerPlugins || { init: function () { FB.init({ appId : '1678638095724206', autoLogAppEvents : true, xfbml : true, version : 'v3.0' }); }, callable: [] }; window.fbAsyncInit = window.fbAsyncInit || function () { window.fbMessengerPlugins.callable.forEach(function (item) { item(); }); window.fbMessengerPlugins.init(); }; setTimeout(function () { (function (d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) { return; } js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk/xfbml.customerchat.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); }, 0);</script>
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const requestPermission = (app) => {
app.askForPermission('To locate you', app.SupportedPermissions.DEVICE_PRECISE_LOCATION);
};
const userInfo = (app) => {
if (app.isPermissionGranted()) {
const address = app.getDeviceLocation().address;
if (address) {
console.log(`You are at ${address}`);
}
else {
// Note: Currently, precise locaton only returns lat/lng coordinates on phones and lat/lng coordinates
// and a geocoded address on voice-activated speakers.
// Coarse location only works on voice-activated speakers.
console.log('Sorry, I could not figure out where you are.');
}
} else {
console.log('Sorry, I could not figure out where you are.');
}
};
const app = new DialogflowApp({request, response});
const actions = new Map();
actions.set('location', requestPermission);
actions.set('user_info', userInfo);
app.handleRequest(actions);
});
<!-- Load Facebook SDK for JavaScript -->
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
xfbml : true,
version : 'v3.3'
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = 'https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<!-- Your customer chat code -->
<div class="fb-customerchat"
attribution=setup_tool
page_id="299247230998305"
theme_color="#0084ff"
logged_in_greeting="Hello Welcome to DrSaab!"
logged_out_greeting="Hello Welcome to DrSaab!">
</div>