## Conversão Fluxo N8N para Python (FastAPI) com Async

![Fluxo N8N para Python](./fluxo.png)

### Setup
```bash
# Linux ou Mac
virtualenv venv
source ./venv/bin/activate 
pip install -r requirements.txt

 # Windows
python -m venv .venv
source .venv/Scripts/activate
pip install -r requirements.txt
```
para sair do venv é deactivate
### Como Executar
uvicorn main:app --host 0.0.0.0 --port 8005

```bash
curl --location 'http://127.0.0.1:8000/transcreve-audios' \
--header 'Content-Type: application/json' \
--data-raw '
  {
    "headers": {
      "host": "webhook-ia.seudominio.com.br",
      "user-agent": "axios/1.7.2",
      "content-length": "15723",
      "accept": "application/json, text/plain, */*",
      "accept-encoding": "gzip, compress, deflate, br",
      "content-type": "application/json",
      "x-forwarded-for": "172.18.0.1",
      "x-forwarded-host": "webhook-ia.seudominio.com.br",
      "x-forwarded-port": "443",
      "x-forwarded-proto": "https",
      "x-forwarded-server": "a2e7d31228a0",
      "x-real-ip": "172.18.0.1"
    },
    "params": {},
    "query": {},
    "body": {
      "event": "messages.upsert",
      "instance": "FABIO",
      "data": {
        "key": {
          "remoteJid": "556181381868@s.whatsapp.net",
          "fromMe": false,
          "id": "93C8B072717FE29738BFC5E4E6D15DBF"
        },
        "pushName": "TESTE IMPACTEAI",
        "message": {
          "audioMessage": {
            "url": "https://mmg.whatsapp.net/v/t62.7117-24/33503277_1306283390777873_1084449934390411316_n.enc?ccb=11-4&oh=01_Q5AaIDrkuMTePOg9XqrA1ayzh-g8D6uyb3UYggo-7nQ954rq&oe=6733B14B&_nc_sid=5e03e0&mms3=true",
            "mimetype": "audio/ogg; codecs=opus",
            "fileSha256": "iBQQ1nLO01PmJG+rAfrLkAMXMOZ6hiwbSjx4taUMzdQ=",
            "fileLength": "10169",
            "seconds": 4,
            "ptt": true,
            "mediaKey": "c1PezCe6nVSaCdAwra4qjkvKmOQdse7TCYQKVL0CaDc=",
            "fileEncSha256": "58y+fn5kaSRN3Ysr6O0xHCHxXctbUUdRi0IlwtNQaCc=",
            "directPath": "/v/t62.7117-24/33503277_1306283390777873_1084449934390411316_n.enc?ccb=11-4&oh=01_Q5AaIDrkuMTePOg9XqrA1ayzh-g8D6uyb3UYggo-7nQ954rq&oe=6733B14B&_nc_sid=5e03e0",
            "mediaKeyTimestamp": "1728854871",
            "contextInfo": {
              "expiration": 7776000,
              "ephemeralSettingTimestamp": "1664312625",
              "entryPointConversionSource": "global_search_new_chat",
              "entryPointConversionApp": "whatsapp",
              "entryPointConversionDelaySeconds": 10,
              "disappearingMode": {
                "initiator": "CHANGED_IN_CHAT",
                "trigger": "UNKNOWN"
              }
            },
            "waveform": "AAAAAAAAAAAFCQIEAjRKYmJiWjtdXWFjTUFGKg4uUBdaVVQqTyVGTVBSNFdjWldJTVtXVlVZPVdbJDASFRgJAw=="
          },
          "messageContextInfo": {
            "deviceListMetadata": {
              "senderKeyHash": "0DqP6++CnEQUHg==",
              "senderTimestamp": "1728853603",
              "recipientKeyHash": "Zc6F2LFA8Au6Aw==",
              "recipientTimestamp": "1728500286"
            },
            "deviceListMetadataVersion": 2,
            "messageSecret": "9/SSQplA77ey/WtKk9vtfJWUnsJsa313Zbr7phUUR3s="
          },
          "base64": "[encoded data, 13560 characters]"
        },
        "contextInfo": {
          "expiration": 7776000,
          "ephemeralSettingTimestamp": "1664312625",
          "entryPointConversionSource": "global_search_new_chat",
          "entryPointConversionApp": "whatsapp",
          "entryPointConversionDelaySeconds": 10,
          "disappearingMode": {
            "initiator": "CHANGED_IN_CHAT",
            "trigger": "UNKNOWN"
          }
        },
        "messageType": "audioMessage",
        "messageTimestamp": 1728854881,
        "owner": "FABIO",
        "source": "android"
      },
      "destination": "https://webhook-ia.seudominio.com.br/webhook/transcreveaudios",
      "date_time": "2024-10-13T18:28:01.953Z",
      "sender": "556181381868@s.whatsapp.net",
      "server_url": "https://evolution-ia.seudominio.com.br",
      "apikey": "7lymwfyuwiwu369siwvvz"
    },
    "webhookUrl": "https://webhook-ia.seudominio.com.br/webhook/transcreveaudios",
    "executionMode": "production"
  }'

```
