Skip to content
Docs
About By Dawn Contact supportOpen By Dawn
  1. Work with tickets
  2. Comment on a ticket

Comment on a ticket

Use this to keep a ticket’s discussion in one place: post a build result or a customer reply to the ticket, or copy its comments somewhere your team already reads. By the end you’ll have posted a comment and read back the ticket’s whole thread.

Before you start: posting needs a Board — read & write key (see Scopes), and you need the ticket’s id, for example from Create a ticket. Pass the ID as the recipe’s argument.

Read down the steps. The code on the right follows along and highlights the lines each one explains.

  1. Every recipe starts this way, as the Quickstart explains.

    // 1. Exchange the API key for a short-lived access token. Every call after this goes to your
    // organization's URL with the token as a Bearer header.
    const exchange: Schemas['ApiKeyExchange'] = { apiKey };
    const { accessToken: token } = await call<Schemas['AccessTokenData']['data']>(`${ACCOUNTS_URL}/auth/token/api-key`, { method: 'POST', body: exchange });
    const api = `${WORKSPACE_URL}/orgs/${orgIdOf(token)}`;
  2. POST /tickets/{ticketId}/comments with a body posts the comment. It shows your key as its author, so people can tell it came from your integration rather than a colleague.

    // 2. Post a comment on the ticket you named.
    const ticketId = process.argv[2];
    if (!ticketId) throw new Error('Usage: node comment.ts <ticketId>');
    const url = `${api}/tickets/${encodeURIComponent(ticketId)}/comments`;
    const create: Schemas['CommentCreate'] = { body: 'Posted by the comment recipe through the SAW API.' };
    const comment = await call<Schemas['Comment']>(url, { method: 'POST', body: create, token });
    console.log(`Posted comment ${comment.id}.`);
  3. GET on the same path returns the ticket’s comments, oldest first, so they read like a conversation. The recipe checks that its own comment is there.

    // 3. Read the ticket's comments back, oldest first.
    const comments = await call<Schemas['Comment'][]>(url, { token });
    console.log(`The ticket has ${comments.length} comment(s):`);
    for (const c of comments) console.log(` ${c.createdAt} ${c.body}`);
    if (!comments.some((c) => c.id === comment.id)) throw new Error('The new comment is missing from the list.');

Run the TypeScript recipe from this page. It posts a comment on the ticket, then lists the ticket’s comments. A ticket you created here is filled in for you. See Try it in your browser.

Try it with your organization

How this works

Connect once and run this recipe live against the By Dawn API.

Your key stays in this tab and goes only to By Dawn. Use a read-only key in a test organization.

▶ Run comment.tsThe same code CI runs, in your browser

This recipe posts a comment on the ticket in your organization.

Connect your organization above to run it.
  • Replies. Set parentCommentId to reply to a comment. Replies go one level deep.
  • Only what’s new. To pick up new comments as they come, pass the newest createdAt you’ve seen as since (ISO 8601). You get only the comments created after it.
  • Your own comments. A key can edit (PATCH) and delete (DELETE …/comments/{commentId}) the comments it posted, and no one else’s.