Skype bot error on sending attachments/JSON - bots

I was trying to send a JSON stringified object or an attachment through the session using session.send, I got the following error in the console and do not get any response from the bot.
Error: Request to 'https://smba.trafficmanager.net/apis/v3/conversations/SOMEHASHCODE/activities' failed: [400] Bad Request
When I checked the Skype channel issues in Microsoft Bot Framework, I see the following message for JSON objects
Invalid XML in message text
and the following message for attachments.
Unknown attachment type
The bot is working perfectly in Slack and Emulator. So it must not be the issue with the code.
// JSON object
session.send(JSON.stringify(session.conversationData.inputData, null, 2));
// Attachment message
session.send(new builder.Message(session)
.text(`Here's the document:`)
.addAttachment({
contentUrl: `http://host:port/${filePath}`,
contentType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
name: 'Document.docx',
}));
The JSON object which was sent was {"name": "Philip John", "id": "444411111111", "phone": "54545454", "email": "philip#john.com", "address": "Street 11 - 111, City , ", "job": "Software Tester", "date": "1st June 2017", "salary": "9000", "bankAccount": "DE121231231231231231" }
Any idea how to tackle this issue?

Answer to question #1: Sending stringified JSON in Bot Framework message.
When you stringify JSON with the following settings:
JSON.stringify(inputJson, null, 2)
It produces output with new-line symbols, which is designed to "pretty print" console output in a terminal or browser console, but does not produce the same formatting when sending as a message via Bot Framework SDK.
// string output of JSON.stringify(inputJson, null, 2)
var stringified = = '{\n "name": "Philip John",\n "id": "444411111111",\n "phone": "54545454",\n "email": "philip#john.com",\n "address": "Street 11 - 111, City , ",\n "job": "Software Tester",\n "date": "1st June 2017",\n "salary": "9000",\n "bankAccount": "DE121231231231231231"\n}';
To get proper line breaks in your bot message, you need to use two \n characters instead of one. For example:
// bot formatted message string with line breaks
var botJsonMessage = '{\n\n "name": "Philip John",\n\n "id": "444411111111",\n\n "phone": "54545454",\n\n "email": "philip#john.com",\n\n "address": "Street 11 - 111, City , ",\n\n "job": "Software Tester",\n\n "date": "1st June 2017",\n\n "salary": "9000",\n\n "bankAccount": "DE121231231231231231"\n\n}';
Answer to question #2: Supported message attachment types in Bot Framework.
Currently, contentType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' is an unsupported content type. Use application/word instead.

Related

Expecting two different responses, accepting one?

I have a similar problem to this one: Two Different Response in Retrofit
However, both things that I've tried have not worked. I'm new to this and can't seem to find any other sources that are of use. I'm so so sorry if this is a dumb question, but I've been struggling with this for a week now.
Important information: I am coding in Jetpack Compose and using Retrofit2. To test data calls, I am using postman.
Success Response: [ Info changed for identification purposes, it responds with actual user data ]
{
"data": {
"id": 0,
"name": "First Last",
"first_name": "First",
"last_name": "Last",
"email": "name#yup",
"is_verified": true,
"created_at": 1666202587,
"meta": {
"image": "avatarImage",
"username": "",
"rng": " ",
"date_of_birth": null,
"city": null
}
},
"token": "correct token"
}
Error Response:
Error response
Data class:
Data class
In my first attempt, I made two data classes and split up the different responses. However, that just led to them both being null regardless of what I input. Once I moved them to once data class, it allows the user to sign in just fine, but the error is never caught and instead just crashes my app.

How to specify content type as application/json while sending message to azure service bus queue in node js?

I am sending message to queue using #azure/service-bus package and sendMessages function as mentioned in here.
When I am sending a javascript array [{ name: "Albert Einstein", "company": "xyz" }] it is giving an error TypeError: Provided value for 'message' must be of type ServiceBusMessage. So after research found out it adds body key e.g. [body:{name: "Albert Einstein", "company": "xyz"}]. But this inserts record with content-type as application/xml. Is there any way I can specify content-type:application/json?
You can specify contentType like below:
const messages = [
{
body: { "name": "Albert Einstein", "company": "xyz"},
contentType: "application/json"
}
]
Please refer to ServiceBusMessage:

Sending JSON Payload to Slack via AWS Lambda

I am trying to build a Slack app by using AWS lambda and NodeJs. The issue I am facing is that I don't understand in what format does the SlackBot need the JSON payload from my AWS lambda code to display it.
I followed the tutorial video suggested on Slack linked here. In the video, the following JSON object is created and returned from the AWS lambda.
const response = {
statusCode: 200,
body: "Sample Response",
};
The SlackBot posts the text entered in the 'body' property (i.e. 'Sample Response' in this case) as a response. This seems to be working well. But, I need some more flair than simple text so I looked into their Block Kit UI builder. But there seems to be no documentation for how to do this with a similar 'response' JSON object like this. How exactly am I supposed to use the JSON object created by the UI builder?
I do not know much about Web development so sorry if this seems like a very basic question. I wish there was a sample Slack app on their website which showed this.
The following may work for you (I use a similar one on the production);
{
"channel": "your-channel-name",
"username": "channel-username",
"attachments": [
{
"title": "some-title",
"fallback": "some message",
"text": "some text",
"fields": [
{
"title": "sub-title",
"value": "sub-title-value",
"short": true
},
{
"title": "some-other-title",
"value": "some-value"
}
],
"color": "red"
}
],
"icon_emoji": "gun"
}
This link or this one may provide some extra information.

