microsoftbotframework icon indicating copy to clipboard operation
microsoftbotframework copied to clipboard

Unable to send proactive messages to Slack platform

Open meets7 opened this issue 8 years ago • 1 comments

Sending async/ad hoc messages for skype is working well with the following message object:

      message = {
           'type': 'message',
           'channelId': user['channelId'],
           'conversation': {
               'id': user['conversationId']
           },
           'serviceUrl': user['serviceUrl'],
           'from': {
               'id': '*******:*********',
               'name': 'botname'
           }
       }

But the above doesn't work for slack. It gives me the following error:

Error posting to Microsoft Bot Connector. Status Code: 400, Text { error: { code: Missing Property, message: The from field is required } }

If I change the mesage to following:

message = {'type': 'message',
                   # 'id': '*********',
                   # 'timestamp': '2017-08-16T17:22:07.1718198Z',
                   'serviceUrl': 'https://slack.botframework.com',
                   'channelId': 'slack',
                   'fromAccount': {
                       'id': '*******:********',
                       'name': 'botname'
                   },
                   'conversation': {
                       'isGroup': False,
                       'id': '*****:*******:*********'
                   },
                   'from': {
                       'id': user['userId'],
                       'name': user['name']
                   },
                   'recipient': {
                       'id': user['userId'],
                       'name': user['name']
                   },
                   'channelData': {
                       'SlackMessage': {
                           # 'type': 'user_typing',
                           'channel': '*********',
                           'user': '********'
                       },
                       # 'ApiToken': 'xxxxxxxxxxx'
                    }
                   }

I get the following error:

ERROR:microsoftbotframework.response:Error posting to Microsoft Bot Connector. Status Code: 400, Text { "error": { "code": "MissingProperty", "message": "The bot referenced by the 'from' field is unrecognized" } }

Btw sending replies to slack works normally using:

        reply = ReplyToActivity(fill=message,
                        channelData={},
                        **response).send()

Any suggestions?

meets7 avatar Aug 16 '17 18:08 meets7

Hey,

I am not quite sure how you are constructing the message object. Can you show me the actual code you are using?

The from field is a pain as from is a reserved keyword in python so you set it using fromAccount rather than from. This might be the issue. I would need the code you are using the the first example to really help.

In the second example it looks like you are setting the from field to the user field which would explain why it fails there. And again I use fromAccount internally in place of the from field. It is not actually one of the fields that gets set to/from Microsoft.

Matt

mbrown1508 avatar Aug 21 '17 03:08 mbrown1508