Skip to content

how to comment on a discussion with probot ? #1614

Answered by gr2m
anwarghammam asked this question in Q&A
Discussion options

You must be logged in to vote

I don't think there are any REST APIs for discussions yet. You can use GraphQL though, e.g. to create a discussion you can use the addDiscussionComment mutation

const query = `
  mutation ($discussionId: ID!, $body: String!) {
    addDiscussionComment(input: {discussionId: $discussionId, body: $body}) {
      comment {
        url
      }
    }
  }
`;

octokit.graphql(query, {
  discussionId: "<discussion node id>",
  body: "Discussion comment text",
});

You'll need to retrieve the node ID for the discussion first, the query for that could look like this

query ($owner:String!,$repo:String!,$discussionNumber:Int!){
  repository(owner:$owner,name:$repo) {
    discussion(number:$discussionNu…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@anwarghammam
Comment options

@gr2m
Comment options

Answer selected by gr2m
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants