Is there a way to reply to pull-request review comments with the Github-API V4 (GraphQL)? - github

Goal
I want to use the GraphQL API to reply to a pull request review comment.
It is possible if the status of the review is PENDING, but when the status of the review is SUBMITTED, it is not possible.
When I try it over the UI or the API V3 (REST), everything works fine.
This is an example of an reply to another PR-review comment.
This was the way to do it over the REST API.
What I have tried
I have tried to use the GraphQL addPullRequestReviewComment
mutation.
Here is my mutation request
mutation {
addPullRequestReviewComment(
input: {
pullRequestReviewId: $pullRequestReviewId,
inReplyTo: $commentToReplyTo,
body: "test comment"
}) {
clientMutationId
comment{
body
}
}
}
I expect the above mutation to reply to another review comment, but I get this response:
{
"data": {
"addPullRequestReviewComment": null
},
"errors": [
{
"type": "VALIDATION",
"path": [
"addPullRequestReviewComment"
],
"locations": [
{
"line": 2,
"column": 3
}
],
"message": "Review has already been submitted."
}
]
}
I know that when you reply to another PR-Review comment of an already submitted review, you create a new review object for that comment.
But when I would try to solve my problem with that logic I would expect to find a reply_to field or some other way to link to a comment of another PR-review comment on the addPullRequestReviewInput object.

Related

Facebook webhook, how to get conversation id from mid id

Hello everyone i'm building a chat bot, i'm having a problem that is, when a user sends a message to my app, i don't get the conversation id like "t_31231231231231", instead I get "mid", I don't know how to get the conversation from "mid", i tried to find the document but maybe I haven't found it yet. :(
{
"object": "page",
"entry": [
{
"id": "553014938133297",
"time": 1567149324484,
"messaging": [
{
"sender": {
"id": "2112675102192095"
},
"recipient": {
"id": "553014938133297"
},
"timestamp": 1567149323879,
"message": {
"mid": "n89QDNpjbh7UUZjDj7mkfk-Mqd_vry00MlXChtxjo-ZLokFwJAtZ6udnPZibQjzAZpuqsN64UVjTly5cTCEKTQ",
"text": "dasddsad",
"nlp": {
"entities": {},
"detected_locales": [
{
"locale": "vi_VN",
"confidence": 0.8299
}
]
}
}
}
]
}
]
}
This might not be the ideal solution, but can serve as an improvisation. Since, you have the message_id you can fetch message to determine who the participants are, then you can match them with the participants in the conversations.participants.
What I did was to fetch all the conversations with their participants field.
i.e
curl -i -X GET \
"https://graph.facebook.com/v8.0/me/conversations?fields=participants&access_token=your-access-token-goes-here"
Which returns
{"data"=>
[{"participants"=>
{"data"=>
[{"name"=>"Masroor Hussain",
"email"=>"3275685679217538#facebook.com",
"id"=>"4275685679217538"},
{"name"=>"Testpage",
"email"=>"115083020351552#facebook.com",
"id"=>"115083020351552"}]},
"id"=>"t_781422919067688"}],
"paging"=>
{"cursors"=>
{"before"=>
"QVFIUlRKd1RBYmtvVXlicm95QUNZAbjVKUW5LbU5lYzhQM24ycmY1aTBXM1NTbnRSLURhc2xnSlBnOWE3OTJ4ZAy1KbS1LLVhUUEdqYmM0MmVzZAXZAZAX2xRdzJCbXpJSEowMmxzUHc0NlBXQ0FTVEdRSEZAZASmI2SGxsNlNOdC1XOWNSZADl0",
"after"=>
"QVFIUkdEUjNPek5jbE9RNUhzZAXpJTm9hWERvQVdGYVV5cHlfcDl6cEJyZAG5NaGpjR1NkUHI4R0JDd1VkWEU0RUh2ZADFOQUVzN0RwQ2tyYmpXcThEV0hjUDM2QXAxbFRLWDVzUGoyNmFjbkcyUzl3X0Myc1AtanRYUndjMDBSdVZAJZAnI0"
}
}
}
In the participants.data one participant is the page and the other is page_scoped_user. You can parse the response to match your participants and get the conversation id e.g here the conversation id would be "t_781422919067688"
A little late here but I had the same problem and actually found the solution in the Instagram API documentation. I tried it in the facebook graph api and it worked perfectly.
In the webhook event, you have the message ID and the sender ID. Using the sender ID, you can make a call to the Graph API (yes, still an additional API call) using the following endpoint:
/{page_id}/conversations?access_token={access_token}&user_id={user_id}
this will return only the conversation between your page and the specified user.

Facebook Graph API get comments from Comments Plugin

