-
Notifications
You must be signed in to change notification settings - Fork 262
Description
Language
Javascript/Typescript
Version
latest
Description
I created a Teams bot app to handle inline image sent from users with teams-ai SDK. It works as expected in Teams client, however it doesn't work in Bot Framework Emulator and unhandled error is thrown:
[onTurnError] unhandled error: TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
Looks it's related to the implementation to check if content url starts with 'https://': https://github.com/microsoft/teams-ai/blob/8258ca0e2396c3f5bb376cdc62374b5cd11b5603/js/packages/teams-ai/src/TeamsAttachmentDownloader.ts#L76
In Bot Framework Emulator, the image is hosted from localhost with http endpoint:

In addition, I found TeamsAttachmentDownloader will try to get access token before downloading the attachment. When I test the bot app in Bot Framework Emulator with empty string of BOT_ID and BOT_PASSWORD, the step to get access token would be failed:
We may consider skipping to get access token if the BOT_ID is empty, similar to the implementation of botbuilder SDK.
Reproduction Steps
1. Create a Teams bot app with below code snippet.
const downloader = new TeamsAttachmentDownloader({
botAppId: process.env.BOT_ID,
botAppPassword: process.env.BOT_PASSWORD,
});
app.activity(ActivityTypes.Message, async (context: TurnContext, state: ApplicationTurnState) => {
const attachments = await downloader.downloadFiles(context, state);
await context.sendActivity(`you have uploaded ${attachments?.length ?? 0} attachments`);
});
2. Run the Teams bot app locally.
3. Test the bot app by uploading an image in Bot Framework Emulator.