title: Possible way to clear the conversation state at the end of a conversation for Microsoft Teams
body: <p>I'm creating a bot and every time the conversation end, I'll to clear the conversation state. For That I'm sending an activity with type <code>endOfConversation</code> after the last message.</p>
  
  <p>At the method <code>OnMessageActivityAsync</code> of my bot I've added this code.</p>
  
  <pre><code>turnContext.OnSendActivities(OnSendActivitiesHandlerAsync);
  </code></pre>
  
  <p>Witch must execute this code:</p>
  
  <pre><code>private async Task&lt;ResourceResponse[]&gt; OnSendActivitiesHandlerAsync(ITurnContext turnContext, List&lt;Activity&gt; activities, Func&lt;Task&lt;ResourceResponse[]&gt;&gt; next)
  {
      foreach (Activity activity in activities)
      {
          if (activity.Type == ActivityTypes.EndOfConversation)
          {
              await _conversationState.ClearStateAsync(turnContext); // &lt;-- `_conversationState` is a global variable type of `BotState`.
          }
      }
  
      return await next();
  }
  </code></pre>
  
  <p>It works very good in the Bot Framework Emulator, but when it goes live on Microsoft Teams I had errors. When looking for that message I've found this:</p>
  
  <blockquote>
    <p>That particular type is not supported in Teams, sorry.</p>
    
    <p><sub><a href="https://github.com/microsoft/botframework-sdk/issues/3300" rel="nofollow noreferrer">https://github.com/microsoft/botframework-sdk/issues/3300</a></sub></p>
  </blockquote>
  
  <p>In the logs I see this when I want to send an <code>endOfConversation</code> type.</p>
  
  <pre><code>{
      "code": "BadArgument",
      "message": "Unknown activity type",
      "innerHttpError": null
  }
  </code></pre>
  
  <p>I would to send an end of conversation type because based on that type I could clear the conversation state on the server side of the bot. In that state I store some objects that aren't not relevant anymore when the conversation is ended.</p>
  
  <p>So my question is now how could I clear the conversation state at the end of an conversation without using the <code>endOfConversation</code> type?</p>