Skip to content

reply to a newly created tweet #199

Answered by alkihis
kass507 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi!

You can reply to an existing tweet using its ID.

const mediaIds = []

for (const image of images) {
  // upload your images...
  const mediaId = await client.v1.uploadMedia(image)
  mediaIds.push(mediaId)
}

// only keep the 4 first images
const firstImages = mediaIds.slice(0, 4)
const remainingImages = mediaIds.slice(4)

// Send your first tweet
const tweet = await client.v1.tweet('Status text', { media_ids: firstImages })

// Reply to the first one
await client.v1.reply(
  'reply to previously created tweet.',
  tweet.id_str,
  { media_ids: remainingImages },
);

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kass507
Comment options

Answer selected by kass507
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants