//native
/**
* Send Reaction
* React to a received message with an emoji.
*/
export async function main(
auth: RT.WhatsappBusiness,
to: string,
message_id: string,
emoji: string
) {
const apiVersion = auth.api_version || "v25.0"
const url = new URL(
`https://graph.facebook.com/${apiVersion}/${auth.phone_number_id}/messages`
)
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
messaging_product: "whatsapp",
recipient_type: "individual",
to,
type: "reaction",
reaction: {
message_id,
emoji,
},
}),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 5 hours ago