-1

I have developed a HTTPS Synchronous end point that responds to POST messages and configured the URL as "Bot URL" under Chat bot configuration for Hangouts Chat. It is deployed to an EC2 in amazon aws and added a route53 entry for the URL: https://mychatbot-implementation which redirects HTTPS POSTs to my ec2.

However, chat bot is not posting any messages to the https end point and there are no errors logged.

Link to screenshot of chat-bot configuration

Chat Bot Implementation Code Here:

from flask import Flask, request, json, render_template, make_response

app = Flask(__name__)

@app.route('/', methods=['POST'])

def on_event():
  event = request.get_json()
  resp = None


  if event['type'] == 'REMOVED_FROM_SPACE':
    logging.info('Bot removed from space...')
  if event['type'] == 'ADDED_TO_SPACE':
    text = 'Thanks for adding me to "%s"!' % event['space']['displayName']
  elif event['type'] == 'MESSAGE':
    text = 'You said: `%s`' % event['message']['text']
  else:
    return
  return json.jsonify({'text': text})


if __name__ == '__main__':
  app.run(port=8080, ssl_context='adhoc', debug=True, host='my host ip address')

Could someone please advise on the next steps?

  • Hello! Please, can you provide mimimal complete example, because right now it's hard to understand what are you doing and what error did you get? Take a look here how to ask a good question: https://stackoverflow.com/help/how-to-ask. – Lapshin Dmitry Jun 13 '18 at 20:06
  • Hi, I have added screenshots and code to my question. Hope it is clear now. – Raghavendra Chary Desoju Jun 14 '18 at 19:39

1 Answers1

1

Unfortunately, mychatbot-implementation isn't a valid Internet TLD, so Route53 will never be able to route your request (in fact, it won't get it). You have 2 issues to be concerned with (bot implementation, user-reachability) and need to tackle them separately (divide-n-conquer) rather than trying to solve everything at once.

I suggest that to test your bot implementation, you keep your bot running on EC2 and get a reachable IP address (w.x.y.z) to your instance (plus port#) and change your configuration to point to that, i.e., https://w.x.y.z:8080/ and see if the Hangouts Chat service can reach your bot. Once you get this working and your bot debugged, then you can worry about getting a TLD and registering with DNS.

wescpy
  • 10,689
  • 3
  • 54
  • 53