BotBuilderCommunity / botbuilder-community-dotnet

Part of the Bot Builder Community Project. Repository for extensions for the Bot Builder .NET SDK, including middleware, dialogs, recognizers and more.
MIT License
281 stars 173 forks source link

Webex Teams Adapter with Bot Framework Composer does not work #506

Open RamkumarManavalan opened 2 years ago

RamkumarManavalan commented 2 years ago

Hi Team,

I have developed a bot using Bot Framework Composer (v2.1.2 dotnet/C#) and deployed the same as Azure Bot Service. I have enabled the channels such as Skype, Teams and Slack in the Azure portal and they all work well. Now, I need to surface my bot in Webex teams too. I looked at a few Microsoft and Webex pages and did the following steps, but I am not able to succeed. I know I am missing some important step or doing something incorrectly. Please help.

Created a Webex bot app and obtained the bot's id and access token.
Added the bot in my webex space (web).
Set up a webhook using the POST API (https://webexapis.com/v1/webhooks) by passing the below:
{
"name": "<>",
"targetUrl": "https://<>.azurewebsites.net/api/webex",
"resource": "messages",
"event": "created",
"secret": "<>"
}
In the bot framework composer, I installed the nuget package 'Microsoft.Bot.Builder.Adapters.Webex'. And, in the External Connections section of the configuration page, I edited the configuration values of Webex connection as below:

Access Token: The token that I obtained in step 

https://github.com/microsoft/BotFramework-Composer/pull/1.
Public Address: https://<>.azurewebsites.net/
Secret: <> (that I passed in the request of Webhook creation API)
Webhook name: <> (that I passed in the request of Webhook creation API)
Route: webex

But I get no response from the bot for any message that I send in webex to this bot.

I wanted to do some troubleshooting and hence used the local bot server and exposed the port through ngrok. I configured this ngork public URL as the WebExPublicAddress in Composer and also in the webhook (targetUrl with /api/webex suffixed). Whenever I send a message in webex, ngrok receives it, but reports 500 internal server error. I am not able to view any other logs of either ngrok or the composer.

I guess the issue could be around any of these:

the way I use secret in the Composer Configuration
the way I use WebExPublicAddress in the Composer Configuration
Some additional code required in the composer's startup.cs

Please advise.

RamkumarManavalan commented 2 years ago

Team, any update on this? I am blocked. I had raised this ticket with Microsoft Bot Framework first, but they advised me to raise in this project. Please help.

RamkumarManavalan commented 2 years ago

Team, any help?

RamkumarManavalan commented 2 years ago

I got this working, after doing the below. Found this by myself, after a lot of troubleshooting and test combinations.

appsettings.json: { ... "runtimeSettings": { "adapters": [ { "name": "Microsoft.WebexAdapter", "enabled": true, "route": "webex", "type": "Bot.Builder.Community.Adapters.Webex.WebexAdapter" } ], ... "components": [ { "name": "Bot.Builder.Community.Adapters.Webex", "settingsPrefix": "Bot.Builder.Community.Adapters.Webex" } ], ... } ... "WebexAccessToken": "xxxxx", "WebexPublicAddress": "https://webexapis.com/v1/", "WebexSecret": "xxxxx", "WebexWebhookName": "xxxxx", ... }

Startup.cs: public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddNewtonsoftJson(options => { options.SerializerSettings.MaxDepth = 128; //HttpHelper.BotMessageSerializerSettings.MaxDepth; }); services.AddSingleton<IBotFrameworkHttpAdapter, WebexAdapter>(); .... }

I could not include the services.AddMvc().SetCompatibilityVersion and services.AddTransient method calls in the function above. But these were recommended in the README.

Please review and let me know if the above is fine.