mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-19 17:59:12 -06:00
Implement externalAdReplyBody for Meta Ads
Receive Instagram/Facebook Ads messages for recognizing in messages to use in Dify(example).
This commit is contained in:
parent
f6b3612c3d
commit
aa79409d44
@ -1585,16 +1585,21 @@ export class ChatwootService {
|
||||
|
||||
private getMessageContent(types: any) {
|
||||
const typeKey = Object.keys(types).find((key) => types[key] !== undefined);
|
||||
|
||||
const result = typeKey ? types[typeKey] : undefined;
|
||||
|
||||
|
||||
let result = typeKey ? types[typeKey] : undefined;
|
||||
|
||||
// Remove externalAdReplyBody| in Chatwoot (Already Have)
|
||||
if (result && typeof result === 'string' && result.includes('externalAdReplyBody|')) {
|
||||
result = result.split('externalAdReplyBody|').filter(Boolean).join('');
|
||||
}
|
||||
|
||||
if (typeKey === 'locationMessage' || typeKey === 'liveLocationMessage') {
|
||||
const latitude = result.degreesLatitude;
|
||||
const longitude = result.degreesLongitude;
|
||||
|
||||
|
||||
const locationName = result?.name;
|
||||
const locationAddress = result?.address;
|
||||
|
||||
|
||||
const formattedLocation =
|
||||
`*${i18next.t('cw.locationMessage.location')}:*\n\n` +
|
||||
`_${i18next.t('cw.locationMessage.latitude')}:_ ${latitude} \n` +
|
||||
@ -1603,7 +1608,7 @@ export class ChatwootService {
|
||||
(locationAddress ? `_${i18next.t('cw.locationMessage.locationAddress')}:_ ${locationAddress} \n` : '') +
|
||||
`_${i18next.t('cw.locationMessage.locationUrl')}:_ ` +
|
||||
`https://www.google.com/maps/search/?api=1&query=${latitude},${longitude}`;
|
||||
|
||||
|
||||
return formattedLocation;
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,9 @@ const getTypeMessage = (msg: any) => {
|
||||
: ''
|
||||
}`
|
||||
: undefined,
|
||||
externalAdReplyBody: msg?.message?.extendedTextMessage?.contextInfo?.externalAdReply?.body
|
||||
? `externalAdReplyBody|${msg.message.extendedTextMessage.contextInfo.externalAdReply.body}`
|
||||
: undefined,
|
||||
};
|
||||
|
||||
const messageType = Object.keys(types).find((key) => types[key] !== undefined) || 'unknown';
|
||||
@ -49,9 +52,13 @@ const getTypeMessage = (msg: any) => {
|
||||
};
|
||||
|
||||
const getMessageContent = (types: any) => {
|
||||
const typeKey = Object.keys(types).find((key) => types[key] !== undefined);
|
||||
const typeKey = Object.keys(types).find((key) => key !== 'externalAdReplyBody' && types[key] !== undefined);
|
||||
|
||||
const result = typeKey ? types[typeKey] : undefined;
|
||||
let result = typeKey ? types[typeKey] : undefined;
|
||||
|
||||
if (types.externalAdReplyBody) {
|
||||
result = result ? `${result}\n${types.externalAdReplyBody}` : types.externalAdReplyBody;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user