I'm sending an Api.ai carousel message to Smooch.io but it ends up being rendered as text

I have explored smooch.io. the format of sending rich messages to smooch.io is as follows:
{
"role": "appMaker",
"type": "carousel",
"items": [{
"title": "Tacos",
"description": "Description",
"mediaUrl": "http://example.org/image.jpg",
"actions": [{
"text": "Select",
"type": "postback",
"payload": "TACOS"
}, {
"text": "More info",
"type": "link",
"uri": "http://example.org"
}]
}, {
"title": "Ramen",
"description": "Description",
"mediaUrl": "http://example.org/image.jpg",
"actions": [{
"text": "Select",
"type": "postback",
"payload": "RAMEN"
}, {
"text": "More info",
"type": "link",
"uri": "http://example.org"
}]
}]
}
BUT when i send this JSON response through api.ai to smooch.io , it gets error. Though it easily displays simple text message.
How can i send this json message as an object to smooch. Is there any way to send it like the Facebook object?
All i want is to send a carousel to the user.
The Smooch API defines its own carousel JSON structure:
http://docs.smooch.io/rest/#carousel-message
The advantage of this is that Smooch can adapt this generic carousel format into any channel that support rendering them (Facebook Messenger, LINE messenger, and Telegram for example).
Update:
(Disclaimer: I work on Smooch)
What you're getting is a text-only fallback rendering of your carousel. This is what Smooch sends for channels that do not yet support it.
Carousels do not currently render fully in the Smooch Web Messenger, though it is in our backlog. The updated list of supported carousel channels can be found in the Channel Support section here: http://docs.smooch.io/rest/#carousel-message
For cards\carousels we had to map api.ai json to the smooch json called by the Smooch webhook.

Deliverymethod fax in docusign create and send API - demo environment

Hi Trying to use the DocuSign createsendEnvelope API for a recipient with delivery method FAX and fax number. However in the demo environment the API needs a recipients email and always send out the email. The document is not faxed to the number provided. Can any one confirm if the demo environment is disabled for faxing options?
Thanks in Advance!
The release notes for the "Fax Out" feature in the DocuSign SOAP API describe how to send via fax with the SOAP API (http://www.docusign.com/sites/default/files/DocuSignReleaseNotes-Jun-1-2012-Final.pdf). I tried to apply the same rational to send an envelope via fax with the REST API -- here's my "Create Envelope" request:
POST https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes
{
"emailSubject": "Please sign this",
"emailBlurb": "Please sign...thanks!",
"status": "sent",
"enableWetSign": "true",
"recipients": {
"signers": [
{
"name": "John Doe",
"email": "johnsemail#outlook.com",
"faxNumber": "2069347947",
"recipientId": "1",
"routingOrder": "1",
"deliveryMethod": "Fax",
}]
},
"documents": [
{
"name": "TestFile.pdf",
"documentId": "1",
"fileExtension": "pdf",
"documentBase64" : "DOCUMENT_BYTES"
}
]
}
Unfortunately, I receive the following error in response to the request (even though the fax number I specified is a valid fax number):
{
"errorCode": "INVALID_FAXNUMBER",
"message": "Fax Number is invalid."
}
To troubleshoot further, I tried a little reverse-engineering in an attempt to determine what properties DocuSign expects you to set for a Fax recipient.
First, using the DocuSign web console, I created/sent a new Envelope with a single recipient where the delivery method = fax. Here's a screenshot of the Status pane from the DocuSign web console for this envlope (immediately after I sent it):
Next, I used the REST API to execute a "Get Recipients" request (GET https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes/{{envId}}/recipients) -- with the goal of examining the recipient object in the response to determine which properties need to be set for a Fax recipient. Here's the response I received:
{
"signers": [
{
"signInEachLocation": "false",
"name": "John Doe",
"email": "johnsemail#outlook.com",
"recipientId": "1",
"recipientIdGuid": "977e571d-6613-492c-8a75-9c207d46c03c",
"requireIdLookup": "false",
"userId": "03c8a856-c0ae-41bf-943d-ac6e92db66a8",
"routingOrder": "1",
"status": "sent"
}
],
"agents": [],
"editors": [],
"intermediaries": [],
"carbonCopies": [],
"certifiedDeliveries": [],
"inPersonSigners": [],
"recipientCount": "1",
"currentRoutingOrder": "1"
}
Interestingly, the API response contains no mention of "deliveryMethod", and no mention of the fax number that was specified for the recipient. This would lead me to believe that perhaps the "fax" delivery method isn't fully supported via the REST API at this time. (If it is supported, then perhaps someone with DocuSign can chime in here and explain how to send via fax (with the API).)
In the meantime, if using the DocuSign SOAP API is an option for you, you might try that route, as it appears that the "Fax Out" feature was initially designed for and implemented in the SOAP API (so I'd expect it to work there, although I haven't personally tested it).

Resources