I think it should be possible using the realtime api (https://api.slack.com/rtm), even if websockets are not supported for now. Has anybody achieved something? Would love to hear about some starting points.
I think it should be possible using the realtime api (https://api.slack.com/rtm), even if websockets are not supported for now. Has anybody achieved something? Would love to hear about some starting points.
hi there- will investigate this wkend and hopefully have something interesting to say. sounds fun!
sounds fun.
Exactly, can't wait to present Eliza the therapist to the team :)
http://www.jezuk.co.uk/cgi-bin/view/software/eliza
So I went to the slack menu > Integrations > Outgoing WebHooks, and created a new outgoing webhook service. The url I used was eg: https://conrad.pythonanywhere.com/message
Then on PythonAnywhere I made a new flask app with the slack auth token like so:
from flask import Flask, request
import json
app = Flask(__name__)
@app.route('/message', methods=['POST'])
def chat_message():
# token to confirm that message came from slack
assert request.form.get('token') == 'YOUR SLACK TOKEN'
# don't reply to yourself
if not request.form.get('user_name') == 'slackbot':
json_message = 'You said {}'.format(request.form.get('text', 'nothing'))
return json.dumps({'text': json_message})
And it just works!
Looks ridiculously easy. I'll try tomorrow....
Here's the latest version of the code that I'm running for my slack group for a more detailed example. It's funny! Can't wait to see your therapist one though...
I followed your example:
import eliza
therapist = eliza.eliza()
reply = therapist.respond(request.form.get('text', 'nothing'))
return json.dumps({'text': reply})
and started a conversation:
It is useful to add a few sys commands like reloading the module, so one doesn't need to reload the flask app via the interface.
Thanks for providing a great platform.
--noiv
:-)