Microsoft Graph send email api conversation Index is different - email

We are integrating the MS Graph API's in our c# application. sending mail is working fine by following this article Send Mail Documentation. But I am facing an issue with ConversationIndex (Mainly Threads).
ConversationIndex of mail sent via API is different than recipients' replies to the same mail. Due to this it is unable to identify the threads.
This is the payload used to send mail. can anybody help me with any key or property I am missing while sending mail?
{
"message": {
"subject": "Meet for lunch?",
"body": {
"contentType": "Text",
"content": "The new cafeteria is open."
},
"toRecipients": [
{
"emailAddress": {
"address": "fannyd#contoso.onmicrosoft.com"
}
}
],
"ccRecipients": [
{
"emailAddress": {
"address": "danas#contoso.onmicrosoft.com"
}
}
]
},
"saveToSentItems": "false"
}

Structure of Conversation Index
[reserved-1B] [timestamp-5B] [GUID-16B] [timestamp-5B][timestamp-5B]…[timestamp-5B]
<-------------Header Block---------------->​<-------------------Child Blocks------------------>
All messages part of the same conversation thread has the same 16-Bytes GUID.
5-Bytes [timestamp] in Header Block: System time when message was received converted into FILETIME format.
5-Bytes [timestamp] in Child Blocks: Child blocks are present only for Outlook messages, to indicate subsequent messages in a thread while keeping the header block attributes same. Every message reply to a conversation adds a [timestamp] at end to create a new conversationIndex.
Relative ordering of messages belonging to same conversation thread:
For all messages belonging to same GUID, SORT the messages by conversationIndex values.
Please refer to documentations here to understand better.
Tracking conversations
ConversationIndex property

Related

How to send activity output as email attachment in logic app

I have an ADF pipeline, I want to send the output of my activity as an email attachment in the logic app.
I have a lookup activity followed by a For each activity and an Inside For each activity I have a web activity to call the logic app.
I want to send the output of the lookup activity as an email attachment to the logic app. I am not able to think about this integration part.
Create Logic app event trigger with HTTP and Outlook.
Inside HTTP request is received:
Copy HTTP POST URL
Request Body JSON Schema
{ "properties": { "dataFactoryName": { "type": "string" }, "message": { "type": "string" }, "pipelineName": { "type": "string" }, "receiver": { "type": "string" } }, "type": "object" }
POST Method
Send an Email
Connect Your outlook email .
Use HTTP POST URL as shown in step1
Create parameter name receiver
Add dynamic this content
s
{
"message" : "This is the row from lookup item #{item().customerID},#{item().gender},#{item().SeniorCitizen},#{item().Partner}.",
"dataFactoryName" : "#{pipeline().DataFactory}",
"pipelineName" : "#{pipeline().Pipeline}",
"receiver" : "#{pipeline().parameters.receiver}"
}
Pipeline successfully executed and got the output:
There is no direct or easy way to send email attachment from ADF.
But as a workaround first you will have to save the output of your lookup activity to a file and then follow the approach described in this video by a community volunteer where logic apps come into play to send the lookup activity output data file as an attachment. How To Send File as Attachment From Azure Data Factory - Azure Data Factory Tutorial 2021
In order to save the lookup output data to a file you can follow this approach: Get Output of lookup activity in a file

OutLook Mail Rest API --> See if the message is a reply

I am trying to get a way to see if a message that i get using the Outlook Rest API using this url https://graph.microsoft.com/beta/me/messages('{messageid}') and seing if it is a reply. Normaly it would be from the Thread Id but the API doesn´t send one.
Is there anyway to see if the message is a reply?
API has one 'ConversationId' field. You can use that to group the messages.
{
...
"ConversationId": "AQQkADAwAT..."
...
}
This question has been answered here:
https://stackoverflow.com/a/60048538/3892957
Use GET https://graph.microsoft.com/v1.0/me/messages?$expand=SingleValueExtendedProperties($filter=(Id%20eq%20'Integer%200x1081'))
If a Message had been replied to you would see a result like
"singleValueExtendedProperties": [
{
"id": "Integer 0x1081",
"value": "102"
}
]

How to change ejabberd MUC subject

I've tried to change MUC subject using ejabberd API but didn't work. I use Postman to work with the API
api : /api/change_room_option
request body :
{
"name": "testgroup",
"service": "conference.localhost",
"option": "subject",
"value": "BookNerds"
}
error : "400 Bad Request"
I've enabled change_room_option in my ejabberd.yaml and set allow_change_subj to true. Using this configuration and same request body format, I successfully change 'title' and 'description'.
Note : I ran another test using Adium and successfully change the subject. When I check in database, subject and subject_author have been updated. Do I need to set subject_author too in the request body? If yes - I don't think it's possible since change_room_option will only accept four parameters as stated here

Getting repeated calls on facebook-messenger webhook

