Slack get conversation history for a specific thread - slack-api

I am trying to fetch the conversation history for a specific thread. I am using
const history = await this.slack.conversations.history({
channel,
latest: threadTs,
});
But I am getting the conversation history for the whole channel instead of just for the the threadTs that I am passing to latest. Is what Im trying to do possible? I am using the 'latest' argument because it was suggesting in another StackOverflow post.

Hopefully, you've since found the answer yourself, but just in case: the API method you're looking for is conversations.replies. It takes a channel and a ts parameter, where the latter is the identifier for the message which started the thread.
From the documentation page linked above:
This Conversations API method returns an entire thread (a message plus all the messages in reply to it), while conversations.history method returns only parent messages.
One small note: as you can see, the returned list will always contain the originating message (the one whose ts you're passing).

Related

ADO API: Builds-List incomplete list

I'm calling this API method:
https://learn.microsoft.com/en-us/rest/api/azure/devops/build/builds/list?view=azure-devops-rest-6.0#response
My API url (with placeholder names):
https://dev.azure.com/MyOrgName/MyProjName/_apis/build/builds?api-version=6.1-preview.6
The results are mostly appropriate, except I get a filtered list of builds, and I can't seem to get all the builds I want. In particular, builds from several pipelines are simply missing, and I can't find any way to include them. There's no discernable reason why some builds are included, and some are not.
The filter options describe ways I could reduce it more, but that's not my goal. I want to retrieve builds which I am otherwise not getting. And I don't know what option that I don't know about which will get me the results I care about.
As you have already noticed, there is a maximum number of the objects that can be listed on the response body of each API call. Normally, if the objects you want to list are too many, they will be returned in multiple pages.
In the response body of each call, generally there is a parameter 'continuationToken' (see here). You can access the next response page via calling the API with this parameter.
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds?continuationToken={continuationToken}&api-version=6.1-preview.6
For example:
the first call returns the list in the first page;
then run the second call with the parameter 'continuationToken' returned in the response of the first call to get the second page;
then get the third page using the 'continuationToken' returned in the second response;
. . .
until the last page.
If you want to traverse all the pages, you may need to call the API in a loop.

List channel subscriptions returns only my channel

So, I have a request that should list my subscribers who do not have the private subscriptions option enable. My request is:
response = youtube.subscriptions().list(
part="snippet",
maxResults=50,
mySubscribers=True
).execute()
However, in items resource, every channel returned is my own channel. My channel name, ID and profile images. Is this the problem with the API or am I making a wrong request?
I also tried using the Try this API option on the documentation, but it also returns the same result.
https://developers.google.com/youtube/v3/docs/subscriptions/list
Thank you for any help you can give
According to the official docs you already quoted, you should have passed to your API call the parameter part as:
part="snippet,subscriberSnippet".
The subscriberSnippet part gives you the needed info:
subscriberSnippet (object)
The subscriberSnippet object contains basic details about the subscriber.
For what concerns the snippet part, the official doc is indeed a bit ambiguous:
snippet (object)
The snippet object contains basic details about the subscription, including its title and the channel that the user subscribed to.
Nevertheless, the info you get from part="snippet" only is correct.

MS Graph API response not returning all the data items it supposed to

My intention is to build a Machine Learning program that will give a recommendation for archiving email item by reading all previous email history.
For that, I am trying to read all the email item from:
https://graph.microsoft.com/beta/me/messages
First I am getting the total number of email items in my account using /messages?$count=true which returns 1881 as the result.
Then I am trying to get all the 1881 item using:
https://graph.microsoft.com/beta/me/messages?$top=1881
But the problem is that returns 976 email items. Where are the rest of the email item? How I can find them?
Are you getting a #odata:nextLink property in your response?
If that's the case, you might need to send another request with a skiptoken parameter. It should contain a value from the #odata:nextLink response property.
On the "paging" documentation page - https://developer.microsoft.com/en-us/graph/docs/concepts/paging - it is specified that different APIs have different max page size. It's possible that the endpoint for fetching emails does not support a page size of 1881. In that case, you might need to access a second page of the results.
Another suggestion is to replace beta endpoint with the V1 API call because me/messages is available there also - https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/user_list_messages

How to search for a message by a specific ts

I am trying to get the parent message of a threaded reply with the Slack API. When a new reply is put, it has a "thread_ts" attached to it, which corrsponds to its parent message's "ts". I tried to do a searchall with the ts as the query but this didn't work. How would I do this?
See Slack's docs on retrieving a single message with channels.history. This "selecting 1 item from a range" approach should also work with other channel history methods and conversations.history.
The easiest way is to provide the thread_ts value you want to look up as the latest parameter to conversations.history, along with the containing channel ID as channel, and a limit of 1 to ask for a single message. You will need the corresponding *:history scope to make the request.
Example:
GET /api/conversations.history?token=TOKEN_WITH_CHANNELS_HISTORY_SCOPE&channel=C2EB2QT8A&latest=1476909142.000007&inclusive=true&limit=1

YouTube Data API v3 Comment Thread Discrepency

I have been trying to get a list of comments out using the new V3 Data API with mixed results.
For some videos, you only get a subset of comments out. I have noticed this on a few videos, but for this specific case I will use video ID = U55NGD9Jm7M
You can find all the comments on this video in the WebUI here: https://www.youtube.com/all_comments?v=U55NGD9Jm7M
At the time of posting, there were 5,499 comments on this video.
API Results:
When querying https://www.googleapis.com/youtube/v3/commentThreads?part=id,snippet,replies&textFormat=plainText&maxResults=100&videoId=U55NGD9Jm7M&key={YOUR_API_KEY} I am only getting about 317 comments (including Paging, and counting all replies) (sorted chronologically).
Verification Research:
If you select "Top Comments" from the drop down and then scroll down and click "More" over and over again, you get over 1,000 comments (I stopped at about 1,000)
If you then select "Newest First" from the dropdown and repeat the process (more ... more ... more) you will find that there are about 317 comments before you are unable to show any more comments.
I find it quite odd that there is a discrepancy in the UI, but thankful that the API lines up with part of the UI. Has anyone else noticed this? Is there a way to get the full text of all 5,499 comments?
Thanks!
Jason
Follow-up 1
As a follow-up, I was able to isolate one comment using View->Source (Thread ID z12wzfzhtybgz13kj22ocvsz2unrtn1qj04) and fetch all the information from this comment in the API here: https://www.googleapis.com/youtube/v3/commentThreads?part=id%2Csnippet%2Creplies&id=z12wzfzhtybgz13kj22ocvsz2unrtn1qj04&maxResults=100&key={YOUR_API_KEY})
It even mentions the correct VideoID that the comment is associated with. However, when you query by Video, this comment ID is not returned.
Follow-up 2
I refresh the Web UI of the All Comments, and there was a significantly different list of comments that are being returned
The commentsThread.list call can only return a maximum of 100 results (see maxResults in the documentation). If you wanted to get more comment threads, you'd have to pass in the nextPageToken you get from your initial call into a subsequent API call.
For example:
https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&videoId=U55NGD9Jm7M&maxResults=100&key=API_KEY
gives you 100 comment threads, and the nextPageToken is Cg0Qk9fa7fHgxgIgACgBEhQIARCY49LZ5eDGAhi4rNGIrZrGAhgCIGM. If you include that token in a new API call, like so:
https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&videoId=Dlj6SUg9B04&&maxResults=100&nextPageToken=Cg0Qk9fa7fHgxgIgACgBEhQIARCY49LZ5eDGAhi4rNGIrZrGAhgCIGM&key=API_KEY
You get a completely different set of comment threads. You can double check this by specifying order=time in both API calls. You'll see that the earliest comment threads for both calls are different, and you won't find the comment Thread ID for either in the other call's results. To get even more comment threads, you take the nextPageToken from the newer call's results and do the same thing again (until the call doesn't give you another nextPageToken, meaning you're on the last page, and there are no more comment threads to return).

Resources