title: Value cannot be null. (Parameter 'clientSecret') when sending an activity from a bot
body: <p>We are trying to send an activity directly to our bot using the /api/messages endpoint for our bot. We are doing this so that we can have 2 Twilio numbers associated with our bot.  <br/>  <br/>
  First, we get an access token for the bot with the following code:</p>
  <pre><code>var authClient = new HttpClient();
  var authRequest = new HttpRequestMessage
  {
      Method = HttpMethod.Post,
      RequestUri = new Uri($&quot;https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token&quot;),
      Content = new StringContent($&quot;grant_type=client_credentials&amp;client_id={BOT_MIRCOSOFT_APP_ID}&amp;client_secret={BOT_MICROSOFT_APP_PASSWORD}&amp;scope=https%3A%2F%2Fapi.botframework.com%2F.default&quot;, Encoding.UTF8, &quot;application/x-www-form-urlencoded&quot;),
  };
  var authResponse = await authClient.SendAsync(authRequest).ConfigureAwait(false);
  </code></pre>
  <p>We then put this access token in the header of our api call to the bot and send the bot an activity through the /api/messages endpoint. The activity reaches the bot and everything works until we try to send an activity out from the bot. Our AdapterWithErrorHandler class catches an error with the message: Value cannot be null. (Parameter 'clientSecret'). We have searched thoroughly and could not find where this clientSecret variable is.  <br/>  <br/>
  How can we resolve this error so that we can send an activity out from our bot?</p>
  <p>Edit: Here is a sample project that throws this error using an unchanged standard echo bot and a console app. To get it to work you need to put in a valid app id and app password in the console app and the settings of the echo bot. <a href="https://github.com/andrew-j-frank/MicrosoftBotErrorSample" rel="nofollow noreferrer">https://github.com/andrew-j-frank/MicrosoftBotErrorSample</a></p>
  <p>Edit: Here is the stack trace for the error:</p>
  <pre><code>   at Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential..ctor(String clientId, String clientSecret)
     at Microsoft.Bot.Connector.Authentication.MicrosoftAppCredentials.&lt;BuildAuthenticator&gt;b__14_0()
     at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
     at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
     at System.Lazy`1.CreateValue()
     at System.Lazy`1.get_Value()
     at Microsoft.Bot.Connector.Authentication.AppCredentials.&lt;BuildIAuthenticator&gt;b__34_0()
     at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
     at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
     at System.Lazy`1.CreateValue()
     at System.Lazy`1.get_Value()
     at Microsoft.Bot.Connector.Authentication.AppCredentials.&lt;GetTokenAsync&gt;d__32.MoveNext()
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
     at Microsoft.Bot.Connector.Authentication.AppCredentials.&lt;ProcessHttpRequestAsync&gt;d__31.MoveNext()
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.Bot.Connector.Conversations.&lt;ReplyToActivityWithHttpMessagesAsync&gt;d__10.MoveNext()
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
     at Microsoft.Bot.Connector.ConversationsExtensions.&lt;ReplyToActivityAsync&gt;d__17.MoveNext()
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at Microsoft.Bot.Builder.BotFrameworkAdapter.&lt;SendActivitiesAsync&gt;d__34.MoveNext()
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.Bot.Builder.TurnContext.&lt;&gt;c__DisplayClass25_0.&lt;&lt;SendActivitiesAsync&gt;g__SendActivitiesThroughAdapter|1&gt;d.MoveNext()
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
     at Microsoft.Bot.Builder.TurnContext.&lt;SendActivityAsync&gt;d__24.MoveNext()
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
     at SampleBot.Bots.EchoBot.&lt;OnMessageActivityAsync&gt;d__0.MoveNext() in C:\Users\myuser\source\repos\SampleBot\SampleBot\Bots\EchoBot.cs:line 19
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
     at Microsoft.Bot.Builder.ActivityHandler.&lt;OnTurnAsync&gt;d__0.MoveNext()
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
     at Microsoft.Bot.Builder.BotFrameworkAdapter.TenantIdWorkaroundForTeamsMiddleware.&lt;OnTurnAsync&gt;d__0.MoveNext()
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
     at Microsoft.Bot.Builder.MiddlewareSet.&lt;ReceiveActivityWithStatusAsync&gt;d__3.MoveNext()
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
     at Microsoft.Bot.Builder.BotAdapter.&lt;RunPipelineAsync&gt;d__18.MoveNext()
  </code></pre>