I have successfully setup a facebook-messenger webhook. Until yesterday I was able to send and receive messages as well. But today, when I am sending one message from user, I am getting multiple calls at server webhook POST API. They never seem to stop.
Do all of those calls have the same content or are they different? You could log the exact message string that facebook sends to you and see what they include.
For example there's a message delivery callback that informs you that the user received the message. The JSON looks like this:
{'delivery': {'mids': ['mid.146174459xxx:30a42600a95exxxxx'], 'seq': 429, 'watermark': 146174459xxx}, 'recipient': {'id': xxxxxxxx}, 'sender': {'id': xxxxxx}}
Edit: It could also be the case that your are not confirming incoming calls with a http status 200. If facebook receives an error from your webhook the message will be sent multiple times.
Figured it out. I was sending response to every communication that came from facebook. So I ended up responding to ACK messages as well. In turn one more ACK came. Thats why it led to infinite loop.
In this page we can find different object structures for messages recieved:
text
{
"object":"page",
"entry":[
{
"id":PAGE_ID,
"time":1457764198246,
"messaging":[
{
"sender":{
"id":USER_ID
},
"recipient":{
"id":PAGE_ID
},
"timestamp":1457764197627,
"message":{
"mid":"mid.1457764197618:41d102a3e1ae206a38",
"seq":73,
"text":"hello, world!"
}
}
]
}
]
}
Message-Delivered callback
{
"object":"page",
"entry":[
{
"id":PAGE_ID,
"time":1458668856451,
"messaging":[
{
"sender":{
"id":USER_ID
},
"recipient":{
"id":PAGE_ID
},
"delivery":{
"mids":[
"mid.1458668856218:ed81099e15d3f4f233"
],
"watermark":1458668856253,
"seq":37
}
}
]
}
]
}
So, for differentiating we can refer to entry[0].messaging[0].message this exist only in user sent message. Callback or postbacks do not contain this part.
Check for this, before responding. If it exists, respond, otherwise dont.
My problem was similar but I was getting Multiple Message delivery posts. After a few hours of frustration, I realized that Message Delivered callback is called every time the message is delivered to EVERY DEVICE. So, if you are logged into both web and mobile app, the callback would be called twice.
When working with messenger of facebook you need to take in account two things after you send the message :
A) Message Delivery
B) Message Read
Since you are working with webhooks this will be trigger everytime one of the events happen (receive a message , deliver the message you sent , the user read the message). So if you activate for example message_deliveries in your webhook and you send a message as action , you will end up in a loop.
The proper way to handle this is in the base code. PHP example :
// Skipping delivery messages
if (!empty($message['delivery'])) {
#Do something here if you want
continue;
}
// Skipping read messages
if (!empty($message['read'])) {
#Do something here if you want
continue;
}
Hope it helps !

Attribute Reference for subscription in Orion Context Broker Fiware

What do I need to put in the reference attribute?
I'm using two forms, and the two are bad for Orion Context Broker:
URL url = new URL("http://130.206.127.23:1026/ngsi10/notifyContext");
//String url = "http://localhost:1028/accumulate";
cabecera.put("reference", ""+url);
With this code, I'm generating the next JSON String for the reference attribute
...."reference":"http:\/\/130.206.127.23:1026\/ngsi10\/notifyContext",...
And this is the response of OCB
<subscribeContextResponse>
<subscribeError>
<errorCode>
<code>400</code>
<reasonPhrase>Bad Request</reasonPhrase>
<details>JSON Parse Error: <unspecified file>(1): invalid escape sequence</details>
</errorCode>
</subscribeError>
</subscribeContextResponse>
Also related to this parameter,do I need a program in execution in a server to receive the information about my subscription?
Can I get a program from Orion Context Broker resources to do this task?
The following is my JSON to call the service, but I'm not sure about the reference attribute. I want to send a subscription to my Orion Context Broker instance. I'm sending this JSON:
{
"duration": "P1M",
"reference": "http://130.206.127.23:1026/ngsi10/notifyContext",
"notifyConditions": [
{
"condValues": [
"PT10s"
],
"type": "ONTIMEINTERVAL"
}
],
"entities": [
{
"id": "1.0",
"type": "Capsule",
"isPattern": "false"
}
],
"attributes": [
"temperature"
]
}
Thanks in advance.
The reference element is described in the Orion User Manual:
The callback URL to send notifications is defined with the reference
element.
Thus, if your reference is http://130.206.127.23:1026/ngsi10/notifyContext as shown in your example, you should have a REST server listening at host 130.206.127.23 port 1026, able to receive notifications in the /ngsi10/notifyContext path. Note that your CB (I mean, the one to which you are sending the subscribeContext request) is the actor that sends notification, not the actor that receives them, so it must not run at 130.206.127.23:1026.
You can implement the notifications receiver program in any programming language that you want (as long as it implements the required REST server interface). You can have a look to the accumulator-server.py, which is a "dummy" notification receiver example implemented in Python, used for testing.