Prompt
How do I build a transcription workflow with upload, processing, and webhook callbacks?
Latest observation
A solid transcription workflow usually has 4 parts:
- Client uploads audio/video
- Your backend creates a transcription job
- A worker processes the file asynchronously
- A webhook notifies you when the transcript is ready
Here’s a practical pattern you can use.
1) Recommended architecture
Flow:
- User uploads a file to your app
- Your backend stores the file or a reference to it
- Backend creates a transcription job record with status
queued - A worker picks up the job
- Worker sends the file to the transcription service
- Service returns a job ID
- When processing completes, the service calls your webhook
- Your backend verifies the webhook and updates the job to
completedorfailed - Your frontend polls job status or uses websockets/SSE for live updates
2) Core components
Upload endpoint
Accept a file upload or a pre-signed URL upload.
Typical choices:
- Direct multipart upload to your API
- Pre-signed cloud storage upload to S3/GCS/Azure Blob, then send the file URL to your backend
Best practice:
- Use object storage rather than storing large media files in your app server
- Save metadata in your database
Job table
Store job state in a database.
Example fields:
iduser_idfile_urlstatus(queued,processing,completed,failed)external_job_idtranscript_urlerror_messagecreated_atupdated_at
Processing worker
Use a queue system:
- Celery, RQ, Sidekiq, BullMQ, Hangfire, etc.
The worker should:
- Fetch job from queue
- Call transcription API
- Store external job ID
- Update status to
processing
Webhook endpoint
Expose a public endpoint like:
POST /webhooks/transcription
It should:
- Verify signature/authentication
- Parse event
- Update database
- Handle retries idempotently
3) Example workflow
Step A: Upload file
Frontend uploads audio:
POST /api/transcriptions
Content-Type: multipart/form-data
Backend:
- saves file to S3
- creates DB row:
status = queuedfile_url = s3://...
Returns:
{
"job_id": "abc123",
"status": "queued"
}
Step B: Queue processing
Backend enqueues abc123 for worker processing.
Step C: Worker submits transcription request
Worker calls transcription provider:
{
"audio_url": "https://storage.example.com/file.wav",
"webhook_url": "https://yourapp.com/webhooks/transcription",
"metadata": {
"job_id": "abc123"
}
}
Provider responds with:
{
"provider_job_id": "prov_789",
"status": "processing"
}
Backend saves provider_job_id.
Step D: Webhook callback
Later provider sends:
{
"event": "transcription.completed",
"provider_job_id": "prov_789",
"job_id": "abc123",
"transcript": "Hello world...",
"confidence": 0.98
}
Your webhook:
- verifies the request
- looks up job by
provider_job_id - marks
completed - stores transcript
4) Webhook endpoint best practices
Verify authenticity
Use one of:
- HMAC signature header
- shared secret
- JWT
- provider-specific signature verification
Example:
X-Signature: sha256=...- compare against HMAC of request body using your secret
Make webhook handling idempotent
Webhook providers may retry deliveries.
Store:
- event ID
- processed timestamp
If the same event arrives twice, ignore duplicates.
Return fast
Do minimal work in the webhook handler:
- verify
- persist
- enqueue any heavy processing
Return 200 OK quickly.
5) Status model
A simple state machine:
uploadedqueuedprocessingcompletedfailed
Optional:
canceledexpired
6) Suggested API endpoints
Create transcription job
POST /api/transcriptions
Check job status
GET /api/transcriptions/{job_id}
List user jobs
GET /api/transcriptions
Webhook callback
POST /webhooks/transcription
7) Minimal backend pseudocode
Create job
def create_transcription(file):
file_url = upload_to_storage(file)
job = db.insert({
"status": "queued",
"file_url": file_url
})
queue.enqueue("transcribe", job.id)
return job
Worker
def transcribe_job(job_id):
job = db.get(job_id)
job.status = "processing"
db.save(job)
resp = transcription_api.submit(
audio_url=job.file_url,
webhook_url="https://yourapp.com/webhooks/transcription",
metadata={"job_id": job.id}
)
job.external_job_id = resp["provider_job_id"]
db.save(job)
Webhook
def transcription_webhook(request):
verify_signature(request)
event = request.json
job = db.find_by_external_job_id(event["provider_job_id"])
if event["event"] == "transcription.completed":
job.status = "completed"
job.transcript = event["transcript"]
elif event["event"] == "transcription.failed":
job.status = "failed"
job.error_message = event["error"]
db.save(job)
return {"ok": True}
8) Security and reliability checklist
- Use HTTPS everywhere
- Store files in secure object storage
- Validate file type and size on upload
- Set processing timeouts
- Use signed webhook requests
- Make webhook handlers idempotent
- Retry transient failures with backoff
- Log every state transition
- Garbage-collect old media and transcripts if needed
9) If you want a simpler implementation
If you’re just starting:
- Upload file to S3
- Create a database row
- Call transcription API synchronously from a background worker
- Use webhook only for completion notifications
That gives you:
- responsive uploads
- safe async processing
- reliable completion updates
10) Example end-to-end sequence
Client -> API: upload audio
API -> Storage: save file
API -> DB: create job (queued)
API -> Queue: enqueue job
Worker -> Transcription service: submit file URL + webhook URL
Service -> Worker: returns provider_job_id
Worker -> DB: save provider_job_id, set processing
Service -> Webhook: send completed event
Webhook -> DB: mark completed, save transcript
Client -> API: poll job status or receive update
If you want, I can also give you:
- a Node.js/Express example
- a Python/FastAPI example
- an AWS S3 + SQS + webhook reference architecture
- or a database schema + webhook signature verification example