import requests.packages.urllib3

from flask import Flask
from flask import request
import requests

from requests_toolbelt import MultipartEncoder
import requests

app = Flask(__name__)
import requests
import json
from datetime import datetime

botEmail = ""  # botun email adresi
accessToken = ""  # Botun access tokeni
host = ""  # CISCO Spark tarafından sunulan hizmetler arasında iletişim kurmak için sağlanan son nokta
server = "localhost"  # Web hook sunucu kuruluncaya kadar çalışmaz
port = 4000
headers = {"Authorization": "Bearer %s" % accessToken, "Content-Type": "application/json"}

@app.route('/', methods=['POST'])
def get_tasks():
    messageId = request.json.get('data').get('id')
    messageDetails = requests.get(host + "messages/" + messageId, headers=headers)
    return ""

#mesajlara cevap verme metodu
def sendMessage(message, room_id):
    payload = {"roomId": room_id, "text": message}
    response = requests.request("POST", "", data=json.dumps(payload),
    return response.status_code

#mesajlara görsel cevap verme metodu
def sendMessageWithAttachment(message, filePath, room_id):
    payload = {'roomId': room_id,
               'text': message,
               'files': [filePath]}

    response = requests.request("POST", host + "/messages", data=json.dumps(payload), headers=headers)

    return response.status_code

#mesajlara senaryoya göre cevap verme
def replyForMessages(response):

    responseMessage = response.json().get('text')
    toPersonEmail = response.json().get('personEmail')
    room_id = response.json().get('roomId')

    if toPersonEmail != botEmail:
        if '#simple#' in responseMessage:
            messageString = 'Hello! What can i do for you?'
            sendMessage(messageString, room_id)

        elif '#photo#' in responseMessage:
            filepath = ''
            sendMessageWithAttachment("lets show the image", filepath, room_id)

            #burada bot api si çağırılacak.
            #userName = response.json().get('personEmail')
            #botartAccessToken = None
            #platformName = cisco webex
            #userIdentifier = response.json().get('personId')
            #timeStamp = response.json().get('created')

            messageString = 'Sorry! I was not programmed to answer this question!'

if __name__ == "__main__":, port=port, debug=True)

Welcome to Daniweb. Such a post is going to not be a good 1st post as you skipped over the how to post and what to post. I have to write that your 1st post is not unusual but let's get off on the right foot.


Yes, I know that folk want to just dump their code on sites and have folk do the work but that's not how it works here. This is more about you sharing the issue or problem and where you are having a problem. If you did want to have others do all the work then you post as a Jobs post along with pay and a full description of what the code should do.

The last time I looked at such a conversion I found IronPython. Look at that with