How can I send notification from Postman using FCM? - flutter

I am using a Post method from the postman to send notifications to my flutter app, If I include the body outside of the notification in this way I can send notifications.
{
"to": "cu6HFvgXSCyKz5kjp..........",
"notification": {
"sound": "default",
"body": "test body",
"title": "test title",
"content_available": true,
"priority": "high"
},
"data": {
"sound": "default",
"body": "test body",
"title": "test title",
"content_available": true,
"priority": "high",
"ride_request_id":"asdfasd"
}
}
I can parse the data to get my value from ride_request_id but the catch is I get double notification, so FCM has suggested including the body inside the notification, Now, neither do I get the notification nor able to parse it. Although in Postman it shows as successful.
{
"to": "cu6HFvgXSCyKz5kjp..........",
"notification": {
"sound": "default",
"body": "test body",
"title": "test title",
"content_available": true,
"priority": "high",
"data": {
"sound": "default",
"body": "test body",
"title": "test title",
"content_available": true,
"priority": "high",
"ride_request_id": "asdfasd"
}
}
}

here is an article about sending a notification using postman:
Test FCM Notification with POSTMAN

Related

OTP Verification using API in swift and mvvm method

I have a sign-in, sign-up and forgot password field. I need to verify the login with a 2fa code. How do I verify this using MVVM method.
here's my API and parameters.
Send OTP:
{
"email": "string",
"phoneNumber": "string",
"callingCode": "string",
"otpType": 1
}
Response:
{
"data": {
"otp": "968785",
"status": true
},
"success": true,
"successCode": 1009,
"httpstatusCode": 200,
"developerMessage": "Please use this code for verification ",
"userMessage": "Please use this one-time code for verification",
"header": "Alert"
}
Verify OTP Request:
{
"email": "string",
"otp": "string"
}
response
{
"data": {
"status": true
},
"success": true,
"successCode": 1010,
"httpstatusCode": 200,
"developerMessage": "Account has been verified successfully",
"userMessage": "Account verified",
"header": "Alert"
}

MS Graph API- End-point to read email messages with header information from outlook account

I am using the below endpoint to read mail messages from a given mail folders but I see the message does not contain header information.
end point- https://graph.microsoft.com/v1.0/me/mailFolders/{folderid}messages/?$orderby=sentDateTime
Response looks like-
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('55f7b855-44a8-46c2-908a-00ff4d54c46e')/mailFolders('AQMkAGYyOTI1Yzc5LTFlZjctNDlhYy1hMWQzLTA1MjY0ZmRkADBkZTAALgAAA--el_XftXZKt0YdPN_913sBAFL-3e9Uo9BKmUKAmISlmIAAAAIBCQAAAA%3D%3D')/messages",
"value": [
{
"#odata.etag": "W/\"CQAAABYAAABS/93vVKPQSplCgJiEpZiAAAAMRZRE\"",
"id": "AAMkAGYyOTI1Yzc5LTFlZjctNDlhYy1hMWQzLTA1MjY0ZmRkMGRlMABGAAAAAAD-3pfl37V2SrdGHTzfvdd7BwBS-93vVKPQSplCgJiEpZiAAAAAAAEJAABS-93vVKPQSplCgJiEpZiAAAAMTZWmAAA=",
"createdDateTime": "2021-08-02T12:47:39Z",
"lastModifiedDateTime": "2021-08-02T12:47:42Z",
"changeKey": "CQAAABYAAABS/93vVKPQSplCgJiEpZiAAAAMRZRE",
"categories": [],
"receivedDateTime": "2021-08-02T12:47:40Z",
"sentDateTime": "2021-08-02T12:47:39Z",
"hasAttachments": false,
"internetMessageId": "<MAZPR01MB5442E2218F9D377BD1D514E4E9EF9#MAZPR01MB5442.INDPRD01.PROD.OUTLOOK.COM>",
"subject": "rr",
"bodyPreview": "rr",
"importance": "normal",
"parentFolderId": "AQMkAGYyOTI1Yzc5LTFlZjctNDlhYy1hMWQzLTA1MjY0ZmRkADBkZTAALgAAA--el_XftXZKt0YdPN_913sBAFL-3e9Uo9BKmUKAmISlmIAAAAIBCQAAAA==",
"conversationId": "AAQkAGYyOTI1Yzc5LTFlZjctNDlhYy1hMWQzLTA1MjY0ZmRkMGRlMAAQAKmsc6svyzlHuJr_l4TQwX4=",
"conversationIndex": "AQHXh5yTqaxzqy/LOUe4mv6XhNDBfg==",
"isDeliveryReceiptRequested": false,
"isReadReceiptRequested": false,
"isRead": true,
"isDraft": false,
"webLink": "https://outlook.office365.com/owa/?ItemID=AAMkAGYyOTI1Yzc5LTFlZjctNDlhYy1hMWQzLTA1MjY0ZmRkMGRlMABGAAAAAAD%2F3pfl37V2SrdGHTzfvdd7BwBS%2F93vVKPQSplCgJiEpZiAAAAAAAEJAABS%2F93vVKPQSplCgJiEpZiAAAAMTZWmAAA%3D&exvsurl=1&viewmodel=ReadMessageItem",
"inferenceClassification": "focused",
"body": {
"contentType": "html",
"content": "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><meta content=\"text/html; charset=iso-8859-1\"><style type=\"text/css\" style=\"display:none\"><!--p{margin-top:0;margin-bottom:0}--></style></head><body dir=\"ltr\"><div style=\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)\">rr<br></div></body></html>"
},
"sender": {
"emailAddress": {
"name": "some name",
"address": "some address"
}
},
"from": {
"emailAddress": {
"name": "some name",
"address": "some address"
}
},
"toRecipients": [
{
"emailAddress": {
"name": "some name",
"address": "some address"
}
}
],
"ccRecipients": [],
"bccRecipients": [],
"replyTo": [],
"flag": {
"flagStatus": "notFlagged"
}
}
]
}
Earlier we used java.mail API to do the same and used to get it like
javax.mail.Message message= ;
Enumeration headers = message.getAllHeaders();
Is there any way to achieve this using an MS graph API?
If you want the Internet Message headers then you need to include that in the Select Parameter as the Graph doesn't return it as a default property eg
https://graph.microsoft.com/v1.0/me/messages/?$select=internetMessageHeaders

