logic app check who has read a yammer post - azure

I'm looking at the Logic Apps Yammer connector.
When we put a message on Yammer we want to find out who has read it. Is there a way to find a list of people in a Yammer group who have not read a Yammer message?
If it can't be done in Logic Apps, is there another way to do it?
As a workaround, I'm trying to do this on the basis of who has liked a message and have done this in Logic apps. It gives a message that the response is not in JSON format. Also, it gives me the number of likes rather than a list of people who have liked it.
This is what I put into the HTTP request
After our chat I tried this
and this
and got this error message.
"error": "invalid_request",
"error_description": "AADSTS900144: The request body must contain the following parameter: 'grant_type'.\r\nTrace ID: d41c78c7-afa5-405f-8f52-8b587ecf1a00\r\nCorrelation ID: 9ffd2247-78ca-4be2-8111-c17a95a830d6\r\nTimestamp: 2020-01-23 10:09:55Z",
"error_codes": [
900144
]
I also tried putting in my Azure directory id in place of tenant id. It failed with and without the directory id.

It seems there isn't an action in logic app Yammer connector which can get the list of users in a group who haven't read a message. And I checked all of the rest api in Yammer api document. Just find a rest api which can get the users in a group:
https://www.yammer.com/api/v1/users/in_group/:Group_Id.json
So I think neither yammer rest api nor logic app can not implement this requirement of get the list of users in a group who haven't read a message.
Update:
For your question about how to implement the workaround in logic app, as I don't have yammer app and account, so I can just provide some suggestions for your reference.
Since the yammer actions in logic app are very limited, so we can just use yammer Apis in logic according to HTTP action.
First we need to get access token from yammer, you can refer to this tutorial and refer to the C. App Authentication title in it. Put this post url in HTTP action in logic app and get the response body. Parse the response body and get the token property under the access_token property. Then we can use this token in the apis which we will call in the next HTTP actions.
Then, call this api in HTTP action(choose "Get" as the method) with the token which we got above to get the users who like the message, the url should be like this:
https://www.yammer.com/api/v1/users/liked_message/:Message_id.json?access_token=<<ACCESSTOKEN>>
Get the response body(and parse it in json type in array) from the api above and then call the other api in HTTP action(with access token) to get the users in one group. Also get the response body from it and parse it in json type and store in array.
After that, use two nested "For each" actions in logic app to loop the two array and compare them. Then we can get the result which you want.
Update 2:

Related

Response from `InvokeRESTAPI` on my Azure pipeline

My InvokeRESTAPI displays the following if executed:
I can see a Response field printed that is empty.
Can I somehow use this to get a value back from the API reply and use it to call another template with it?
On the task itself I am using this parameter:
successCriteria: eq(root["status"], "successful")
So I would assume that if there is some custom success criterion then I would be able to use a value from the response in order to define it.
Based on your screenshot, you are using the API to post the json content to Azure Logic App workflow.
So you need to add the Response Action in Azure Logic App to add response content to the work flow.
Here are the steps:
In Logic App:
Then when you run the API in Invoke Rest API task, it will show the customer response.
For more detailed info, you could refer to this doc: Construct the response

Get Records from Salesforce using Azure Logic Apps

I am trying to use Azure Logic Apps to read data from one of the Salesforce objects which has huge number of records. The Salesforce connector fetches the record and returns the pagination link as #odata.nextLink. But when I try to use a JSON parser to read the value it’s coming as null.
I tried to access the nextlink in a browser but it requires authentication. What authentication do we pass here ?
I would like to use an until action to iterate till I get a next link . So how do I check the condition for the until loop ?
nextLink doesn't look like core Salesforce thing, it might be the OData connector preprocessing the results for you. You'd have to consult the documentation for the connector (if any).
Salesforce's REST API will return field with nextRecordsUrl if there's next page of results, you'd call that in loop until the field disappears. You'd call it like any other REST API resource available after login, by passing Authorization: Bearer <sessionId also known as accessToken here>. Again - probably the connector abstracts this away from you. Don't think you can send headers like that in browser, you'd need curl, Postman, SoapUI or similar http client.
If you don't get better answer and documentation is scarce - consider using raw REST API. Or Azure Data Factory has an almost-decent Salesforce connector?
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm

Node and Microsoft Teams API

I'm building a Node only application that reads logs in the background and based on an event being read will send a message to a Teams channel directly.
I've been having quite a few issues getting a Graph API access token valid through Username and password.
I have been able to get a Graph API access token with client secret and tenant id which represents access
"without a user". Now that does not allow me to post a message in a channel as I would need to have access "on behalf of a user".
API => https://graph.microsoft.com/v1.0/teams/{team-id}/channels/{channel-id}/messages .
Would there be another way of achieving this? Webhook/Connectors?
Thank you!
There's a few different ways you can post to a teams channel, you can set up like you said an http webhook, where you could call it to post into a channel https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using
You can use power automate (flow) or logic apps to post messages as the flowbot, or you can write a bot/ use the bot framework to register a bot that can post to teams, called proactive messaging: https://learn.microsoft.com/en-us/microsoftteams/platform/resources/bot-v3/bot-conversations/bots-conv-proactive
As for trying to use graph with application permissions, that's not possible, at least for the moment.

