title: MS Bot, Direct line API, cannot send an activity, how to fix it?
body: <p>I been trying to set up MS Bot within an app. So far, I did following.</p>
  
  <ol>
  <li><p>set a REST endpoint for Bot, that connector listens to it. </p>
  
  <pre><code> app.post("/botapi/messages", connector);
  </code></pre></li>
  <li><p>get APP_ID and APP_PASSWORD, emulator successfully connected to with following,</p>
  
  <pre><code> http://localhost:4000/botapi/messages
   APP_ID
   APP_PASSWORD
  </code></pre>
  
  <p>this is successful, bot replied as expected. </p></li>
  <li><p>Tried to talk to the Bot using Direct Line API. Successfully started conversations. One of the response is as follows.</p>
  
  <pre><code> {
     "conversationId": "3JYZyAn5VYB3HNcO3tcgtn",
     token: ....
      .....
    }
  </code></pre>
  
  <p>I used "node-fetch" packages to issue POST request, as the documentations said.</p></li>
  </ol>
  
  <p>However, I cannot send an activity using Direct Line API, received </p>
  
  <pre><code>    internal server error 500
  </code></pre>
  
  <p>The documentation said the POST request should be like this below.</p>
  
  <pre><code>    POST 
      https://directline.botframework.com/v3/directline/conversations
      Authorization: Bearer my_secret
  </code></pre>
  
  <p>This worked perfectly for starting conversations but not for sending activities.</p>
  
  <p>The activity I sent is:</p>
  
  <pre><code>      {
         "type": "message",
         "from": {
                "id": "user1"
                 },
              "text": "hello Bot, say something"
         }
  </code></pre>
  
  <p>I don't think "id" is something important, so that is what I posted to </p>
  
  <pre><code>          https://directline.botframework.com/v3/directline/conversations/{conversationId}/activities
  </code></pre>
  
  <p>I used the conversationId received from starting a conversation.
  I googled around, but find no answer to my problem.
  Besides, I have few questions, maybe their answers would help me.</p>
  
  <p>Q1: The url "<a href="https://directline.botframework.com/v3/directline/" rel="nofollow noreferrer">https://directline.botframework.com/v3/directline/</a>" is the same for everybody using Direct Line API?  When I replace it with the endpoint of  the bot, "<a href="http://localhost:3000/botapi/messages/conversations" rel="nofollow noreferrer">http://localhost:3000/botapi/messages/conversations</a>", I even cannot start conversations, nothing works.</p>
  
  <p>Q2: How does the Direct Line API work? I issue POST with my secret to the API, then how the API finds my bot? How the Bot and API communicate? am I missing something here?</p>
  
  <p>Q3: When I issue POST to send an activity, I followed the documentation.
  In the Authorization, I tried both my secret and the token I got from starting conversation, both did not work. I believe both should work. am I wrong?</p>
  
  <p>Q4: Do I need to do something with <a href="https://docs.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-connector-quickstart" rel="nofollow noreferrer">Bot Connector Service</a>? I read the article, but I don't know what it is for. am I wrong?</p>
  
  <p>So, what I am missing here? How can I send activities?</p>
  
  <p><strong>Note</strong>: My bot is not deployed to azuri or aws, it is on my Mac only. 
    But, I got APP_ID, APP_PASSWORD and SECRET for DirectLine as documents explained. </p>