JIRA Webhook Integration
Automatically create Credo AI use cases when Jira issues are created.
How It Works
Jira (Issue Created) ──▶ Your Webhook Endpoint ──▶ Credo AI (Use Case)
The Webhook Handler
When Jira creates an issue, it sends a POST request with the issue data. Your handler extracts the relevant fields and creates a use case:
- Python
- TypeScript
from fastapi import FastAPI, Request
from credoai import CredoAI, UseCaseCreate
app = FastAPI()
@app.post("/webhooks/jira")
async def jira_webhook(request: Request):
payload = await request.json()
# Only handle issue_created events
if payload.get("webhookEvent") != "jira:issue_created":
return {"message": "ignored"}
# Extract issue data
issue = payload["issue"]
jira_key = issue["key"]
summary = issue["fields"]["summary"]
description = issue["fields"].get("description", "")
# Create use case in Credo AI
client = CredoAI()
use_case = client.use_cases.create(
data=UseCaseCreate(
name=f"[{jira_key}] {summary}",
description=description,
)
)
return {"use_case_id": use_case.id}
import express from 'express';
import { createCredoAIClient } from '@credo-ai/sdk';
const app = express();
app.use(express.json());
const client = createCredoAIClient('your-tenant');
app.post('/webhooks/jira', async (req, res) => {
const payload = req.body;
// Only handle issue_created events
if (payload.webhookEvent !== 'jira:issue_created') {
return res.json({ message: 'ignored' });
}
// Extract issue data
const issue = payload.issue;
const jiraKey = issue.key;
const summary = issue.fields.summary;
const description = issue.fields.description ?? '';
// Create use case in Credo AI
const { data, error } = await client.useCases.create({
name: `[${jiraKey}] ${summary}`,
description,
});
if (error) {
return res.status(error.status).json(error.body);
}
res.json({ use_case_id: data.id });
});
app.listen(5000);
Testing Locally
- Install dependencies and run your app:
- Python
- TypeScript
pip install fastapi uvicorn pycredoai
uvicorn main:app --port 5000
npm install express @credo-ai/sdk
npx tsx main.ts
-
Expose with ngrok:
ngrok http 5000 -
Test with curl:
curl -X POST http://localhost:5000/webhooks/jira \-H "Content-Type: application/json" \-d '{"webhookEvent":"jira:issue_created","issue":{"key":"TEST-1","fields":{"summary":"Test"}}}'
Configure Jira
- Go to Jira Settings > System > Webhooks
- Create webhook with URL:
https://your-domain.com/webhooks/jira - Select Issue created event
Production
Deploy your app to any hosting platform (Railway, Render, etc.) and point your Jira webhook to the public URL.
You can also deploy a webhook handler to AWS Lambda, Cloud Run, etc. and point your Jira webhook to the public URL.
For security, verify the webhook signature and use environment variables for credentials.