Skip to content

Commit

Permalink
[JS] fix: local debug environment variables location in teams chef bo…
Browse files Browse the repository at this point in the history
…t sample (#2240)

## Linked issues

closes: #2241 

## Details

Provide a list of your changes here. If you are fixing a bug, please
provide steps to reproduce the bug.
1. Fix bug that debugging in test tool is not working after local
debugging.
  a. Clone the sample.
  b. Select "Debug (Edge)" and press "F5".
  c. Stop debugging and Select "Debug in Test Tool".
  d. The Test Tool will show authentication error.
2. Fix the outdated lines in README file.

#### Change details

Environment variables like bot id and password will be read from
.localConfigs in npm script.
So the env file update in teamsapp.local.yml should be ".localConfigs".
Writing to ".env" file will pollute the Test Tool environment.

> Describe your changes, with screenshots and code snippets as
appropriate

**code snippets**:

**screenshots**:

## Attestation Checklist

- [ ] My code follows the style guidelines of this project

- I have checked for/fixed spelling, linting, and other errors
- I have commented my code for clarity
- I have made corresponding changes to the documentation (updating the
doc strings in the code is sufficient)
- My changes generate no new warnings
- I have added tests that validates my changes, and provides sufficient
test coverage. I have tested with:
  - Local testing
  - E2E testing in Teams
- New and existing unit tests pass locally with my changes

### Additional information

> Feel free to add other relevant information below

---------

Co-authored-by: Corina <[email protected]>
  • Loading branch information
tecton and corinagum authored Jan 8, 2025
1 parent e61f929 commit 3d26bea
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions js/samples/04.ai-apps/a.teamsChefBot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ If you are using Azure OpenAI then follow these steps:
AZURE_OPENAI_ENDPOINT: ${{SECRET_AZURE_OPENAI_ENDPOINT}}
```
- Open `./infra/azure.bicep` and comment out lines 72-75 and uncomment lines 76-83.
- Open `./infra/azure.parameters.json` and replace lines 20-22 with:
- Open `./infra/azure.bicep` and comment out lines of 'OPENAI_KEY' section and uncomment lines of 'AZURE_OPENAI_KEY' and 'AZURE_OPENAI_ENDPOINT' sections.
- Open `./infra/azure.parameters.json` and replace lines of "openAIKey" section with:

```json
"azureOpenAIKey": {
Expand Down
1 change: 0 additions & 1 deletion js/samples/04.ai-apps/a.teamsChefBot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"@microsoft/teams-ai": "~1.7.2",
"@microsoft/teams-js": "^2.32.0",
"botbuilder": "^4.23.1",
"dotenv": "^16.4.5",
"openai": "4.77.4",
"replace": "~1.2.0",
"restify": "~11.1.0",
Expand Down
11 changes: 3 additions & 8 deletions js/samples/04.ai-apps/a.teamsChefBot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

// Import required packages
import { config } from 'dotenv';
import * as path from 'path';
import * as restify from 'restify';

Expand All @@ -11,22 +10,18 @@ import * as restify from 'restify';
import { ConfigurationServiceClientCredentialFactory, MemoryStorage, TurnContext } from 'botbuilder';

import {
ActionPlanner,
AI,
Application,
ActionPlanner,
OpenAIModel,
PromptManager,
TurnState,
TeamsAdapter
TeamsAdapter,
TurnState
} from '@microsoft/teams-ai';

import { addResponseFormatter } from './responseFormatter';
import { VectraDataSource } from './VectraDataSource';

// Read botFilePath and botFileSecret from .env file.
const ENV_FILE = path.join(__dirname, '..', '.env');
config({ path: ENV_FILE });

// Create adapter.
// See https://aka.ms/about-bot-adapter to learn more about how bots work.
const adapter = new TeamsAdapter(
Expand Down
2 changes: 1 addition & 1 deletion js/samples/04.ai-apps/a.teamsChefBot/teamsapp.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ deploy:
# Provides the Teams Toolkit .env file values to the apps runtime so they can be accessed with `process.env`.
- uses: file/createOrUpdateEnvironmentFile
with:
target: ./.env
target: ./.localConfigs
envs:
BOT_ID: ${{BOT_ID}}
BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}}
Expand Down

0 comments on commit 3d26bea

Please sign in to comment.