File size: 748 Bytes
ecbc7d3
 
416b8fa
03d59b8
773f8fc
15a597c
 
 
03d59b8
773f8fc
ecbc7d3
03d59b8
d1c8710
03d59b8
773f8fc
ecbc7d3
03d59b8
 
d1c8710
773f8fc
 
ecbc7d3
03d59b8
416b8fa
 
 
ecbc7d3
577e00d
 
ecbc7d3
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import logging

from fastapi import FastAPI, Request
from fastapi.responses import FileResponse

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

app = FastAPI()


@app.get("/favicon.ico")
def favicon():
    return FileResponse("static/favicon.ico", media_type="image/x-icon")


@app.get("/")
@app.get("/home")
def home():
    return "Hello World"


@app.post("/webhook")
async def webhook(request: Request):
    data = await request.json()
    logger.info(data)

    intent_name = data['queryResult']['intent']['displayName']
    confidence_score = data['queryResult']['intentDetectionConfidence']

    return {"fulfillmentText": f"I am {round(confidence_score*100, 2)}% certain you are talking about {intent_name}."}