Skip to content

Commit 88b6d54

Browse files
committed
Merge branch 'develop'
2 parents 9a164fb + dfe3b18 commit 88b6d54

File tree

2 files changed

+117
-85
lines changed

2 files changed

+117
-85
lines changed

Makefile

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Versioning
22
version_full ?= $(shell $(MAKE) --silent version-full)
33
version_small ?= $(shell $(MAKE) --silent version)
4-
# DevTunnel configuration
4+
# Dev tunnels configuration
55
tunnel_name := call-center-ai-$(shell hostname | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
66
tunnel_url ?= $(shell res=$$(devtunnel show $(tunnel_name) | grep -o 'http[s]*://[^"]*' | xargs) && echo $${res%/})
77
# App location
@@ -121,6 +121,22 @@ dev:
121121
VERSION=$(version_full) PUBLIC_DOMAIN=$(tunnel_url) func start
122122

123123
deploy:
124+
$(MAKE) deploy-bicep
125+
126+
@echo "💤 Wait 10 secs for output to be available..."
127+
sleep 10
128+
129+
@echo "🛠️ Deploying Function App..."
130+
func azure functionapp publish $(function_app_name) \
131+
--build local \
132+
--build-native-deps \
133+
--python
134+
135+
@echo "🚀 Call Center AI is running on $(app_url)"
136+
137+
@$(MAKE) deploy-post
138+
139+
deploy-bicep:
124140
@echo "👀 Current subscription:"
125141
@az account show --query "{subscriptionId:id, subscriptionName:name, tenantId:tenantId}" --output table
126142

@@ -137,20 +153,7 @@ deploy:
137153
--template-file bicep/main.bicep \
138154
--name $(name_sanitized)
139155

140-
@echo "💤 Wait 10 secs for output to be available..."
141-
sleep 10
142-
143-
@echo "🛠️ Deploying Function App..."
144-
func azure functionapp publish $(function_app_name) \
145-
--build local \
146-
--build-native-deps \
147-
--python
148-
149-
@echo "🚀 Call Center AI is running on $(app_url)"
150-
151-
@$(MAKE) post-deploy name=$(name_sanitized)
152-
153-
post-deploy:
156+
deploy-post:
154157
@$(MAKE) copy-resources \
155158
name=$(blob_storage_public_name)
156159

README.md

Lines changed: 99 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ sequenceDiagram
243243

244244
## Deployment
245245

246-
Some prerequisites are needed to deploy the solution.
246+
### Prerequisites
247247

248248
[Prefer using GitHub Codespaces for a quick start.](https://codespaces.new/microsoft/call-center-ai?quickstart=1) The environment will setup automatically with all the required tools.
249249

@@ -258,65 +258,97 @@ For other systems, make sure you have the following installed:
258258
- [Azure Functions Core Tools](https://github.com/Azure/azure-functions-core-tools?tab=readme-ov-file#installing)
259259
- [Twilio CLI](https://www.twilio.com/docs/twilio-cli/getting-started/install) (optional)
260260

261-
### Remote (on Azure)
261+
Then, Azure resources are needed:
262+
263+
#### 1. [Create a new resource group](https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/manage-resource-groups-portal)
264+
265+
- Prefer to use lowercase and no special characters other than dashes (e.g. `ccai-customer-a`)
262266

263-
Steps to deploy:
267+
#### 2. [Create a Communication Services resource](https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/create-communication-resource?tabs=linux&pivots=platform-azp)
264268

265-
1. [Create a new resource group](https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/manage-resource-groups-portal)
269+
- Same name as the resource group
270+
- Enable system managed identity
266271

267-
- Prefer to use lowercase and no special characters other than dashes (e.g. `ccai-customer-a`)
272+
#### 3. [Buy a phone number](https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/telephony/get-phone-number?tabs=linux&pivots=platform-azp-new)
268273

269-
2. [Create a Communication Services resource](https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/create-communication-resource?tabs=linux&pivots=platform-azp)
274+
- From the Communication Services resource
275+
- Allow inbound and outbound communication
276+
- Enable voice (required) and SMS (optional) capabilities
270277

271-
- Same name as the resource group
272-
- Enable system managed identity
278+
Now that the prerequisites are configured (local + Azure), the deployment can be done.
279+
280+
### Remote (on Azure)
273281

274-
3. [Buy a phone number](https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/telephony/get-phone-number?tabs=linux&pivots=platform-azp-new)
282+
#### 1. Create the light config file
275283

276-
- From the Communication Services resource
277-
- Allow inbound and outbound communication
278-
- Enable voice (required) and SMS (optional) capabilities
284+
File is named `config.yaml`:
279285

280-
4. Create a local `config.yaml` file
286+
```yaml
287+
# config.yaml
288+
conversation:
289+
initiate:
290+
# Phone number the bot will transfer the call to if customer asks for a human agent
291+
agent_phone_number: "+33612345678"
292+
bot_company: Contoso
293+
bot_name: Amélie
294+
lang: {}
295+
296+
communication_services:
297+
# Phone number purshased from Communication Services
298+
phone_number: "+33612345678"
299+
300+
sms: {}
301+
302+
prompts:
303+
llm: {}
304+
tts: {}
305+
```
281306
282-
```yaml
283-
# config.yaml
284-
conversation:
285-
initiate:
286-
# Phone number the bot will transfer the call to if customer asks for a human agent
287-
agent_phone_number: "+33612345678"
288-
bot_company: Contoso
289-
bot_name: Amélie
290-
lang: {}
307+
#### 2. Connect to your Azure environment
291308
292-
communication_services:
293-
# Phone number purshased from Communication Services
294-
phone_number: "+33612345678"
309+
```zsh
310+
az login
311+
```
295312

296-
sms: {}
313+
#### 3. Run deployment automation
297314

298-
prompts:
299-
llm: {}
300-
tts: {}
301-
```
315+
```zsh
316+
make deploy name=my-rg-name
317+
```
302318

303-
5. Connect to your Azure environment (e.g. `az login`)
304-
6. Run deployment automation with `make deploy name=my-rg-name`
319+
- Wait for the deployment to finish
305320

306-
- Wait for the deployment to finish
321+
#### 4. [Create a AI Search resource](https://learn.microsoft.com/en-us/azure/search/search-create-service-portal)
307322

308-
7. [Create a AI Search resource](https://learn.microsoft.com/en-us/azure/search/search-create-service-portal)
323+
- An index named `trainings`
324+
- A semantic search configuration on the index named `default`
309325

310-
- An index named `trainings`
311-
- A semantic search configuration on the index named `default`
326+
#### 5. Get the logs
312327

313-
Get the logs with `make logs name=my-rg-name`.
328+
```zsh
329+
make logs name=my-rg-name
330+
```
314331

315332
### Local (on your machine)
316333

317-
#### Prerequisites for local development
334+
#### 1. Create the full config file
335+
336+
> [!TIP]
337+
> To use a Service Principal to authenticate to Azure, you can also add the following in a `.env` file:
338+
>
339+
> ```dotenv
340+
> AZURE_CLIENT_ID=xxx
341+
> AZURE_CLIENT_SECRET=xxx
342+
> AZURE_TENANT_ID=xxx
343+
> ```
318344
319-
Place a file called `config.yaml` in the root of the project with the following content:
345+
> [!TIP]
346+
> If you already deployed the application to Azure and if it is working, you can:
347+
>
348+
> - Copy the configuration from the Azure Function App to your local machine by using the content of the `CONFIG_JSON` application setting
349+
> - Then convert it to YAML format
350+
351+
File is named `config.yaml`:
320352
321353
```yaml
322354
# config.yaml
@@ -372,52 +404,49 @@ ai_translation:
372404
endpoint: https://xxx.cognitiveservices.azure.com
373405
```
374406
375-
To use a Service Principal to authenticate to Azure, you can also add the following in a `.env` file:
407+
#### 2. Run the deployment automation
376408

377-
```dotenv
378-
AZURE_CLIENT_ID=xxx
379-
AZURE_CLIENT_SECRET=xxx
380-
AZURE_TENANT_ID=xxx
409+
```zsh
410+
make deploy-bicep deploy-post name=my-rg-name
381411
```
382412

383-
To override a specific configuration value, you can also use environment variables. For example, to override the `llm.fast.endpoint` value, you can use the `LLM__FAST__ENDPOINT` variable:
413+
- This will deploy the Azure resources without the API server, allowing you to test the bot locally
414+
- Wait for the deployment to finish
384415

385-
```dotenv
386-
LLM__FAST__ENDPOINT=https://xxx.openai.azure.com
387-
```
416+
#### 3. Initialize local function config
388417

389-
Then run:
418+
Copy `local.example.settings.json` to `local.settings.json`, then fill the required fields:
390419

391-
```bash
392-
# Install dependencies
393-
make install
394-
```
420+
- `APPLICATIONINSIGHTS_CONNECTION_STRING`, as the connection string of the Application Insights resource
421+
- `AzureWebJobsStorage`, as the connection string of the Azure Storage account
395422

396-
Also, a public file server is needed to host the audio files. Upload the files with `make copy-resources name=my-rg-name` (`my-rg-name` is the storage account name), or manually.
423+
#### 4. Connect to Azure Dev tunnels with `devtunnel login`, then run it with `make tunnel`
397424

398-
For your knowledge, this `resources` folder contains:
425+
> [!IMPORTANT]
426+
> Tunnel requires to be run in a separate terminal, because it needs to be running all the time
399427
400-
- Audio files (`xxx.wav`) to be played during the call
401-
- [Lexicon file (`lexicon.xml`)](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/speech-synthesis-markup-pronunciation#custom-lexicon) to be used by the bot to understand the company products (note: any change [makes up to 15 minutes](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/speech-synthesis-markup-pronunciation#custom-lexicon-file) to be taken into account)
428+
#### 5. Iterate quickly with the code
402429

403-
#### Run
430+
> [!NOTE]
431+
> To override a specific configuration value, you can use environment variables. For example, to override the `llm.fast.endpoint` value, you can use the `LLM__FAST__ENDPOINT` variable:
432+
>
433+
> ```dotenv
434+
> LLM__FAST__ENDPOINT=https://xxx.openai.azure.com
435+
> ```
404436
405-
Finally, run:
437+
> [!NOTE]
438+
> Also, `local.py` script is available to test the application without the need of a phone call (= without Communication Services). Run the script with:
439+
>
440+
> ```bash
441+
> python3 -m tests.local
442+
> ```
406443
407-
```bash
408-
# Start the local API server
444+
```zsh
409445
make dev
410446
```
411447
412-
#### Debug
413-
414-
Breakpoints can be added in the code to debug the application with your favorite IDE.
415-
416-
Also, `local.py` script is available to test the application without the need of a phone call (= without Communication Services). Run the script with:
417-
418-
```bash
419-
python3 -m tests.local
420-
```
448+
- Code is automatically reloaded on file changes, no need to restart the server
449+
- The API server is available at `http://localhost:8080`
421450

422451
## Advanced usage
423452

0 commit comments

Comments
 (0)