UCWA: error when sending multiple messages - skype-for-business

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?

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.

Related

Vonage WhatsApp messages suddenly stopped working

I have recently joined a company that is using Vonage and we have WhatsApp communications which was working fine in both dev and production that have both suddenly stopped working.
The shape of the incoming json looks to have changed significantly, but I have changed the code that is reading this and am able to read the messages into the system.
The problem that I have now, is outgoing message is not being accepted.
If I send this json body over
{
"from": "4474183xxxxx",
"to": "4474719xxxxx",
"message": {
"Type": "text",
"content": "Hello! I’m CAI, A Virtual Chat-bot assistant. blurb, more blurb.... .\n\n1. Okay I understand\n\nChoose any one option. Type \"1\" to choose first option."
}
}
I get the following response
{
"Status": "fail", // custom one to my company
"e3": {
"Error": {
"body": {
"type": "https://developer.vonage.com/api-errors",
"title": "Your request parameters didn't validate.",
"detail": "Found errors validating 1 of your submitted parameters.",
"invalid_parameters": [
{
"name": "to",
"reason": "Malformed JSON body."
}
],
"instance": "cf4bce73-2db5-4102-b7af-xxxxxx"
},
"headers": {
"date": "Wed, 02 Nov 2022 14:02:08 GMT",
"content-type": "application/problem+json",
"content-length": "287",
"connection": "close",
"x-envoy-upstream-service-time": "3",
"x-frame-options": "deny",
"x-xss-protection": "1; mode=block",
"strict-transport-security": "max-age=31536000; includeSubdomains",
"x-content-type-options": "nosniff",
"server": "envoy"
},
"statusCode": 400
},
"StatCode": 400,
"Response": null
},
"a": {
"label": 6,
"trys": [
[
0,
6,
null,
7
]
],
"ops": []
}
}
However, looking at the shape of the message that is on the website (https://dashboard.nexmo.com/messages/sandbox) and send this message
{
"from": "xxxx",
"to": "xxxx",
"message_type": "text",
"text": "Hello! I’m CAI, blurb... .\n\n1. Okay I understand\n\nChoose any one option. Type \"1\" to choose first option.",
"channel" : "whatsapp"
}
I get this response
{
"Status": "fail",
"e3": {},
"a": {
"label": 6,
"trys": [
[
0,
6,
null,
7
]
],
"ops": []
},
"Message": "Cannot read property 'Type' of undefined"
}
I would be grateful if someone could help me shape the message that needs to be sent to vonage to that this can be sent out to the end user \ recipient correct.
Thanks
Simon

Forwading URL Through Cloudflare API

I'm trying to create a page rule using Cloudflare's API to forward http to https. Unfortunately, I don't think the documentation is 100% clear on how to do this. Here is the JSON object I'm currently passing to the POST body:
{
"targets": [
{
"target": "url",
"constraint": {
"operator": "matches",
"value": "http://exampletest.com/*"
}
}
],
"actions": [{
"id": "forwarding_url",
"value": "https://exampletest.com/$1"
}]
}
and here is the message I'm getting back:
{
"success": false,
"errors": [
{
"code": 1004,
"message": "Page Rule validation failed: See messages for details."
}
],
"messages": [
{
"code": 1,
"message": ".settings[0].url: This value should not be blank.",
"type": null
},
{
"code": 2,
"message": ".settings[0].statusCode: This value should not be blank.",
"type": null
}
],
"result": null
}
So it seems like I need to have a settings object somewhere, but any way I try to add the settings, I'm getting the same message. Does anyone know what I'm doing wrong here? Here is Cloudflare's Documentation on the subject. Not sure if I might be missing something:
https://api.cloudflare.com/#page-rules-for-a-zone-create-page-rule
Actually, just figured this one out. It looks like this is the correct format:
{
"targets": [
{
"target": "url",
"constraint": {
"operator": "matches",
"value": "http://exampletest.com/*"
}
}
],
"actions": [
{
"id": "forwarding_url",
"value": {
"url": "https://www.exampletest.com/$1",
"status_code": 301
}
}
]
}
You have to set a parameter - "status":"active" to actually activate the page rule or else you're just creating an inactive rule.
Cloudflare sets this as an optional parameter, but it is needed to activate the rule.
The updated version of this answer goes like this:
{
"targets": [
{
"target": "url",
"constraint": {
"operator": "matches",
"value": "http://exampletest.com/*"
}
}
],
"actions": [
{
"id": "forwarding_url",
"value": {
"url": "https://www.exampletest.com/$1",
"status_code": 301
}
}
],
"status": "active"
}

Define array of different objects with max count 5 in swagger

I have completed a Node.js app using LINE APIs.I have the following request object. How can I define the array of different objects, here the messagesfield which contains different object structure for different message types. I hope swagger permits this very common scenario.
Request Body:
{
"to": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"messages":[
{
"type":"text",
"text":"Hello, world1"
},
{
"type": "audio",
"originalContentUrl": "https://example.com/original.m4a",
"duration": 240000
}
{
"type": "location",
"title": "my location",
"address": "〒150-0002 東京都渋谷区渋谷2丁目21−1",
"latitude": 35.65910807942215,
"longitude": 139.70372892916203
}
]
}
My swagger definition for messages array.
"Messages Object": {
"type": "array",
"items": {
"allOf": [
{
"$ref": "#/definitions/multicast Message Error Response"
},
{
"$ref": "#/definitions/multicast Message Error Response"
}
]
}
}
And this is the rendered messages array. It has only one entry. I want to include many different entries
"messages": [
{
"code": 500,
"httpCode": 400,
"name": "string",
"message": "string"
}
]

Detect the id of a sent mail

I would like to detect the message-id of an email
sent from the gmail interface?
what are your proposals?
Thanks.
One way of doing it would be to first list messages:
GET https://www.googleapis.com/gmail/v1/users/me/messages
Response:
{
"messages": [
{
"id": "14f60b097be71757",
"threadId": "14f60b097be71757"
},
{
"id": "14f603ead78aff97",
"threadId": "14f603ead78aff97"
}, ...
Then, get the message you want, and just ask for the Message-Id-header:
format = metadata
metadataHeaders = Message-Id
GET https://www.googleapis.com/gmail/v1/users/me/messages/14f60b097be71757?format=metadata&metadataHeaders=Message-Id
Response:
{
"id": "14f60b097be71757",
"threadId": "14f60b097be71757",
"labelIds": [
"INBOX",
"CATEGORY_PROMOTIONS",
"UNREAD"
],
"snippet": "Cool snippet...",
"historyId": "545168",
"internalDate": "1440436229000",
"payload": {
"mimeType": "multipart/alternative",
"headers": [
{
"name": "Message-Id",
"value": "<10342275.20150824171029.55db500501e9a7#example.com>" // Here it is!
}
]
},
"sizeEstimate": 73995
}

Invalid Path while inserting job from google cloud storage to google bigquery

I am trying to insert a job through HTTP Post request, but i am getting Invalid path error.
My request body is as follows:
{
"configuration": {
"load": {
"sourceUris": [
"gs://onianalytics/PersData.csv"
],
"schema": {
"fields": [
{
"name": "Name",
"type": "STRING"
},
{
"name": "Age",
"type": "INTEGER"
}
]
},
"destinationTable": {
"datasetId": "Test_Dataset",
"projectId": "lithe-anvil-404",
"tableId": "tb_test_Pers"
}
}
},
"jobReference": {
"jobId": "10",
"projectId": "lithe-anvil-404"
}
}
For the sourceuri parameter, I am passing "gs://onianalytics/PersData.csv", where onianalytics is my bucket name and PersData.csv is my csv file (from which I want to upload data into google bigquery).
I am getting below response:
"status": {
"state": "DONE",
"errorResult": {
"reason": "invalid",
"message": "Invalid path: gs://onianalytics/PersData.csv"
},
"errors": [
{
"reason": "invalid",
"message": "Invalid path: gs://onianalytics/PersData.csv"
}
]
},
"statistics": {
"creationTime": "1387276603674",
"startTime": "1387276603751",
"endTime": "1387276603751"
}
}
Please explain why this error is occurring?
Is your bucket under the same projectId that has the BigQuery service activated and you requested tokens with? If not, have you tried enabling read/write access for that project?