GitHubIssueCommenter
Post comments to GitHub issues from a pipeline using the GitHub API—useful for AI agents that respond to or triage issues automatically.
Key Features
- Posts a comment to any GitHub issue given its URL.
- Parses the repository owner, name, and issue number directly from the issue URL.
- Retries failed API requests automatically, with a configurable number of attempts.
- Resolves a
GITHUB_TOKENsecret at runtime, keeping credentials out of the pipeline YAML. - Returns a boolean indicating whether the comment was posted successfully.
- Also available as
GitHubIssueCommenterToolfor use with Haystack agents.
Configuration
- Store your GitHub personal access token as a secret named
GITHUB_TOKEN. For instructions, see Create Secrets. - Drag the
GitHubIssueCommentercomponent onto the canvas from the Component Library. - Click on the component to open the configuration panel.
- The token is read automatically from the
GITHUB_TOKENenvironment variable.
Connections
GitHubIssueCommenter receives a url (the full GitHub issue URL) and a comment (the text to post). It outputs a success boolean. You can connect an upstream prompt builder or LLM output to the comment input and use the success output to branch the pipeline.
Source Code
To check this component's source code, open issue_commenter.py in the Haystack Core Integrations repository.
Usage Examples
Basic Configuration
GitHubIssueCommenter:
type: haystack_integrations.components.connectors.github.issue_commenter.GitHubIssueCommenter
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: true
raise_on_failure: true
retry_attempts: 2
Using the Component in a Pipeline
This example shows a pipeline that reads a GitHub issue, generates a response with an LLM, and posts the reply as a comment.
# haystack-pipeline
components:
issue_viewer:
type: haystack_integrations.components.connectors.github.issue_viewer.GitHubIssueViewer
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: false
prompt_builder:
type: haystack.components.builders.chat_prompt_builder.ChatPromptBuilder
init_parameters:
template:
- role: user
content: "You are a helpful assistant. Read the issue and write a short, helpful comment:\n\n{{ documents[0].content }}"
required_variables:
- documents
llm:
type: haystack.components.generators.chat.openai.OpenAIChatGenerator
init_parameters:
model: gpt-4o-mini
issue_commenter:
type: haystack_integrations.components.connectors.github.issue_commenter.GitHubIssueCommenter
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: true
retry_attempts: 2
connections:
- sender: issue_viewer.documents
receiver: prompt_builder.documents
- sender: prompt_builder.prompt
receiver: llm.messages
- sender: llm.replies
receiver: issue_commenter.comment
inputs:
query:
- issue_viewer.url
- issue_commenter.url
outputs:
success: issue_commenter.success
max_runs_per_component: 100
metadata: {}
Parameters
Inputs
| Parameter | Type | Description |
|---|---|---|
url | str | Full GitHub issue URL (for example, https://github.com/owner/repo/issues/123). |
comment | str | Text of the comment to post. |
Outputs
| Parameter | Type | Description |
|---|---|---|
success | bool | True if the comment was posted successfully, False otherwise. |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
github_token | Secret | Secret.from_env_var("GITHUB_TOKEN") | GitHub personal access token used for API authentication. |
raise_on_failure | bool | True | If True, raises an exception on API errors. If False, returns False in success. |
retry_attempts | int | 2 | Number of retry attempts for failed API requests. |
Related Information
Was this page helpful?