我试图通过gupshup使用统一的单发送消息API端点https://api.gupshup.io/sm/api/v1/msg发送模板消息。
我们有一个模板消息,其中有相关的措辞,并规定应该有一个附件。当我们尝试发送附件时,它在以下消息中失败,(1005)消息发送失败,因为用户对会话消息不活跃,模板不匹配
在编码了JSON的message元素中,我尝试了几个选项,它们都拒绝使用上面相同的消息。
innerJson = { "isHSM": "true", "type": "file", "url": fileURL + location, "filename": filename, "text": message }
innerJson = { "isHSM": "true", "type": "file", "url": fileURL + location, "filename": filename, "caption": message }
innerJson = { "type": "file", "url": fileURL + location, "filename": filename, "text": message }
innerJson = { "type": "file", "url": fileURL + location, "filename": filename, "caption": message }在gupshup文档中找不到任何关于如何这样做的显式示例。
发布于 2022-06-29 18:23:08
我向您发送一个具有正确端点的链接,用于发送模板。
这里还有一个如何在node.js中使用它的示例:
const sendTemplateWhatsapp = (templateId, phone, media, callbackFunc) => {
innerJson = { "type":"file","url":"your_url" }
const params = new URLSearchParams()
params.append('channel', 'whatsapp');
params.append('source', waba_number);
params.append('destination', phone);
params.append('src.name', waba_name);
params.append('template', templateId);
params.append('message', JSON.stringify(innerJson));
const config = {
headers: {
'apikey': 'your_apikey',
'Content-Type': 'application/x-www-form-urlencoded'
}
}
axios.post('http://api.gupshup.io/sm/api/v1/template/msg', params, config)
.then((result) => {
console.log('Template sent to whatsapp');
callbackFunc(result.data);
})
.catch((err) => {
console.log(err);
callbackFunc(err);
})
}希望这能有所帮助
https://stackoverflow.com/questions/72692704
复制相似问题