{"id":20461513,"url":"https://github.com/assemblyai-solutions/assemblyai_webhook_example","last_synced_at":"2026-05-26T23:12:09.143Z","repository":{"id":156541312,"uuid":"570633212","full_name":"AssemblyAI-Solutions/assemblyai_webhook_example","owner":"AssemblyAI-Solutions","description":"An example deployment using Cloudflare Tunnels as a replacement for deploying an endpoint on a Public IP address.","archived":false,"fork":false,"pushed_at":"2023-04-26T17:32:49.000Z","size":1277,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-16T00:37:45.713Z","etag":null,"topics":["deployments"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AssemblyAI-Solutions.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-25T17:11:14.000Z","updated_at":"2023-06-28T16:06:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"381254f3-90b2-4985-a9d7-10deac424f10","html_url":"https://github.com/AssemblyAI-Solutions/assemblyai_webhook_example","commit_stats":null,"previous_names":["assemblyai-solutions/assemblyai_webhook_example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AssemblyAI-Solutions%2Fassemblyai_webhook_example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AssemblyAI-Solutions%2Fassemblyai_webhook_example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AssemblyAI-Solutions%2Fassemblyai_webhook_example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AssemblyAI-Solutions%2Fassemblyai_webhook_example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AssemblyAI-Solutions","download_url":"https://codeload.github.com/AssemblyAI-Solutions/assemblyai_webhook_example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242017970,"owners_count":20058524,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deployments"],"created_at":"2024-11-15T12:25:59.348Z","updated_at":"2025-12-04T01:15:40.943Z","avatar_url":"https://github.com/AssemblyAI-Solutions.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## [AssembylAI Webhooks](https://www.assemblyai.com/docs/walkthroughs#using-webhooks)\n\n### [Video Tutorial](https://www.loom.com/share/e046f0b2ad2f4a16b51f82d45295d58c)\n\n### Cloudflare Tunnels\n###### Note: Cloudflare is required to be DNS provider\n- [How do they work](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps)\n- [Pricing](https://blog.cloudflare.com/tunnel-for-everyone/)\n- [Setup \u0026 Installation](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide/remote/)\n\n### Code Example\n\n#### ```upload.py```\n```python\ndef main():\n    files = getFiles()\n    for file in files:\n        upload_response = uploadToAssemblyAI(file)\n        request_data = {\n            \"audio_url\": upload_response[\"upload_url\"],\n            \"webhook_url\": WEBHOOK_URL,\n        }\n        transcript_response = createNewTranscriptRequest(request_data)\n        print(transcript_response)\n```\n\n#### ```webhook.py```\n```python\n#fast api post route to receive webhook\n@app.post(\"/\")\nasync def webhook(request: Request): \n    ip = str(request.client.host)\n    if ip not in assembly_ip_address:\n        print(\"Unauthorized IP Address\")\n        print(ip)\n        return Response(status_code=401)\n    #get request body\n    body = await request.body()\n    #convert request body to json\n    body_json = body.decode('utf-8')\n    #load json into dictionary\n    body_dict = json.loads(body_json)\n    #get transcript id from dictionary\n    transcript_id = body_dict['transcript_id']\n    #get status from dictionary\n    status = body_dict['status']\n    #get timestamp\n    timestamp = datetime.now()\n    #get completed transcript from assemblyai\n    completed_transcript = getTranscript(transcript_id)\n    #save to database\n    #UUID | transcript_id | status | timestamp | assemblyai_response\n    saveToDatabase(transcript_id, status, timestamp, completed_transcript)\n    #return response 2XX\n    return Response(status_code=200)\n```\n- [Create a tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide/remote/#1-create-a-tunnel)\n\n### Deployment Example\n\nPrepare Linux Box (Ubuntu 22.04)\n\n1. ```sudo apt update -y```\n2. ```sudo apt install python3-pip```\n3. ```cd /opt```\n4. ```git clone https://github.com/GarvanD/assemblyai_webhook```\n    ##### Note: When Authenticating Github CLI, you must use an [Access Token](https://github.com/settings/tokens) as your password\n\nStart Upload Process\n\n1. Chage directory to /upload\n2. ```pip3 install -r requirements.txt```\n3. ```ASSEMBLY_API_KEY=YourAPIKey WEBHOOK_URL=YourWebhookURL python3 upload.py``` \n\nStart Webhook Process\n\n1. Change directory to /webhook\n2. ```pip3 install -r requirements.txt```\n3. ```ASSEMBLY_API_KEY=YourAPIKey uvicorn app.main:app --host 127.0.0.1 --port 8000```\n\n\n\n\n#### ```Authentication \u0026 Security```\n- [Whitelist AssemblyAI IP Address - Python](https://github.com/GarvanD/assemblyai_webhook/blob/main/webhook/app/main.py#L31)\n- [Whitelist AssemblyAI IP Address - Cloudflare](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide/remote/#3-connect-a-network)\n- [Secure VM with OS \u0026 Cloud Firewall](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/do-more-with-tunnels/secure-server/)\n- [Add Authorization Header](https://www.assemblyai.com/docs/walkthroughs#using-webhooks)\n\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassemblyai-solutions%2Fassemblyai_webhook_example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fassemblyai-solutions%2Fassemblyai_webhook_example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassemblyai-solutions%2Fassemblyai_webhook_example/lists"}