Composio Jira integration guide
Quick answer
Use the
composio_openai package to obtain Jira tools and then call the Jira API via OpenAI chat completions with the tools parameter. Authenticate with your API keys and handle tool calls to automate Jira tasks seamlessly.PREREQUISITES
Python 3.8+OpenAI API key (free tier works)Composio API keypip install openai>=1.0 composio-core composio-openai
Setup
Install the required packages and set environment variables for your API keys.
- Install packages:
openai,composio-core, andcomposio-openai. - Set environment variables
OPENAI_API_KEYandCOMPOSIO_API_KEY.
pip install openai>=1.0 composio-core composio-openai output
Collecting openai Collecting composio-core Collecting composio-openai Successfully installed openai composio-core composio-openai
Step by step
This example shows how to get Jira tools from Composio, send a chat completion request with Jira commands, and handle the tool calls to perform Jira actions.
import os
import json
from openai import OpenAI
from composio_openai import ComposioToolSet, Action
# Initialize Composio toolset with your Composio API key
toolset = ComposioToolSet(api_key=os.environ["COMPOSIO_API_KEY"])
# Get Jira-related tools from Composio
jira_tools = toolset.get_tools(actions=[Action.JIRA_CREATE_ISSUE, Action.JIRA_SEARCH_ISSUES])
# Initialize OpenAI client with your OpenAI API key
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
# Compose chat messages to create a Jira issue
messages = [
{"role": "user", "content": "Create a Jira issue in project TEST with summary 'Bug in login' and description 'Login fails with 500 error'"}
]
# Call chat completion with Jira tools
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=messages,
tools=jira_tools
)
print("Assistant reply:", response.choices[0].message.content)
# Check if the model requested a tool call
if response.choices[0].finish_reason == "tool_calls":
tool_call = response.choices[0].message.tool_calls[0]
# Parse the tool call arguments
args = json.loads(tool_call.function.arguments)
# Handle the tool call via Composio toolset
tool_response = toolset.handle_tool_calls(response)
print("Tool response:", tool_response)
else:
print("No tool call requested.") output
Assistant reply: Creating Jira issue in project TEST with summary 'Bug in login'.
Tool response: {'issueKey': 'TEST-123', 'status': 'created'} Common variations
You can use async calls with asyncio and the OpenAI async client. Also, switch models like gpt-4o for more capability. Customize Jira actions by changing Action enums or adding more tools.
import asyncio
import os
import json
from openai import OpenAI
from composio_openai import ComposioToolSet, Action
async def main():
toolset = ComposioToolSet(api_key=os.environ["COMPOSIO_API_KEY"])
jira_tools = toolset.get_tools(actions=[Action.JIRA_CREATE_ISSUE])
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
messages = [
{"role": "user", "content": "Create a Jira issue in project TEST with summary 'Async issue'"}
]
response = await client.chat.completions.create(
model="gpt-4o",
messages=messages,
tools=jira_tools
)
print("Assistant reply:", response.choices[0].message.content)
if response.choices[0].finish_reason == "tool_calls":
tool_call = response.choices[0].message.tool_calls[0]
args = json.loads(tool_call.function.arguments)
tool_response = toolset.handle_tool_calls(response)
print("Tool response:", tool_response)
else:
print("No tool call requested.")
if __name__ == "__main__":
asyncio.run(main()) output
Assistant reply: Creating Jira issue in project TEST with summary 'Async issue'.
Tool response: {'issueKey': 'TEST-124', 'status': 'created'} Troubleshooting
- If you see
401 Unauthorized, verify yourOPENAI_API_KEYandCOMPOSIO_API_KEYenvironment variables are set correctly. - If no tool calls are triggered, ensure you passed the
toolsparameter and your prompt clearly requests Jira actions. - For JSON parsing errors on tool calls, validate the tool call arguments format and update
composio-openaito the latest version.
Key Takeaways
- Use
ComposioToolSetto fetch Jira tools and pass them viatoolsin chat completions. - Always handle
tool_callsin the response to execute Jira API actions programmatically. - Set environment variables
OPENAI_API_KEYandCOMPOSIO_API_KEYsecurely for authentication. - Async usage with OpenAI SDK is supported for scalable Jira automation workflows.
- Clear prompts and correct tool usage ensure smooth Jira integration with Composio.