GitHubIssueCommenter
Post comments to GitHub issues.
Basic Information
- Type:
haystack_integrations.components.connectors.github.issue_commenter.GitHubIssueCommenter - Components it can connect with:
Input: Receives issue URL and comment text as input.- Generators: Receives generated comment text from LLM generators.
GitHubIssueViewer: Works alongside to read issues before commenting.
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| url | str | GitHub issue URL. | |
| comment | str | Comment text to post. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| success | bool | Whether the comment was posted successfully. |
Overview
GitHubIssueCommenter posts comments to GitHub issues. It takes a GitHub issue URL and comment text, then posts the comment to the specified issue using the GitHub API.
This component is useful for building automated pipelines that respond to GitHub issues, such as issue triage bots or automated support systems.
Authorization
To use this component, you must create a secret with your GitHub personal access token with write access to the repository you want to comment on. Type GITHUB_TOKEN as the secret key. For detailed instructions on creating secrets, see Create Secrets.
Usage Example
This pipeline uses GitHubIssueCommenter to post AI-generated responses to issues:
components:
GitHubIssueViewer:
type: haystack_integrations.components.connectors.github.issue_viewer.GitHubIssueViewer
init_parameters:
github_token:
type: env_var
env_vars:
- GITHUB_TOKEN
strict: false
raise_on_failure: true
retry_attempts: 2
ChatPromptBuilder:
type: haystack.components.builders.chat_prompt_builder.ChatPromptBuilder
init_parameters:
template:
- role: system
content: "You are a helpful assistant that responds to GitHub issues. Provide a helpful and professional response to the issue."
- role: user
content: "Issue content:\n{% for doc in documents %}\n{{ doc.content }}\n{% endfor %}\n\nGenerate a helpful response to this issue."
OpenAIChatGenerator:
type: haystack.components.generators.chat.openai.OpenAIChatGenerator
init_parameters:
api_key:
type: env_var
env_vars:
- OPENAI_API_KEY
strict: false
model: gpt-4o-mini
OutputAdapter:
type: haystack.components.converters.output_adapter.OutputAdapter
init_parameters:
template: '{{ replies[0].text }}'
output_type: str
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
connections:
- sender: GitHubIssueViewer.documents
receiver: ChatPromptBuilder.documents
- sender: ChatPromptBuilder.prompt
receiver: OpenAIChatGenerator.messages
- sender: OpenAIChatGenerator.replies
receiver: OutputAdapter.replies
- sender: OutputAdapter.output
receiver: GitHubIssueCommenter.comment
inputs:
url:
- GitHubIssueViewer.url
- GitHubIssueCommenter.url
outputs:
success: GitHubIssueCommenter.success
max_runs_per_component: 100
metadata: {}
Parameters
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 for API authentication as a Secret. |
| raise_on_failure | bool | True | If True, raises exceptions on API errors. |
| retry_attempts | int | 2 | Number of retry attempts for failed requests. |
Run Method Parameters
These are the parameters you can configure for the run() method. You can pass these parameters at query time through the API, in Playground, or when running a job.
| Parameter | Type | Default | Description |
|---|---|---|---|
| url | str | GitHub issue URL. | |
| comment | str | Comment text to post. |
Was this page helpful?