Send Message to Chatwoot #14345
Unanswered
inovisedigital
asked this question in
Chatwoot APIs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm having trouble sending a message to Chatwoot. I'm using the Application API endpoint api/v1/accounts/{nnn}/conversations/{nnn}/messages with attachments and I've tried everything (HTTP request, code with axios, with fetch, with helpers) and nothing works! Error 422 without any details, poor documentation...
The last one I tried was this:
const url = 'https://[domain]/api/v1/accounts/{nnn}/conversations/{nnn}/messages';
const nodeDeConversao = $('ConvAudioToBin').first().binary;
const body = {'content': $('dataSet').first().json.msgTexto, 'message_type': 'incoming'};
const options = {
method: 'POST',
url: url,
headers: {
'api_access_token': apiToken,
'content-type': 'multipart/form-data',
'accept': 'application/json'
},
body: body,
json: true}
// If a binary exists, attach it using the helper
if (nodeDeConversao.data) {
options.body['attachments[]'] = nodeDeConversao.data; // remembering this is a binary after node "convert to file"
}
try {
const response = await helpers.httpRequest(options);
return { json: response };
} catch (error) {
return {
json: {
error: true,
message: error.message,
details: error
}
};
}
I checked the attachment and it's there, it exists, but I'm sure it's some detail in the body of the Message, schema validation...
The response is always "message: Request failed with status code 422, name: AxiosError" and nothing else.
Can someone help me? Thank you
Beta Was this translation helpful? Give feedback.
All reactions