You can reply to a thread using the replyToThread mutation. The call to this mutation will be successful if:

  • the last message in the thread is an email from the customer OR
  • the thread was just created with createThread

If it is not possible to reply to this thread, you will get the mutation error code cannot_reply_to_thread and a message indicating why.

Only one permission is needed:

  • thread:reply
import { PlainClient } from '@team-plain/typescript-sdk';

const client = new PlainClient({ apiKey: 'plainApiKey_xxx' });

const res = await client.replyToThread({
  threadId: 'th_01HD1G6649R1DK061W27VBT7QB',
  textContent: 'The plain text version of your reply goes here.',
  markdownContent: 'The markdown **version** of your _reply_ goes here.',
});

if (res.error) {
  console.error(res.error);
} else {
  console.log(res.data);
}

Where res.data is:

{}