Search code examples
skype-for-businessskypedeveloperucwa

UCWA: error when sending multiple messages


I'm trying to code a Skype for Business chatbot using UCWA. For now, I can successfully create an application, send a message invitation and finally send a message which is correctly received. The problem is: if I send another message, it is never received by its recipient.

In the event, the message status is "Failure", but no other helpful information are given.

I used Matthew Proctor's tutorial and official Microsoft documentation. Microsoft example send only one message before closing the conversation so no indication is given about my problem. The Matthew Proctor's tutorial only says to rerun the POST request POST https://myhostname.com/ucwa/oauth/v1/applications/108/communication/conversations/39e/messaging/messages. And I correctly call the event resource between each message.

Here are the steps performed in my script:

sd.send_user_message_invitation()
conv_id = sd.get_conversation_ID_in_event()
sd.send_message(conv_id, "Premier message")
sd.get_event()
sd.send_message(conv_id, "Deuxième message")
sd.get_event()
sd.terminate_conversation(conv_id)

Here is the response I get when I make a GET request on the event URL after the first message (which is correctly received):

GET https://myhostname.com/ucwa/oauth/v1/applications/108/events?ack=2

{
    "_links": {
        "self": {"href": "/ucwa/oauth/v1/applications/108/events?ack=2"},
        "next": {"href": "/ucwa/oauth/v1/applications/108/events?ack=3"}
    },
    "sender": [
        {
            "rel": "conversation",
            "href": "/ucwa/oauth/v1/applications/108/communication/conversations/39e",
            "events": [
                {
                    "link": {
                        "rel": "message",
                        "href": "/ucwa/oauth/v1/applications/108/communication/conversations/39e/messaging/messages/2"
                    },
                    "status": "Success",
                    "_embedded": {
                        "message": {
                            "direction": "Outgoing",
                            "timeStamp": "\/Date(1581608086884)\/",
                            "_links": {
                                "self": {"href": "/ucwa/oauth/v1/applications/108/communication/conversations/39e/messaging/messages/2"},
                                "messaging": {"href": "/ucwa/oauth/v1/applications/108/communication/conversations/39e/messaging"}
                            },
                            "rel": "message"
                        }
                    },
                    "type": "completed"
                }
            ]
        }
    ]
}

And here is what I get when I make a GET request on the event URL after the second (or any following sent) message (which is not received):

GET https://myhostname.com/ucwa/oauth/v1/applications/108/events?ack=3

{
    "_links": {
        "self": {"href": "/ucwa/oauth/v1/applications/108/events?ack=3"},
        "next": {"href": "/ucwa/oauth/v1/applications/108/events?ack=4"}
    },
    "sender": [
        {
            "rel": "conversation",
            "href": "/ucwa/oauth/v1/applications/108/communication/conversations/39e",
            "events": [
                {
                    "link": {
                        "rel": "message",
                        "href": "/ucwa/oauth/v1/applications/108/communication/conversations/39e/messaging/messages/3"
                    },
                    "status": "Failure",
                    "_embedded": {
                        "message": {
                            "direction": "Outgoing",
                            "timeStamp": "\/Date(1581608088182)\/",
                            "_links": {
                                "self": {"href": "/ucwa/oauth/v1/applications/108/communication/conversations/39e/messaging/messages/3"},
                                "messaging": {"href": "/ucwa/oauth/v1/applications/108/communication/conversations/39e/messaging"}
                            },
                            "rel": "message"
                        }
                    },
                    "reason": {
                        "code": "RemoteFailure",
                        "message": "Your request couldn\u0027t be completed.",
                        "debugInfo": {"errorReportId": "fb8aada02f7f47e6958b6c7df62e7bec"}
                    },
                    "type": "completed"
                }
            ]
        }
    ]
}

What am I forgetting? Any help?


Solution

  • I just solved the problem. It seems that there is an encoding error, so no message containing a accented character can be sent ("é", "è", "à", "ù", ...) without causing a failure.