RingCentral Glip webhook not supporting unusual characters received via email - webhooks

I'm trying to send data to RingCentral Glip using their webhook process from php on Linux.
What I'm actually doing is processing incoming mail messages and reformatting them into a Glip message format and then submitting them via the Glip webhook.
But I've run into what appears to be a character set compatibility problem.
I'm not entirely sure of what character set Glip supports, but I've tried formatting it in UTF-8 and when I submit it the message never gets posted.
If I just use plain ASCII characters the message posts without any problem.
Does anyone know what format Glip requires?
Is there any existing code libraries that people would use with PHP to transform text into that format?

The answer in my case was that I don't know what character format is required by GLIP but I do know now that it wasn't causing my problem. It turns out that I had two bugs that resulted in my message body being erased and if you send a message to glip with an empty body it submits an empty message rather than just showing the activity and title information that is set (as you would expect if the body was blank) it just treats it as entirely blank.

UTF-8 works for me without any special conversion as shown below. Is it possible that the email conversion to UTF-8 isn't working as expected? Can you post an example of the UTF-8 that isn't working for you, along with what you are expecting?
The following demo message works fine for me with JSON and screenshot provided. I've added ♠♥♣♦ to every text field for verification.
♠ - https://www.fileformat.info/info/unicode/char/2660
♥ - https://www.fileformat.info/info/unicode/char/2665
♦ - https://www.fileformat.info/info/unicode/char/2663
♦ - https://www.fileformat.info/info/unicode/char/2666
You can find the example Go code here:
Code: github.com/grokify/go-glip/...
{
"icon": "https://i.imgur.com/9yILi61.png",
"title": "**Title of the post ♠♥♣♦**",
"body": "Body of the post ♠♥♣♦",
"attachments": [
{
"color": "#00ff2a",
"pretext": "Attachment pretext appears before the attachment block ♠♥♣♦",
"author_name": "Author Name ♠♥♣♦",
"author_link": "https://example.com/author_link",
"author_icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/f/fd/000080_Navy_Blue_Square.svg/1200px-000080_Navy_Blue_Square.svg.png",
"title": "Attachment Title ♠♥♣♦",
"title_link": "https://example.com/title_link",
"fields": [
{
"title": "Field 1 ♠♥♣♦",
"value": "A short field ♠♥♣♦",
"short": true
},
{
"title": "Field 2",
"value": "This is [a linked short field](https://example.com)",
"short": true
},
{
"title": "Field 3 ♠♥♣♦",
"value": "A long, full-width field with *formatting* and [a link](https://example.com) \n\n ♠♥♣♦"
}
],
"text": "Attachment text ♠♥♣♦",
"image_url": "https://media3.giphy.com/media/l4FssTixISsPStXRC/giphy.gif",
"thumbnail_url": "https://funkybuddhabrewery.com/sites/default/files/WorldBeerCupGold.png",
"footer": "Attachment footer and timestamp ♠♥♣♦",
"footer_icon": "http://www.iconsdb.com/icons/preview/red/square-ios-app-xxl.png",
"ts": 1517169226
}
]
}
More information is available on the message formatting here:
http://ringcentral-api-docs.readthedocs.io/en/latest/glip_message_attachments/

Related

Dialogflow Fulfillment URLnot sending any data

