I'm trying to send a reply to a tweet by giving the tweet_id, but instead of sending a reply, it sends a tweet. I feel like the tweet_id isn't user in the function.
Here's the code I have:
function(properties, context) {
var Twitter = require('twitter');
var client = new Twitter({
consumer_key: context.keys["ConsumerKey"],
consumer_secret: context.keys["ConsumerSecret"],
access_token_key: context.keys["AccessTokenKey"],
access_token_secret: context.keys["AccessTokenSecret"]
});
let result = context.async(async callback => {
// Reply to the tweet
client.post(
'statuses/update',
{
status: properties.message,
in_reply_to_status_id: properties.tweet_id
},
function(error, tweet, response) {
if (error) {
callback(error[0].code + ':' + error[0].message);
} else {
callback(null, 'OK');
}
}
);
});
return { tweet_result: result };
}
This is the description of the in_reply_to_status_id
parameter from the documentation for the statuses/update
API:
The ID of an existing status that the update is in reply to. Note: This parameter will be ignored unless the author of the Tweet this parameter references is mentioned within the status text. Therefore, you must include @username , where username is the author of the referenced Tweet, within the update.
If properties.message
doesn't "at" the person you want to reply to, it won't be sent as a reply.