BotBuilder-Samples icon indicating copy to clipboard operation
BotBuilder-Samples copied to clipboard

What is the correct method to create a CloudAdapter instance?

Open gleysonlf opened this issue 3 years ago • 4 comments

All Typescript samples follow the following pattern to instantiate a CloudAdapter where the mandatory parameter of type "Configuration" is passed a null value:

  1. Create a "credentialsFactory with ConfigurationServiceClientCredentialFactory;
  2. Creates a botFrameworkAuthentication with createBotFrameworkAuthenticationFromConfiguration passing as parameter "null" and the "credentialsFactory";
  3. Create an "adapter" with CloudAdapter passing as a parameter the "botFrameworkAuthentication";

What is the correct method to create a CloudAdapter instance?

Sample information

**1. Sample type: ** samples 2. Sample language: typescript 3. Sample name:

  • 00.empty-bot
  • 02.echo-bot
  • 03.welcome-users
  • 05.multi-turn-prompt
  • 06.using-cards
  • 16.proactive-messages
  • 50.teams-messaging-extensions-search
  • 51.teams-messaging-extensions-action
  • 57.teams-conversation-bot
  • 58.teams-start-new-thread-in-channel

To Reproduce

Steps to reproduce the behavior:

  1. Clone and install de solution according to instructions in the README
  2. Configure tsconfig.json with compiler options strict, noImplicitOverride, emitDecoratorMetadata and experimentalDecorators as true
  3. Build and run application

Expected behavior

Normal build and started application

Screenshots

image image image

gleysonlf avatar Jul 22 '22 15:07 gleysonlf

Hi @gleysonlf,

This is probably related to #3792. You can take a look at that one for inspiration for the moment, and I will see about having the TypeScript samples updated as well.

anishprasad01 avatar Jul 22 '22 19:07 anishprasad01

Hi @anishprasad01, thanks for your reply.

I've seen this commit with tweaks, but the parameter applied to the ConfigurationBotFrameworkAuthentication class constructor required BotOpenIdMetadata, OAuthApiEndpoint, ValidateAuthority, or even a ToChannelFromBotLoginUrl.

Once the ProcessEnv has been sent, I receive:

Type 'ProcessEnv' has no properties in common with type '{ BotOpenIdMetadata?: string | undefined; ChannelService?: string | undefined; OAuthApiEndpoint?: string | undefined; ValidateAuthority?: string | boolean | undefined; ToChannelFromBotLoginUrl?: string | undefined; ... 5 more ...; CallerId?: string | undefined; }'.

I tried to directly send an object like ConfigurationBotFrameworkAuthenticationOptions but no success. The app runs but does not connect.

index.ts

const botFrameworkAuthentication = new ConfigurationBotFrameworkAuthentication(
  {
    MicrosoftAppId: 'myString';
    MicrosoftAppPassword: 'myString';
    MicrosoftAppType: 'myString';
    MicrosoftAppTenantId: 'myString';
  } as ConfigurationBotFrameworkAuthenticationOptions
);

Bot Emulator:

POST 400 directline/conversations/<conversationId>/activities

Sending an empty object, I have the same result.

gleysonlf avatar Jul 23 '22 15:07 gleysonlf

Thanks, we'll investigate further.

anishprasad01 avatar Jul 25 '22 15:07 anishprasad01

Hello @gleysonlf the PR that addresses this issue has been merged. Could you please try the samples again?

munozemilio avatar Aug 10 '22 21:08 munozemilio

Hi @munozemilio, worked perfectly! Thanks!

gleysonlf avatar Aug 12 '22 15:08 gleysonlf

import {
    CloudAdapter,
    ConfigurationBotFrameworkAuthentication,
    ConfigurationBotFrameworkAuthenticationOptions
} from 'botbuilder';

const botFrameworkAuthentication = new ConfigurationBotFrameworkAuthentication(process.env as ConfigurationBotFrameworkAuthenticationOptions);
const adapter = new CloudAdapter(botFrameworkAuthentication);

gleysonlf avatar Aug 12 '22 15:08 gleysonlf