I'm trying to get all comments from Facebook Comments Plugin running in my application.
Here's a step by step of what i have done
https://graph.facebook.com/{myUrl}
{
"share": {
"comment_count": 43,
"share_count": 1695
},
"og_object": {
"id": {myObjectID},
"description": {myDescription},
"title": {myTitle},
"type": "website",
"updated_time": "2018-05-28T21:50:37+0000"
},
"id": {myUrl}
}
https://graph.facebook.com/{myObjectID}/comments?access_token={pageToken}
{
"data": [ ],
"paging": {
"cursors": {
"before": {beforePointer},
"after": {afterPointer}
},
"next": {nextUrl}
}
}
So despite comment_count = 43, data field is empty.
It's also weird that a {nextUrl} is given although not showing any results.
Haven't found nothing about this in the recent update due to GDPR.
Any ideas?
The graph API has changed recently due to privacy and GDPR concerns.
To get all comments for a page or user first you need to make a call to get all your posts and then make a call for each post to get comments.
Please view the following example end to get all the posts and then post_ids (the call is similar for user posts).
https://graph.facebook.com/v3.2/{pageId}/posts?access_token={accessToken}
post_id looks something like this - 5704324444475_570454233326 and is in the id field of each returned post.
Then call the get comments endpoint from the graph API using the ID(s) returned by the first endpoint.
https://graph.facebook.com/{post_id}/comments?access_token={accessToken}&summary=true
You'll need to make a separate call for each posts to get that post's comments.

Error "Empty speech response"

I tried to connect DialogFlow and Actions on Google, so I created some intents, connected the services, added explicit and implicit invocations etc, but when I try the bot in the simulator https://console.actions.google.com/project/[projectId]/simulator/ it always gives me the error:
"Failed to parse Dialogflow response into AppResponse, exception
thrown with message: Empty speech response"
even tough inputType was "KEYBOARD".
What I tried so far:
I did set "Response from this tab will be sent to the Google Assistant integration" in Dialog Flow (do you have to set it for every single intent?), but I don't see any extra setting for speech.
I disabled the second language, first I had also intents in German
I also turned off the Fullfillment Webhook (implemented in API v1 and then also v2) with no change
I only found this user with the same problem https://productforums.google.com/forum/#!topic/dialogflow/xYjKlz31yW0;context-place=topicsearchin/dialogflow/Empty$20speech$20response but no resolution.
the fulfillment checkbox is checked at the intents
The bot works fine when I use it through "Try it now" on the very right in Dialog Flow or in the Web Demo https://bot.dialogflow.com/994dda8b-4849-4a8a-ab24-c0cd03b5f420
Unfortunately the docs don't say anything about this error. Any ideas?
Here a screenshot of the error on the Actions integration:
This is the full debug output:
{
"agentToAssistantDebug": {
"agentToAssistantJson": {
"message": "Failed to parse Dialogflow response into AppResponse, exception thrown with message: Empty speech response",
"apiResponse": {
"id": "c12e1389-e887-49d4-b399-a332188ca946",
"timestamp": "2018-01-27T03:55:30.931Z",
"lang": "en-us",
"result": {},
"status": {
"code": 200,
"errorType": "success"
},
"sessionId": "1517025330705"
}
}
},
"assistantToAgentDebug": {
"assistantToAgentJson": {
"user": {
"userId": "USER_ID",
"locale": "en-US",
"lastSeen": "2018-01-27T03:55:03Z"
},
"conversation": {
"conversationId": "1517025330705",
"type": "NEW"
},
"inputs": [
{
"intent": "actions.intent.MAIN",
"rawInputs": [
{
"inputType": "KEYBOARD",
"query": "Talk to Mica, the Hipster Cat Bot"
}
]
}
],
"surface": {
"capabilities": [
{
"name": "actions.capability.MEDIA_RESPONSE_AUDIO"
},
{
"name": "actions.capability.WEB_BROWSER"
},
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
}
]
},
"isInSandbox": true,
"availableSurfaces": [
{
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
}
]
}
]
},
"curlCommand": "curl -v 'https://api.api.ai/api/integrations/google?token=TOKEN' -H 'Content-Type: application/json;charset=UTF-8' -H 'Google-Actions-API-Version: 2' -H 'Authorization: AUTH_TOKEN' -A 'Mozilla/5.0 (compatible; Google-Cloud-Functions/2.1; +http://www.google.com/bot.html)' -X POST -d '{\"user\":{\"userId\":\"USER_ID\",\"locale\":\"en-US\",\"lastSeen\":\"2018-01-27T03:55:03Z\"},\"conversation\":{\"conversationId\":\"1517025330705\",\"type\":\"NEW\"},\"inputs\":[{\"intent\":\"actions.intent.MAIN\",\"rawInputs\":[{\"inputType\":\"KEYBOARD\",\"query\":\"Talk to Mica, the Hipster Cat Bot\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"},{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]}]}'"
},
"sharedDebugInfo": [
{
"name": "ResponseValidation",
"subDebugEntry": [
{
"debugInfo": "API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: \": Cannot find field.\".",
"name": "UnparseableJsonResponse"
}
]
}
]
}
Also "debugInfo" sounds like an internal problem:
"API Version 2: Failed to parse JSON response string with
'INVALID_ARGUMENT' error: \": Cannot find field.\"."
Here a screenshot of the welcome intent:
ps.
It took me AGES to figure out, what
"Query pattern is missing for custom intent"
means - so I just document it here: In Dialog Flow - Intent - "User says" you have to DOUBLE CLICK on a word in the text input field when you want to set it as query parameter - which seems to be required for Actions on Google.
This happened to me. If this happens for an Intent you just added in the Dialogflow console and you are using Webhook fulfillment for the action, check the intent's fulfillment settings and ensure that the Webhook fulfillment slider is on. Evidently new intents don't automatically get webhook fulfillment: you have to opt each one in piecemeal (or at least, that was my experience).
I experienced this situation too.
My problem was that I used a SimpleResponse in my fulfillment index.js without referencing to it. So the solution for me was to add SimpleResponse like this in index.js:
const {dialogflow, SimpleResponse} = require('actions-on-google');
So, always check if you aren't using any dependencies without including it in your js-file.
Probably not the most common cause of the problem, but it can be.
I got this when running through the codelabs tutorial (https://codelabs.developers.google.com/codelabs/actions-1/index.html#4) and didn't name my intent the same name as it is referenced in the webhook script:
I came across this error when trying to develop my own WebHook. I first verified that my code was called by looking into the Nginx log, after which I knew there was a problem in my JSON output because I based my output on outdated examples.
The (up-to-date) documentation for both V1 and V2 of the API can be found here:
https://dialogflow.com/docs/fulfillment/how-it-works
This example response for v2 of the dialogflow webhook API helped me to resolve this error:
{
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "this is a simple response"
}
}
]
}
}
}
}
Source: https://github.com/dialogflow/fulfillment-webhook-json/blob/master/responses/v2/ActionsOnGoogle/RichResponses/SimpleResponse.json
You can find more examples in the official github repository linked above.
Another possibility is if you have a text response (even an empty one) like so:
Then you need to click the trash can next to the response to clear it out to use the webhook.
The Actions on Google support helped me fix this problem:
I needed to add a text as Default Response to the intent used for Explicit Invocation.