How to have app send message to Microsoft Teams via Graph API?

I want to be able to use the graph API to get a list of channels & teams, then have the app send an update to the appropriate channel without the user having to interact with MS Teams. Looking around I see a lot of posts saying this isn't possible yet, but Monday.com and Smartsheet seem to be doing this. Monday.com even specifies its using the beta api and neither are using connectors.
I attempted to do use the api POST /teams/{id}/channels/{id}/messages after authenticating via the way shown in this documentation
First Call for adminconsent
https://login.microsoftonline.com/organizations/v2.0/adminconsent?&client_id={botID}&response_type=code&redirect_uri=https://myoauthCallback&scope=offline_access User.ReadWrite.All Group.ReadWrite.All
After that returns I do an immediate call to get an access token, the above call doesn't seem to return anything I need to put into this request.
POST => /organizations/oauth2/v2.0/token
body = client_id={botId}&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default&client_secret={secret}&grant_type=client_credentials
I set the permissions in https://portal.azure.com/#blade/ for the bot to have the same scope as the first request above. Here it doesn't like the scope passed in the same way so I set it to default
I then take the access_token that is returned and attempt the call to POST a message to the channel.
URL: /teams/{TEAM_ID}/channels/{CHANNEL_ID}/messages
body: {
subject: 'test subj',
body: { contentType: 'text', content: 'Test message from app' },
}
This results in an error
statusCode: 401, code: 'UnknownError', message: ''
So how do I get the same functionality of these other apps so I can send a message directly to teams without setting up a connector?
Turns out it was a Office 365 Connector vs the regular "connector" that requires configuration within teams.
https://www.youtube.com/watch?v=EqodWkS5PYM
Edit: Disregard, even with office 365 connectors it requires the user to still interact with MS Teams in some way.
Another Edit: Turns out it is using Proactive Messaging https://learn.microsoft.com/en-us/microsoftteams/platform/resources/bot-v3/bot-conversations/bots-conv-proactive#net-example-from-this-sample
Although technically you cannot actually send a message to the app without a user interacting with the bot first, the installation of the app does trigger a conversationUpdate to which you can reply. So In the end, I can install the Teams app, and send a bot notification all within my web app, without the user having to actually touch Microsoft Teams.
If you look at the "auth" page you linked to, it's talking about creating Application permissions. However, see the "create chatMessage in a channel" graph documentation and under "permissions" near the top it shows that it supports "Delegated" permissions only, so you can't use that particular endpoint with Application permissions unfortunately.
Connectors (Webhooks) will be able to do what you need, but you say you want to avoid that - perhaps you can explain why it's not ideal? I'm not aware of how to create a webhook programmatically, I'm afraid.

How to make an Approval step in Azure Logic app calling my own APIs similar to office365 approval connector?

I wanna build a small workflow using Azure Logic Apps that contains an "Approval" step, which is simply an API call in my own system, similar to office 365 approval connector.
However, from what I found on the internet, the only way to make a long running task in Azure Logic Apps is to use Webhooks.
In Webhooks, I could not set a value to the parameter I created "Bool-Approved".. so, How can I check it later in a condition step?
The other possible solution maybe is to use Swagger to have an "Bool-Approved" parameter. However, it does not support long running action!
What's the possible solution for me?
As you mentioned, the way to do it is to use the Webhook action, and for that you need to implement the Subscribe/Unsubscribe pattern described here. The webhook action will allow you to get any payload (via an HTTP Post) from the instance-based webhook you are subscribing to.
The points below are a summary of this blog post:
https://www.mexia.com.au/correlation-identifier-pattern-on-logic-apps/
To implement the Subscribe/Unsubscribe Webhook pattern you need to consider:
Subscription store: A database to store the unique message Id and the
instance-based callback URL provided by the webhook action.
Subscribe and Start Request Processing API: this is a RESTful API that is in charge of starting the processing of the request and storing the
subscription.
Unsubscribe and Stop Request Processing API: this is another RESTful API that is only going to be called if the webhook action on the main workflow times out. This API is in charge of stopping the processing and deleting the subscription from the store.
Instance-based webhook: this webhook is to be triggered by your own custom approval event. Once triggered, your webhook is in charge of getting the instance-based callback URL from the store and invoking it. After making the call back to the main workflow instance, the subscription is to be deleted. This is the webhook that is in charge of sending the payload you require to the waiting webhook action in your Logic App.
The subsequent actions will be able to use that response body, so you can implement your conditions, etc.
You can follow the blog post mentioned above to see a detailed example and get more details on how to implement it.
make you api return HTTP code 200 if the response if "ok" and 400 if the response is "not ok". This way you can force logic app to behave the way you need it to behave..

Resources