[英]How to capture Referral parameters from m.me links inside MS Chatbot?
I have integrated a survey chatbot with my Facebook page.我在我的 Facebook 页面上集成了一个调查聊天机器人。 I want to send personalised m.me links to my users via email.我想通过电子邮件向我的用户发送个性化的 m.me链接。 These links contain a unique referral parameter that can identify a user's transaction.这些链接包含一个唯一的推荐参数,可以识别用户的交易。 So when a user clicks the m.me link I want my chatbot to capture this parameter from the link and send a proactive personalised welcome message to the user.因此,当用户单击 m.me 链接时,我希望我的聊天机器人从链接中捕获此参数并向用户发送主动的个性化欢迎消息。 So far I've unsuccessfully tried using a middleware to capture payloads from incoming requests.到目前为止,我已经尝试使用中间件从传入请求中捕获有效负载,但没有成功。
const restify = require('restify');
let server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 80, function () {
console.log(`\n${server.name} listening to ${server.url}`);
console.log(`\nGet Bot Framework Emulator: https://aka.ms/botframework-emulator`);
console.log(`\nTo talk to your bot, open simplePrompts.bot file in the Emulator`);});
server.use(restify.plugins.bodyParser());
// Listen for incoming requests.
server.post('/api/messages', (req, res) => {
console.log(req.body);
adapter.processActivity(req, res, async (context) => {
// Route to main dialog.
await myBot.onTurn(context);
});
});
You have to subscribe for messaging_referrals in your webhook.您必须在 webhook 中订阅 messaging_referrals。 Then you would get the referral parameter as well.然后你也会得到推荐参数。 You can read how to set it up and how the event will be provided from the documentation here: https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/messaging_referrals/您可以阅读如何设置它以及如何从此处的文档中提供事件: https ://developers.facebook.com/docs/messenger-platform/reference/webhook-events/messaging_referrals/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.