I am building a bot for google assistant. I have enabled fulfillment section for some intents. Dialog flow sends the request to the fulfillment url. The url is executed and a hard coded response is returned. I can see the response in the assistant simulator. Everything works fine except one thing. The request is empty.I can't access fields that are supposed to be present in the request.
I have accessed the same url using post request from a python code and it displays the parameters. So, there are no issues in the code. I think I am missing some configuration option.
I was expecting the post body in the following format:
POST body:
{
"responseId": "ea3d77e8-ae27-41a4-9e1d-174bd461b68c",
"session": "projects/your-agents-project-id/agent/sessions/88d13aa8-2999-4f71-b233-39cbf3a824a0",
"queryResult": {
"queryText": "user's original query to your agent",
"parameters": {
"param": "param value"
},
"allRequiredParamsPresent": true,
"fulfillmentText": "Text defined in Dialogflow's console for the intent that was matched",
"fulfillmentMessages": [
{
"text": {
"text": [
"Text defined in Dialogflow's console for the intent that was matched"
]
}
}
],
"outputContexts": [
{
"name": "projects/your-agents-project-id/agent/sessions/88d13aa8-2999-4f71-b233-39cbf3a824a0/contexts/generic",
"lifespanCount": 5,
"parameters": {
"param": "param value"
}
}
],
"intent": {
"name": "projects/your-agents-project-id/agent/intents/29bcd7f8-f717-4261-a8fd-2d3e451b8af8",
"displayName": "Matched Intent Name"
},
"intentDetectionConfidence": 1,
"diagnosticInfo": {},
"languageCode": "en"
},
"originalDetectIntentRequest": {}
}
But when I print the post data using print(request.POST), the actual post request shown is
One more thing: Does dialog flow append the action at the end of the fulfillment url? If so, I will have to handle the logic separately. I have done it without considering the action name. But a lot of my stuff is hacked, so I just want to be sure.
On another note, is dialogflow good enough? It has worked fine on a few examples similar to what it was trained on. How many training samples does it need to work properly? What is the underlying algorithm used in dialogflow? Or should I use the fulfillment url and handle everything on my own? I am inclined towards the later. I do not have too much faith in the existing chatbots.
Any help is appreciated.
If the Fallback Intent is the one being triggered, then you wouldn't get any parameters since this means that nothing else matched.
Got it. Used request.body. This solves the problem. Then parsed it using json.loads and accessed the parameters.

Identifying numbers correctly

I have an intent where I might say 'Transfer 4 to Bob' and it identifies this as 'Transfer for to Bob'
Also I might say 'Transfer 10 to Bob and it identifies this as 'Transfer 102 Bob' treating to word to as 2 on the end of the previous number.
What is the best way to get API.AI to recognise these parts correctly so 4 is not for and to is not 2?
You mentioned that you're using the Actions on Google platform. This means that speech recognition - the process of translating what the user says into text - is happening before the data gets to API.AI.
The problem you're experiencing is that Actions on Google is misrecognizing some numbers as words, e.g. four becomes for.
Because this happens before - and separately from - API.AI, you won't be able to fix the misrecognition.
Below, I'll explain how you can work around this issue in API.AI. However, it's also worth thinking about how you could make your conversation design as robust as possible so that issues like this are less likely to cause problems.
One way you could increase robustness would be to mark the number as a required parameter in API.AI so the user is prompted if it isn't detected due to a recognition error. In that case, the dialog would go like this:
User: Give me four lattes.
App: Sure, four lattes coming up.
User: Give me for lattes.
App: How many do you want?
User: Four.
App: Sure, four lattes coming up.
Regardless, here's a workaround you can use to help recover from misrecognition:
In your intent, provide examples of these commonly misrecognized values. Highlight and mark them as numbers.
Test out your intent out in the console and you'll see that "for" is now matched as a "number" entity with value "for".
In your fulfillment webhook, check the parameter for this value and convert it to the appropriate number using a dictionary. Here's the JSON for the above query:
{
"id": "994c4e39-be49-4eae-94b0-077700ef87a3",
"timestamp": "2017-08-03T19:50:26.314Z",
"lang": "en",
"result": {
"source": "agent",
"resolvedQuery": "Get me for lattes",
"action": "",
"actionIncomplete": false,
"parameters": {
"drink": "lattes",
"number": "for" // NOTE: Convert this to "4" in your webhook
},
"contexts": [],
"metadata": {
"intentId": "0e1b0e72-78ba-4c61-a4fd-a73788034de1",
"webhookUsed": "false",
"webhookForSlotFillingUsed": "false",
"intentName": "get drink"
},
"fulfillment": {
"speech": "",
"messages": [
{
"type": 0,
"speech": ""
}
]
},
"score": 1
},
"status": {
"code": 200,
"errorType": "success"
},
"sessionId": "8b0891c1-50c8-43c6-99c4-8f77261acf86"
}

Pre-populating Template Tabs with REST API

