# doorman-client

This is the Twilio Function that is triggered when receiving a call from a buzzer. In short, it's job is to talk to the doorman-api to determine the buzzers configuration and to check if the door should be auto unlocked, or dial through to a phone number on file.

## dependency services
This service has a hard dependency on doorman-api, specifically on the /api/door/info Function. if this is down, the buzzer client will not work.

It has soft dependencies on self hosted monitoring solutions:
- Pushgateway (prometheus metrics)
- Loki (logs)

## running locally

NOTE: You'll want to make sure that doorman-api is also running locally first. .env.local is configured to use http://localhost:8080 as the doorman-api endpoint

First install the necessary dependencies `bun install`.

Run the doorman-client

`bun run start`

To test doorman-client head over to 

`http://localhost:4500/buzzer-activated?From=6133163433`

This will simulate a buzzer calling from 6133163433 (the test buzzer)

If you let it poll for 10s then it should respond with Twilio xml saying to dial fallback numbers.

If doorman-api is not running, it would always return with a `<Reject/>`

## adding new audio assets

Generate using this website: https://ttsmp3.com/

select US English / Salli for consistency with the voice.

After generated, go to this website: https://www.mp3louder.com/

boost the audio 3db and save it

put it in the doorman-client/assets folder with suffix `.protected.mp3`