When initiating a conversation with Botpress via NodeJS using the whatsapp-web.js library,
I’d like to initially send the phone number of the person starting the conversation.
I’m trying to achieve this in the following way:
client.on('message', message => {
console.log('number', message.from);
if( message.from == '[email protected]' ){
const number = message.from.split('@')
const from = number[0]
axios({
method: 'POST',
headers: { 'Content-Type': 'application/json' },
data: {
type: "text",
text: message.body,
payload: {from}
},
url: "http://127.0.0.1:3000/api/v1/bots/bot-zdg/converse/552298120000"
}).then(async res => {
const {responses} = res.data
for (let index = 0; index < responses.length; index++) {
const {text, choices} = responses[index]
let choice = ''
if( choices ){
const rows = choices.map(c => `> *${c.value}*: ${c.title}`)
choice = rows.join('n')
}
const msg = `${text}n${choice}`
client.sendMessage(message.from, msg)
await delay(message.from)
}
}).catch(e =>{
console.log('error',e.response.data);
console.log('error',e.message);
})
}
});
However, I’m getting the following error:
error {
statusCode: 400,
type: 'StandardError',
message: 'Invalid payload: "payload" is not allowed',
details: '',
docs: 'https://botpress.com/docs',
showStackInDev: true,
stack: 'Error: Invalid payload: "payload" is not allowedn' +
' at /snapshot/v12/packages/bp/dist/core/converse/converse-router.js',
full: 'Invalid payload: "payload" is not allowed'
}
error Request failed with status code 400
As far as I know, the standard Botpress payload is:
{
type: "text",
text: "mensagem"
}
Is there a way for me to send an additional variable so that Botpress can read it?