I want to use Facebook Messenger Extensions (opening a Webview) with Microsoft Edge.
My app sends a request to the REST API endpoint messages. The payload is as follows. Documentation on this.
{
"messaging_type":"RESPONSE",
"recipient":{
"id":"<id>"
},
"message":{
"attachment":{
"type":"template",
"payload":{
"template_type":"button",
"text":"Test text",
"buttons":[
{
"type":"web_url",
"url":"https://c0292fc0.ngrok.io/facebook/render_multi_choice?data=24561",
"title":"Test Button",
"webview_height_ratio":"full",
"messenger_extensions":"true",
"fallback_url":"https://c0292fc0.ngrok.io/facebook/render_multi_choice?data=24561"
}
]
}
}
}
}
When the user taps the button "Test Button" in Messenger, a Webview pops up and displays the response at the fallback URL / URL : https://c0292fc0.ngrok.io/facebook/render_multi_choice?data=24561
Note the URL contains one parameter, data = 24561
My Python Flask App receives the request:
#application.route("/facebook/render_multi_choice", methods=["GET"])
def render_multi_choice():
args = request.args
print(args)
return "OK"
The issue is that one would expect args to be printed out as:
ImmutableMultiDict([('data', 24561), ('fb_iframe_origin', '')])
Yet, it is printed out as:
ImmutableMultiDict([('data', ''), ('fb_iframe_origin', '')])
My flow works fine in Google Chrome, but NOT on Microsoft Edge. Do you have any idea what the issue could be? If I open the URL directly in the browser (without the Webview), things work as expected on Edge.
Related
I am running an influxDb, on my server, and I created below:
Notification Check
Notification Endpoint (HTTP POST)
Notification Rule
All above are running successfuly
I have also created a webhook connector to Microsoft teams in order for InfluxDb send the notification alert to it.
However, for the Microsoft Teams webhook to work successfully, needs a key called "summary" inside request body of the POST request.
InfluxDb has no key called summary in their request body. Something like this:
{
"summary":"text"
}
I am looking to find out how to alter the request body InfluxDb sends, however there is nothing on their documentation.
Any ideas ?
The incoming webhooks send messages as a card. So, the title and summary fields are mandatory. It is by design.
This might be late but I've created my own team connection task in influxdb, where I can add mentions and buttons.
Basic Example:
Copy teams into a task in influxdb and add this next code at the end.
This Example adds a mention for Tom Cruise with its respective teams ID ( use Graph Explorer to get the correct IDs). It's possible to add multiple mentions as follow:
mentions = addMention(name : "James Bond",id:"007") + addMention(name : "Tom Cruise",id:"123456")
Adding Button / Buttons
button = addButton(type: "Action.OpenUrl", title: "Go To Google.com", url:"google.com" )
button2 = addButton(type: "Action.OpenUrl", title: "Go To Mohameds GITHUB", url:"https://github.com/Mohamedkrs" )
url= "https://..."
endpoint1 = endpoint(url: url)
mentions = addMention(name : "James Bond",id:"007")
button = addButton(type: "Action.OpenUrl", title: "Go To Google.com", url:"google.com" )
button2 = addButton(type: "Action.OpenUrl", title: "Go To Mohameds GITHUB", url:"https://github.com/Mohamedkrs" )
crit_statuses =from(bucket: "bucket")
|> range(start: -15s)
|> filter(fn: (r) => r["_measurement"] == "win_cpu")
|> endpoint1(mapFn: (r) => ({
title: "Memory Usage",
text: "<at>team user name</at>: ${r.host}: Process uses ${r._value} GB",
summary: "Alert",
mention: mentions,
button : button + button1
}),
)()
I want to create a rich response to Facebook integration using Dialogflow fulfillment. I tried using webhook but it's not working and then I try below way directly using response and now I am facing this context binding issue.
I tried below
let responseJson = {};
let rich = [
{
'text': {
'text': [
text
],
},
'platform': 'FACEBOOK'
},
];
responseJson.fulfillmentMessages = rich;
responseJson.outputContexts = context;
response.json(responseJson);
my context JSON
{ name: 'MAINTENANCE_REQUEST', lifespan: 5, parameters: { maintenanceRequest: maintenanceRequest }}
To add a custom payload without a webhook, go to your intent, and scroll to the bottom where it says "responses". Click on the plus sign (picture) and click on the facebook option. Click on the add responses -> custom payload. The format and available fields for the custom payload are described here. Delete the "Text Response" if it's there so the custom payload will be the only one to be returned.
To get Google Assistant to display rich responses to the user, one must provide it with a response like the example on the Actions on Google docs. However, since I'm using Dialogflow as the intermediary party between my server and Google's, I need to provide some kind of response to Dialogflow in my webhooks to indicate that there should be a rich response. As you can see from that link, the docs mention how to send rich responses to FB Messenger, Kik, LINE, etc. but not Google Assistant.
What am I missing here? I see an option for rich responses in the Dialogflow web console, but there I can only seem to input hardcoded responses with no dynamic data from the server. What's the right way to do this?
Using the Dialogflow integration, the response JSON your webhook should return for a rich response will look like:
{
"data":{
"google":{
"expectUserResponse":true,
"noInputPrompts":[
],
"richResponse":{
"items":[
{
"simpleResponse":{
"textToSpeech":"Welcome to this Basic Card",
"displayText":"Welcome to this Basic Card"
}
},
{
"basicCard":{
"buttons":[
{
"title":"Button Title",
"openUrlAction":{
"url":"https://some.url"
}
}
],
"formattedText":"Some text",
"image":{
"url":"http://some_image.jpg",
"accessibilityText":"Accessibility text describing the image"
},
"title":"Card Title"
}
}
],
"suggestions":[
{
"title":"Aléatoire"
},
{
"title":"Top"
}
]
}
}
}
}
If you are using the Node.js library You can also use the provided methods for Dialogflow integration to build your rich response.
If you're using Node.js you should call the method buildRichResponse() and then add items as child of that object, like this:
app.ask(app.buildRichResponse()
.addSimpleResponse('A text to be spoken')
.addBasicCard(app.buildBasicCard('Some text to be displayed')
.setTitle('A title')
.addButton('Read more', 'https://example.google.com/something')
.setImage('https://example.google.com/image.png', 'Image alternate text')
.setImageDisplay('CROPPED')
)
);
That was an example for adding a BasicCard, you can see how to add Carousels, Lists and Suggestions Chips at https://developers.google.com/actions/assistant/responses#rich-responses
I implemented web-push notifications on my site with Google Firebase service.
firebase.google.com/docs/cloud-messaging/js/client
I tested it and everything works fine, but when my website window isn't in focus (it's in background) or closed and if I get push-notification it will disappear after 20 seconds.
In my https://hdlava.me/j/firebase_subscribe.js file I added
requireInteraction: true
flag in messaging.onMessage so if I get push mesage when my website is open the message won't disappear until I click on it.
I tried to add this
requireInteraction: true
in messaging.setBackgroundMessageHandler in my https://hdlava.me/firebase-messaging-sw.js, but it's not working. Even:
console.log('[firebase-messaging-sw.js] Received background message ', payload)
doesn't work. It looks like whole messaging.setBackgroundMessageHandler does not work.
Can someone please help me figure out what is the problem ? Also if I use in firebase-messaging-sw.js
self.addEventListener("push",function(event)
instead messaging.setBackgroundMessageHandler so I have two messges at once. First message disappears and second one doesn't, but second one is not clickable. Is it possible to prevent first message and make second one to be clickable ?
Referring to the FCM docs:
https://firebase.google.com/docs/cloud-messaging/js/receive
"Note: If you set notification fields in your HTTP or XMPP send request, those values take precedence over any values specified in the service worker."
So, if you have
{
"notification": {
"title": "Your title",
"body": "Your message"
},
"to": "topic",
}
It never triggers the BackgroundMessageHandler. Because sending data this way, simply overrides your variables. If you want to trigger it you need to send your notification like this:
{
"data": {
"notification": {
"title": "Your title",
"body": "Your message"
}
},
"to": "topic",
}
In my chrome extension I need to add a line to header of every site browsed. In background.js file I add such code:
var responseListener = function(details){
var rule = {
"name": "Access-Control-Allow-Origin",
"value": "*"
};
details.responseHeaders.push(rule);
return {responseHeaders: details.responseHeaders};
};
chrome.webRequest.onHeadersReceived.addListener(responseListener,
{urls: [ "*://*/*" ] },
["blocking", "responseHeaders"]);
While debugging the handler is called and newly added header successfully passes any filters I have found upper in the stack. But it is not seen on network tab's Response headers section and does not effects any code. I use these permissions:
"tabs","<all_urls>", "http://*/*" ,"webRequest","webRequestBlocking", "webNavigation"
Is there a new policy or API changed which disallow to do such things or there is some bug in my 10 lines of a code?
The Network tab of the Chrome Developer tools does not show the modifications from extensions. See https://crbug.com/258064
If you wish to see whether your extension has successfully modified a request, visit chrome://net-internals/#events, click on a request of type URL_REQUEST and look for URL_REQUEST_DELEGATE entries, e.g. URL_REQUEST_FAKE_RESPONSE_HEADERS_CREATED (this is an example of a log entry generated via the chrome.declarativeWebRequest API) or "delegate_info = "extension [extension name]" (generated by chrome.webRequest).