# How do I add a comment via Script automation?

**URL:** <https://community.fibery.io/t/how-do-i-add-a-comment-via-script-automation/3220>\
**Category:** Misc\
**Created:** [August 29, 2022, 1:54pm UTC](https://community.fibery.io/t/how-do-i-add-a-comment-via-script-automation/3220 "2022-08-29T13:54:45Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lug-gl](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/lug-gl/32/5293_2.png) [@Lug-gl](https://community.fibery.io/u/Lug-gl)\
**Post date:** [August 29, 2022, 1:54pm UTC](https://community.fibery.io/t/how-do-i-add-a-comment-via-script-automation/3220/1 "2022-08-29T13:54:45Z")

</div>

I tried:

```auto
await fibery.addComment("space/dataSource", entity["Id"], "someting", automationUserId, "md")

```

then always this error occures:  
Failed to execute Action “Script”: addComment: Cannot add collection items to readonly comment/author field for comments/comment database.

Do I have to create an comment entity first like descripted in API docu?

if yes what kind of values do I have to set and so on? There is not much to find in script docu.

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [August 29, 2022, 8:53pm UTC](https://community.fibery.io/t/how-do-i-add-a-comment-via-script-automation/3220/2 "2022-08-29T20:53:59Z")

</div>

Using the no-code interface, you can do this:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/e/e14356ebac5ba7b1e524fb995b6b3e525da776a1.png)

**Also the GraphQL interface has an “AddCommentInput” mutation, but I do not have any more info on it. Maybe @Oleg can help here?**

---

<div class="post-metadata">

**Author:** ![Lug-gl](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/lug-gl/32/5293_2.png) [@Lug-gl](https://community.fibery.io/u/Lug-gl)\
**Post date:** [August 30, 2022, 6:29am UTC](https://community.fibery.io/t/how-do-i-add-a-comment-via-script-automation/3220/3 "2022-08-30T06:29:07Z")

</div>

Sure this works fine and also GraphQL would be an option, but it would be a bigger workaround. The script fibery function provides the addComment, but I doesn’t understand how it should work.

---

<div class="post-metadata">

**Author:** ![Oleg](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/oleg/32/1887_2.png) [@Oleg](https://community.fibery.io/u/Oleg)\
**Post date:** [August 30, 2022, 8:51am UTC](https://community.fibery.io/t/how-do-i-add-a-comment-via-script-automation/3220/5 "2022-08-30T08:51:39Z")

</div>

Hi, @Lug-gl

Looks like it is a bug. We will fix it in nearest future.

Thanks,  
Oleg

---

<div class="post-metadata">

**Author:** ![Lug-gl](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/lug-gl/32/5293_2.png) [@Lug-gl](https://community.fibery.io/u/Lug-gl)\
**Post date:** [August 30, 2022, 9:02am UTC](https://community.fibery.io/t/how-do-i-add-a-comment-via-script-automation/3220/6 "2022-08-30T09:02:20Z")

</div>

ah ok thank you!

---

<div class="post-metadata">

**Author:** ![Sergey\_Truhtanov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/sergey_truhtanov/32/13986_2.png) [@Sergey\_Truhtanov](https://community.fibery.io/u/Sergey_Truhtanov)\
**Post date:** [August 30, 2022, 9:04am UTC](https://community.fibery.io/t/how-do-i-add-a-comment-via-script-automation/3220/7 "2022-08-30T09:04:50Z")

</div>

That was a bug on our side indeed. Issue is fixed an deployed.  
Please write here if there are still any problems with that api.

---

<div class="post-metadata">

**Author:** ![Lug-gl](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/lug-gl/32/5293_2.png) [@Lug-gl](https://community.fibery.io/u/Lug-gl)\
**Post date:** [August 30, 2022, 10:57am UTC](https://community.fibery.io/t/how-do-i-add-a-comment-via-script-automation/3220/8 "2022-08-30T10:57:57Z")

</div>

@Sergey_Truhtanov  
Thank you!

PS: I think it’s sending two notifications if you set authorID. One by fibery ghost and one by authorId mention. if authorID = “” it’s only the ghost thats cool.

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [December 22, 2023, 4:10am UTC](https://community.fibery.io/t/how-do-i-add-a-comment-via-script-automation/3220/9 "2023-12-22T04:10:29Z")

</div>

@Oleg, I am seeing an error from `addComment()` –

When I call:

```auto
await fibery.addComment("Workflows/WTask", // comments enabled on DB
  "7f6f1e90-835d-11ee-9610-37ed00f0ca21", 
  `😁Good news everyone!\n blah blah...`,
  "f13af52d-dea3-40af-83dc-b41876015c00", // User Id
  "md")

```

This error is thrown:

```auto
getEntityById: null field is not a collection. Expr: {"v":["comments/parent"]}. 

```

❓

---

<div class="post-metadata">

**Author:** ![Sergey\_Truhtanov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/sergey_truhtanov/32/13986_2.png) [@Sergey\_Truhtanov](https://community.fibery.io/u/Sergey_Truhtanov)\
**Post date:** [December 22, 2023, 10:42am UTC](https://community.fibery.io/t/how-do-i-add-a-comment-via-script-automation/3220/10 "2023-12-22T10:42:31Z")

</div>

Hello.  
This was a regression from our side. Fixed and deployed, should work fine now.  
Sorry for inconvenience.

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [December 29, 2023, 8:27pm UTC](https://community.fibery.io/t/how-do-i-add-a-comment-via-script-automation/3220/11 "2023-12-29T20:27:50Z")

</div>

@Sergey_Truhtanov, I am not getting any errors, but `await fibery.addComment()` is **not creating a new comment**.

---

<div class="post-metadata">

**Author:** ![Sergey\_Truhtanov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/sergey_truhtanov/32/13986_2.png) [@Sergey\_Truhtanov](https://community.fibery.io/u/Sergey_Truhtanov)\
**Post date:** [January 3, 2024, 2:18pm UTC](https://community.fibery.io/t/how-do-i-add-a-comment-via-script-automation/3220/12 "2024-01-03T14:18:22Z")

</div>

Oh wow. Works perfectly for me.  
Can you please share a script or part of it, that doesn’t work?  
What does this method return for you? (It should return Id of created comment).

My looking through codebase does not show risky places. It creates comment and links it to entity via batch command. Then it sets a text to a created comment. If anything fails you should get exception.  
Maybe you catch and swallow some errors in your script code?

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [January 3, 2024, 5:03pm UTC](https://community.fibery.io/t/how-do-i-add-a-comment-via-script-automation/3220/13 "2024-01-03T17:03:15Z")

</div>

It is odd… the code works for one type, but not for a different type.  
This is the entire test Button code:

```auto
///// This works correctly for the WAction type:
// const type = 'Workflows/WAction'
// const id = 'cb123770-9ed7-11ee-9b81-213a7b82dfc6' // "On State=Open" (43)

///// For the WTask Type: it "appears" to work, but then there is no comment on the entity:
// NOTE this entity already has one RESOLVED comment.
const type = 'Workflows/WTask'
const id = '7f6f1e90-835d-11ee-9610-37ed00f0ca21' // "Proof Page" (5)

const result = await fibery.addComment(type, id, "😁Good news everyone! #3", userId, "md")
console.log(result)

```

For WTask (failure case), it logs this result, which _looks_ correct:

```auto
{
  Author: { Id: 'f13af52d-dea3-40af-83dc-b41876015c00', Name: 'Matt B' },
  Id: 'd71c8650-e8d2-4229-8b08-fa347d46a916',
  'Public Id': '44',
  Parent: { Id: null, 'Document Secret': null },
  'Document Secret': '90d022b3-2c54-43ea-8c73-d345780b5b6c',
  'Creation Date': '2024-01-03T16:55:56.450Z'
}

```

But when I check the entity, there is no new comment on it – only the older resolved one.

**UPDATE:**

Weirdness: I was looking for the API-created comments in the new Comments sidebar (via the button at the top-right of entity view), and I was not seeing any new comments there, after creating many.

But after I opened (unfolded) the older “Comments field” in the same entity view, now suddenly I can see all the missing comments in both places. 😕

So now I understand that **entity comments** do not appear in the Comments sidebar when the older entity Comments area is closed/minimized/folded.

---

<div class="post-metadata">

**Author:** ![Sergey\_Truhtanov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/sergey_truhtanov/32/13986_2.png) [@Sergey\_Truhtanov](https://community.fibery.io/u/Sergey_Truhtanov)\
**Post date:** [January 4, 2024, 2:31pm UTC](https://community.fibery.io/t/how-do-i-add-a-comment-via-script-automation/3220/14 "2024-01-04T14:31:12Z")

</div>

Yep, that’s a current issue with our Comments panel ☹
