Best practices for developers: Bulk updating article labels for Answer Bot

Have more questions? Submit a request

12 Comments

  • Matt Petersen

    I'm getting the following errors when trying to run the Ruby script in terminal:

    bulk_add_labels.rb:1: syntax error, unexpected $undefined, expecting '}'
    {\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf830
      ^
    bulk_add_labels.rb:2: syntax error, unexpected $undefined, expecting '}'
    {\fonttbl\f0\fmodern\fcharset0 Courier;}
      ^
    bulk_add_labels.rb:2: syntax error, unexpected '}', expecting end-of-input

    Anyone else running into this or know how to fix it? 

    0
  • Matt Petersen

    Please disregard my last comment. The problem had to do with formatting added by TextEdit, even though I was converting the file to plain text. Using Sublime Text instead worked flawlessly. 

    0
  • Patrick

    So I tried to write a remove labels in bulk, but it seems we cannot access the label json, are there certain permissions for this?

    0
  • Sean Needham

    Hi Mike, 

    This would be very useful if I could get it to work. Option 2 works and I get a list of sections but when I try to add a label to a section nothing happens. Then I tried to add a label to an individual article an I get this response below. Any ideas feedback much appreciated. 

    Sean,

    Alright, whats the name of your label? example: answer-bot
    answer-bot
    bulk_add_labels.rb:64:in `article': undefined method `[]' for nil:NilClass (NoMethodError)
    from bulk_add_labels.rb:83:in `block in add_answer_bot_label_to_articles'
    from bulk_add_labels.rb:81:in `each'
    from bulk_add_labels.rb:81:in `add_answer_bot_label_to_articles'
    from bulk_add_labels.rb:116:in `block in <main>'
    from bulk_add_labels.rb:93:in `loop'
    from bulk_add_labels.rb:93:in `<main>'

    0
  • Mike Mortimer

    Hey Sean, what's your default locale of your HC set to?

    0
  • Sean Needham

    @Mike /en-gb/

    0
  • Mike Mortimer

    OK, that makes sense Sean - we had en-us hard coded on some of those API endpoints. If you update lines 56 and 63 it should work. Let us know?

    0
  • Sean Needham

    Thanks Mike, This works, Very helpful :)

    0
  • An Nguyen

    The script doesn't list all the sections that we have on help center (option #1)

    So I had to modify the line #49 to get the category from a specific category. Then it shows all the sections under the selected category just fine

    #sections_response = JSON.parse(get('help_center/{local}/categories/{categoryID}/sections.json').body)

     

    Thanks Mike for having the script written

    0
  • An Nguyen

    Hi Mike,

    Can you help to modify this script to make it support removing labels out of articles as well?

    Thanks

    0
  • Michael Buch-Larsen

    Hi Mike

    I’ve gotten the script working and while I think it's really great, but it doesn’t do quite what I want. Is there any way you could help me with the final steps?

    What I want to expand to script to do, is have option 3 be able to take in more than one label, for an example a comma-separated list of label names and add all of those to a single article.

    Looking forward to hearing back for you :)

    0
  • Zac

    You can now update articles in bulk without using the API: https://support.zendesk.com/hc/en-us/articles/360001912187-Updating-knowledge-base-articles-in-bulk

    1

Please sign in to leave a comment.

Powered by Zendesk