How to create transaction for shopify order created via API

I have followed everything in the following shopify question which is basically the same thing but what is described there is not working for me at all. Here is the request I am sending to the transactions endpoint:
{
"transaction": {
"amount": "0.01",
"kind": "sale"
}
}
and here is the response I am getting:
{
"errors": {
"kind": [
"sale is not a valid transaction"
]
}
}
I am thinking something has changed with shopify's API since that seemingly duplicate question was answered.

Using facebook API breakdowns insights

Trying to get the impressions per notification of specific group(by using ref).
By the api you can set a group for notifications by adding ref param to the notification request
That worked fine.
Now i am trying to use the API for getting insights as explained here:
insights
I still dont understand how to pass the ref param.
this is my execution:
../app_insights/app_notification_impressions?breakdowns[0]=ref&access_token={acce‌​ss-token}
And in return I get this:
{
"data": [
{
"time": "2014-12-09T08:00:00+0000",
"value": "44",
"breakdowns": {
"ref": "no_ref_specified"
}
}
]
}
How I am passing the request the ref value?
I tried all kind of combinations and I get errors.
I posted notification with diff ref. ref=test0099 and Now I see this:
{
"data": [
{
"time": "2014-12-09T08:00:00+0000",
"value": "3",
"breakdowns": {
"ref": "no_ref_specified"
}
},
{
"time": "2014-12-10T08:00:00+0000",
"value": "1",
"breakdowns": {
"ref": "test0099"
Maybe there is some bug over there?
thanks,
ray.
Edit:
Stating your findings
for some reason you cant notify with ref which is only numeric or start with numeric
Again, it still comes to down to file a bug.
From IRC, just stating that you should file a bug.
As long as the app is a canvas app and a game you should be able to see the desired response
HTTP POST /13608786/notifications with App Token and
template=Yo this is a test
ref=test0099
You should receive the notification
And be redirected to the canvas page
https://apps.facebook.com/philippeharewood/?fb_source=notification&fb_ref=test0099&ref=notif&notif_t=app_notification
The insights will reflect the same
HTTP GET /app/app_insights/app_notification_impressions?breakdowns[0]=ref
{
"data": [
{
"time": "2014-12-10T08:00:00+0000",
"value": "1",
"breakdowns": {
"ref": "test0099"
}
}
]
}
This issue apparently to be a bug.
I have assigned this into facebook developers and now they taking care of it.
tracking at: https://developers.facebook.com/bugs/1512426199028095