Trying to pre-populate some fields before sending an envelope using a template in my account, but when the signer/recipient receives the link to the document in their email, the fields are left blank. Here's a portion of the JSON I'm using to make the request in the API:
var body = JSON.stringify({
"emailSubject": "DocuSign API call - Request Signature",
"templateId": templateId,
"templateRoles": [{
"email": recipientEmail,
"name": recipientName,
"roleName": templateRoleName,
"tabs": {
"companyTabs": [
{
"tabLabel": "\\*SignerCompany",
"value": recipientCompany
},
],
"titleTabs": [
{
"tabLabel": "\\*SignerTitle",
"value": recipientTitle
}
]
}
}],
"status": "sent", ....
So the company and title tabs with the labels "SignerCompany" and "SignerTitle" aren't being pre-filled for the recipient. I've tried changing font colors and other things and those seem to work, but somehow the value just doesn't.
I've viewed many similar problems with trying to pre-populate these templates but haven't been able to figure it out. Any help is much appreciated!
This was just asked (and answered) in another recent Stack Overflow post. The issue is that you can not set the company and title tabs in particular (they are read-only).
The system populates their data based on the user's account profile, so if no profile or no data in their profile they'll show up as blank as you're seeing.
See this post for a more detailed answer: https://stackoverflow.com/a/38009218/1968395

Outlook Mail REST API: send message with attachment

I'm trying to use next API method: https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#SendMessages. Sending messages without attachments works just fine, but I can not understand how to send message with attachments.
According to docs, Message structure can contain array of Attachments with items of type https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#RESTAPIResourcesFileAttachment . Problem is in the field ContentBytes -- it is impossible to dump bytes to JSON before sending request to this API method (actually dumping any BLOB to JSON is nonsense).
How should I pass Attachments using REST API at all?
Thanks.
There's an example of passing the attachment on that page: https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#SendMessageOnTheFly
I know I'm 3 years late but, you can look at this example:
https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#create-and-send-messages (if you don't get forwarded to the section "Create and send messages", please scroll manually).
I know it is 365 and not Microsoft Graph but request is absolutely same.
This is basically how JSON representation of the post method looks:
https://outlook.office.com/api/v2.0/me/sendmail
{
"Message":
{
"Subject": "Meet for lunch?",
"Body": {
"ContentType": "Text",
"Content": "The new cafeteria is open."
},
"ToRecipients": [
{
"EmailAddress": {
"Address": "garthf#a830edad9050849NDA1.onmicrosoft.com"
}
}
],
"Attachments": [
{
"#odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "menu.txt",
"ContentBytes": "bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
]
}
}

display computed text in JSON format

In an xpage I have several calls to collect data in json format from several notesviews via java class files.
To check or visualize the data I have a "debug mode" option to display this data in computed fields.
The data is json but I would like to have it formatted in the computed text so it is easier to read.
Does anyone know how I can format the display to it is easier to read in stead of one line of text?
e.g. from
{"locationName":"","gender":"Male","companyName":"","name":"Patrick Kwinten","docUNID":"845AB7AF45FF1260C1257E88003DACFA","notesName":"CN=Patrick Kwinten\/O=quintessens","branchName":"Quintessens Global Services","phone": ["+49 1525 161 223"],"info": ["IT Specialsit"],"sourceUNID":"","pictureURL":"http:\/\/dev1\/apps\/banking\/ServiceData.nsf\/0\/845AB7AF45FF1260C1257E88003DACFA\/$FILE\/PortalPicture.jpg","mail": ["patrickkwinten#ghotmail.com"],"reportsTo":"CN=Eva Fahlgren\/O=quintessens","job":"Managaer","departmentName":"Collaboration Services"}
to
{
"locationName": "",
"gender": "Male",
"companyName": "",
"name": "Patrick Kwinten",
"docUNID": "845AB7AF45FF1260C1257E88003DACFA",
"notesName": "CN=Patrick Kwinten\/O=quintessens",
"branchName": "Quintessens Global Services",
"phone": [
"+49 1525 161 223"
],
"info": [
"IT Specialsit"
],
"sourceUNID": "",
"pictureURL": "http:\/\/dev1\/apps\/banking\/ServiceData.nsf\/0\/845AB7AF45FF1260C1257E88003DACFA\/$FILE\/PortalPicture.jpg",
"mail": [
"patrickkwinten#ghotmail.com"
],
"reportsTo": "CN=Eva Fahlgren\/O=quintessens",
"job": "Managaer",
"departmentName": "Collaboration Services"
}
I do it in a different way. I use Google Postman to fire the request (with headers or whatever you need) and then I get the result back in Postman and can view it as "pretty" - this way I don't have to build anything like this into the application - and I also prefer to see the "raw" data and not risk changing anything on manipulating it prior to displaying it the way you suggest :-)
Really can't live without this utility once I discovered it.
/John

Resources