DialogFlow v2 fulfillmentMessages

I'm trying to respond to users with news cards but as far as I can see if I follow your example it does not work.
If I just respond with fulfillmentMessages like this
res.json({
"fulfillmentMessages": [
{
"card": {
"title": "card title",
"subtitle": "card text",
"imageUri": "https://assistant.google.com/static/images/molecule/Molecule-Formation-stop.png",
"buttons": [
{
"text": "button text",
"postback": "https://assistant.google.com/"
}
]
}
}
],
"source": "example.com"
});
I get this error back:
{
"responseMetadata": {
"status": {
"code": 13,
"message": "Failed to parse Dialogflow response into AppResponse because of empty speech response",
"details": [
{
"#type": "type.googleapis.com/google.protobuf.Value",
"value": "{\"id\":\"ef8154ae-96ff-4837-b7e7-d3388223240d\",\"timestamp\":\"2018-04-27T15:19:19.449Z\",\"lang\":\"en-us\",\"result\":{},\"status\":{\"code\":200,\"errorType\":\"success\"},\"sessionId\":\"1524841118917\"}"
}
]
}
}
}
If I add the fulfillmentText (that should be optional) Google Assistant will only use the plain text as a response and won't use cards.
Has someone fixed this issue?

How can I create a response with rich messages in Dialogflow?

Currently, When an intent is invoked, I am calling a webhook and getting a response from the web service as json structure show below.
{
"speech": "this text is spoken out loud if the platform supports voice interactions",
"displayText": "this text is displayed visually"
}
This is mere text. Alternatively, What response do I have to get to display a list for example.
I tried the rich message section of dialogflow documentation. Those structures didn't work.
Every time DialogFlow matches an intent, you have the possibility to ask DialogFlow to send a request to a specific endpoint. An endpoint which you’ll obviously have to code.
That will allow you to retrieve the matched intent, as well as the matched parameters and contexts, and do some useful work with those.
How to use Message Object in Dialogflow
Kommunicate - Custom webhook Dialogflow integration example
Example of rich message with webhook
{
"fulfillmentMessages": [{
"payload": {
"message": "Object1",
"platform": "", // Example - Facebook, Slack...etc
{
"name": "Save Promo",
"action": {
"type": "quickReply",
"payload": {
"message": "text will be sent as message",
"replyMetadata": {
"key1": "value1"
}
}
}
},
{
"name": "Save Coupon",
"action": {
"type": "quickReply",
"payload": {
"message": "text will be sent as message",
"replyMetadata": {
"key1": "value1"
}
}
}
}
}, {
"payload": {
"message": "Object2",
"platform": "" // Example - Facebook, Slack...etc
}
}]
}
To add an Actions on Google List as part of the reply, you'll need to use the data field in your response to include a richResponse with what should be said, along with a systemIntent that contains the list information.
You can see more examples at their github example repository, but here is the one for showing a list:
{
"data": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Choose an item"
}
}
]
},
"systemIntent": {
"intent": "actions.intent.OPTION",
"data": {
"#type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
"listSelect": {
"title": "Hello",
"items": [
{
"optionInfo": {
"key": "first title"
},
"description": "first description",
"image": {
"url": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
"accessibilityText": "first alt"
},
"title": "first title"
},
{
"optionInfo": {
"key": "second"
},
"description": "second description",
"image": {
"url": "https://lh3.googleusercontent.com/Nu3a6F80WfixUqf_ec_vgXy_c0-0r4VLJRXjVFF_X_CIilEu8B9fT35qyTEj_PEsKw",
"accessibilityText": "second alt"
},
"title": "second title"
}
]
}
}
}
}
}
}

Set Dialogflow response object based on user platform

I have a webhook server that responds to Dialogflow with rich message objects, which work on the Google Assistant.
However, in the case the user chatting with my bot from a different platform other than Google Assitant, such as the web or Amazon Alexa, I would like to send a basic text response.
After looking through the docs, I am not sure how I can send a response message object that will display a rich message object when the user uses Google Assistant, and a plain text response on other platforms as a fallback.
This is the format of my current rich message response object, taken from the docs: https://dialogflow.com/docs/reference/agent/message-objects#basic_card_response
{
"messages": [
{
"buttons": [
{
"openUrlAction": {
"url": "https://linkUrl.com"
},
"title": "AoG Card Link title"
}
],
"formattedText": "AoG Card Description",
"image": {
"url": "http://imageUrl.com"
},
"platform": "google",
"subtitle": "AoG Card Subtitle",
"title": "AoG Card Title",
"type": "basic_card"
}
]
}
To do this, you'll just include a regular text/speech response in the messages object.
In the /query doc, check out the POST response sample.
Your JSON should look something like this:
{
"messages": [
{
"buttons": [
{
"openUrlAction": {
"url": "https://linkUrl.com"
},
"title": "AoG Card Link title"
}
],
"formattedText": "AoG Card Description",
"image": {
"url": "http://imageUrl.com"
},
"platform": "google",
"subtitle": "AoG Card Subtitle",
"title": "AoG Card Title",
"type": "basic_card"
},
{
"speech": "text response",
"type": 0
}
]
}