Hi,
I was able to authenticate/get a token and use that to create a chat session between myself and another test user. I now want to create a message to inject into the conversation but when I include the content of message in the request body I am getting a 400 “data should NOT have additional properties” error. Where should this go?
Is there a postman file of a working create message request that I can take a look at?
Can you share the request body and which specific path (e.g. /conversations/{conversationID}/messages) you’re using?
We’re working to publish a Postman library within the next week, I’ll announce it here on the forums as soon as it’s available.
I’m first creating the conversation and getting the conversation ID. When creating the message, I am passing the conversation ID as parameter. For the message contents I may have been mis-interpreting the documentation but I passed it as a json in the body:
{
“body”: “string”
}
That looks correct, body is the only mandatory property for creating a message. @budd.renaud is going to publish a postman collection shortly.
I found the calls you’re making in the server logs, and it looks like you’re including the conversation ID as a query parameter and not a path parameter. Your call should look like this:
POST https://chat.dev.api.mitel.io/2017-09-01/conversations/{conversationID}/messages
The request body is fine, it’s just “body” with the content of the message as you outlined.
Is there documentation that more details on the body parameters and the allowed values? For example, I am getting message that languageCode should match pattern but I don’t know what are the allowed/expected parameter values
{
"name": "string",
"languageCode": "string",
"stream": false,
"thumbnailUrl": "http://example.com",
"visibility": "PUBLIC",
"hidden": true,
"generateSystemMessages": false,
"originalParticipants": [
{
"type": "USER",
"participantId": "jim.su@windstream.com, ron.xiao@windstream.com"
}
],
"accessCode": "string"
}
What is the sequence to create a conversation then inject a message into the conversationID?
I tried to first create a Conversation, using following body parameters:
{
"languageCode": "en-US",
"stream": false,
"thumbnailUrl": "http://example.com",
"visibility": "PRIVATE",
"hidden": false,
"generateSystemMessages": false,
"originalParticipants": [
{
"type": "USER",
"participantId": "jim.su@windstream.com"
},
{
"type": "USER",
"participantId": "ron.xiao@windstream.com"
}
],
"accessCode": "string"
}
It successfully created a ConversationID, but I noticed that even though I specified hidden to be false, the response showed that it was set to true. Should it have set to false?
I then used the ConversationID in a Create Message request with the following body:
{
"body": "Hello Ron!",
"contentType": "text/*",
"fallbackText": "string",
"parentMessageId": "",
"tag": "string"
}
The 201 response indicated that it went through but neither of us saw the message show up. Also, when ran a get message request using the conversation ID, it did not show up.
You guessed correctly on the language codes.
For the other issue, I think the cause is that for the “participantId” you’re using an email address instead of the actual UserID (GUID). Other than that, what you’ve shown looks like it should technically work. That said, a couple minor points:
- “accessCode” isn’t actually used by any Mitel apps right now, but you can use it yourself for your own apps if you need it. You’ll find this happens a lot with the Chat API, lots of functionality available that just isn’t used yet.
- “fallbackText” is not required here, but useful if the app UI has a problem deciphering the message content. Like let’s say the contentType is something finicky (like code) that gets malformed in some way so that the UI can’t display it as intended. Using a simple string for ‘fallbacktext’ lets the UI display something other than just erroring out.
- “parentMessageId” and “tag” are optional too.
I’m working on a guide for the chat API that should be posted to the forums next week, it will give more context around a lot of this stuff.
Thanks, I substituted the userID for participantID and now it is displaying. However, it is displaying the fallback text instead of the actual body. I suspect that it might be because of contentType. What are the allowable values for contentType?
I used “text/*” as the contentType and received 200 OK. But the actual message displayed is the fallback text, so it indicates it did not understand the content?
{
"body": "Hello Ron!",
"contentType": "text/*",
"fallbackText": "This is the fallback text message",
"parentMessageId": "",
"tag": "string"
}
The Chat API will accept just about any contentType, even ones that you make up yourself for your own apps. The question is if the application will support said contentType.
Try using “text/plain” for contentType and see if that works. I assume you’re using the MOWA chat client (https://office.dev.mitel.io/)?
I will be publishing a guide on the Chat API in the next day or two, hopefully that will help you out as well.