title: Slack Events API: Events are posted (multiple times) for responses of own bot user
body: <p>I seem to have a problem when responding to incoming messages via the Slack Events API (<a href="https://api.slack.com/events/message.im" rel="nofollow noreferrer">im.message event</a>).</p>
  
  <ul>
  <li><p>When a user (in this case <code>UQ364CBPF</code>) sends a message to my App Home, the events API correctly posts an event to my backend (=first line in the logs below).</p></li>
  <li><p>I respond to the event with an HTTP 200 OK, and in my code (see below), I trigger a response from my Bot User. </p></li>
  <li><p>This response is sent correctly in Slack.</p></li>
  </ul>
  
  <p><strong>But</strong>: after that, the events API keeps posting events that <em>my own bot user</em> has posted a message in this channel...</p>
  
  <p>Also, where the events are usually posted only 3 times, these events just keep being posted non-stop. Even though the bot user only sent one response message in Slack.</p>
  
  <pre><code>User UQ364CBPF has posted message: I'm typing a message to my Slack bot. in DQ5FF35N2 of channel type: im
  [26/Dec/2019 15:16:30] "POST /slack/events/ HTTP/1.1" 200 0
  User UQ5529KTR has posted message: Thank you for your message! We will get back to you soon! in DQ5FF35N2 of channel type: im
  [26/Dec/2019 15:16:32] "POST /slack/events/ HTTP/1.1" 200 0
  User UQ5529KTR has posted message: Thank you for your message! We will get back to you soon! in DQ3KX0NPJ of channel type: im
  [26/Dec/2019 15:16:33] "POST /slack/events/ HTTP/1.1" 200 0
  User UQ5529KTR has posted message: Thank you for your message! We will get back to you soon! in DQ3KX0NPJ of channel type: im
  [26/Dec/2019 15:16:35] "POST /slack/events/ HTTP/1.1" 200 0
  User UQ5529KTR has posted message: Thank you for your message! We will get back to you soon! in DQ3KX0NPJ of channel type: im
  [26/Dec/2019 15:16:37] "POST /slack/events/ HTTP/1.1" 200 0
  User UQ5529KTR has posted message: Thank you for your message! We will get back to you soon! in DQ3KX0NPJ of channel type: im
  [26/Dec/2019 15:16:39] "POST /slack/events/ HTTP/1.1" 200 0
  User UQ5529KTR has posted message: Thank you for your message! We will get back to you soon! in DQ3KX0NPJ of channel type: im
  [26/Dec/2019 15:16:40] "POST /slack/events/ HTTP/1.1" 200 0
  User UQ5529KTR has posted message: Thank you for your message! We will get back to you soon! in DQ3KX0NPJ of channel type: im
  [26/Dec/2019 15:16:42] "POST /slack/events/ HTTP/1.1" 200 0
  User UQ5529KTR has posted message: Thank you for your message! We will get back to you soon! in DQ3KX0NPJ of channel type: im
  [26/Dec/2019 15:16:43] "POST /slack/events/ HTTP/1.1" 200 0
  User UQ5529KTR has posted message: Thank you for your message! We will get back to you soon! in DQ3KX0NPJ of channel type: im
  </code></pre>
  
  <p>In my code, this is part of a bigger function that processes Slack events, the relevant part:</p>
  
  <pre><code>@csrf_exempt
  def slack_events(request):
      if request.method == 'POST':
          json_data = json.loads(request.body)
          event_callback_type = json_data['event']['type']
          if event_callback_type == 'message':
                  user_id = json_data['event']['user']
                  text = json_data['event']['text']
                  channel_id = json_data['event']['channel']
                  channel_type = json_data['event']['channel_type']
                  timestamp = json_data['event']['ts']
                  print ('User ' + user_id + ' has posted message: ' + text + ' in ' + channel_id + ' of channel type: ' + channel_type)
                  slack_message_received(user_id, channel_id, channel_type, team_id, timestamp, text)
                  return HttpResponse(status=200)
  </code></pre>
  
  <p>There is nothing in here (or in the function <code>slack_message_received</code>) could trigger this recurring flow.</p>
  
  <p>So</p>
  
  <p><strong>1. Is it strange behavior that Slack is bombarding me with all these
         POST requests from my own bot user?</strong></p>
  
  <p><strong>2. Can I avoid this behavior, other than filtering out my own Bot User ID and ignoring these requests on backend side?</strong></p>