Send attachment via converse

Hi,

We’re using the converse API via code together with Venom-Bot (https://libraries.io/npm/venom-bot) for using in whatsapp.

I send the message from whatsapp to be interpreted by botpress and get the result to send back to user.

Is it possible to send attachment via converse API to botpress? How?

Tks!

Does anyone have any idea how to do this?

Hi @amauri,

This is currently not possible, only text payloads are allowed through the API. If these attachments are text, I suggest you flatten them, otherwise you should look at another channel to exchange data.

Happy Building :robot:

1 Like

Hello, I’m doing this integration with venom-bot, which way are you sending the messages to Venom-bot? Did you create a module? or are you creating a transition to API call for each message? could you give me a light?

Hello!

I just created an instance from venom and a function to botpress’s interactions using axios, like this:

async function botpress(user, msg) {
let url = http:// host : port /api/v1/bots/ BOT /converse/${user}
try {
let postData = {
type: “text”,
text: msg
}

    let axiosConfig = {
        headers: {
            'Content-Type': 'application/json;charset=UTF-8',
            "Access-Control-Allow-Origin": "*",
        }
    }

    return await axios.post(url, postData, axiosConfig);
} catch (error) {
    console.log("AXIOS ERROR: ", error);
}

}

After this, you can use return of the function:

let retorno_botpress = botpress(user, message.body);
retorno_botpress.then(async (resp) => {
if (resp.data.responses[i].type === ‘text’) {

}

Hope this helps

Hie @amauri thank you very much for your contribution. I am wondering where you placed this code. Is this in a hook.