Quick action for catalog item

snehalataka
Tera Contributor

I tried to configure quick action for catalog item. However its searching catalog items but whenever i am sending it to user its sending only text not linkable card format same like Kb. All the things are configured same like search-kb quick action but for catalog item its not behaving properly.

 

Below is the script using under quick action parameter for catalog

 

var api = new sn_search.ScriptableSearchAPI();
var searchContextConfigId = '269812d447946290ef4b91cd436d4365';
var searchTerm = query;
var disableSpellCheck = false;
var facetFilters = [];
var searchFilters = [];
var requestedFields = {
    sc_cat_item: ['sys_id','text', 'name','short_description']
};
var response = api.search(searchContextConfigId, searchTerm, paginationToken, disableSpellCheck,facetFilters, searchFilters, requestedFields);
results = response.getSearchResults();
items = results.map(function(result) {
    var columns = result.getColumns();
    var fields = {};
    columns.forEach(function(column) {
        fields[column.getFieldName()] = column.getDisplayValue();
    });
    return {
        value: fields['name'],
        label: fields['name'],
        displayValue:result.getTitle(),
        aisDetails: {
            title: result.getTitle(),
            summary: result.getText(),
            detailLabelOne: fields['name'],
            detailLabelSeparator: " ",
            detailLabelType: "inline",
            nextPaginationToken: response.getNextPaginationToken(),
            prevPaginationToken: response.getPreviousPaginationToken()
        }
    };
});
var openedForUser = record.getValue('opened_for');
var filteredItems = sn_snippets.QuickAction.filterReadable(items, 'value', 'sc_cat_item', 'name', openedForUser);
answer = {
    items: filteredItems
};
3 REPLIES 3

Ankur Bawiskar
Tera Patron

@snehalataka 

how and where have you configured this? please share steps and detailed screenshots.

If my response helped please mark it correct and close the thread so that it benefits future readers.

snehalataka
Tera Contributor

Hi Ankur, I am configuring  this quick action under SOW virtual agent live chat. for that I created one new quick action and under Quick action-> quick action parameter we have added above script. 

 

snehalataka_0-1742365595310.png

In above snap I tried to send catalog item through quick action but it has send name only, not a clickable link. 

And you can see below snap for KB article. 

snehalataka_1-1742366480085.png

I am trying to configure catalog items in this way

j_r
Tera Contributor

Hi,

Your configuration isn't really wrong – the problem is that the part you copied isn't the part that produces the card.

Why it can't work that way

If you look closely at the OOTB search-kb quick action, the action script does almost nothing. It takes the parameter value and posts it as a plain message body. The parameter script returns the KB number as the value. So what actually gets posted into the conversation is just the string KB00xxxxx.

The nice card is generated client-side: the chat client detects a record number in the message body, resolves it and renders the preview. You can verify this in seconds – type a KB number manually into a chat and you'll get the same card, with no quick action involved at all. The same works for other record numbers such as INC or RITM.

Catalog items have no number field out of the box, so there is nothing for that renderer to detect. Pasting a catalog item URL or sys_id produces plain text. That's why your version posts only the name: your parameter script returns name as the value, and the message body becomes exactly that.

In short: an equivalent card for catalog items is not achievable out of the box. It isn't a configuration mistake on your side.

What you can do instead

A quick action that posts a formatted message with a clickable deep link to the item in your portal. No card preview, but the user gets to the item in one click. At a high level you need:

  1. A dedicated AI Search profile and search context configuration for sc_cat_item. Reuse your existing catalog search source – you only need a new profile, not a new source, so no duplicated indexing. Don't point the quick action at a general portal profile: results would be mixed with KB hits, and anyone tuning that profile would silently change your chat behavior.

  2. A parameter script that returns the sys_id as the value. Watch out for filterReadable – the field you pass must match what you put into value. The OOTB version uses number; yours needs sys_id. If they don't match, the filter silently returns nothing.

  3. Build the message in the action script, not in the parameter script. Look up the item by sys_id and compose name, short description and the portal URL there. If you put the long link into value, it ends up in the agent's input field, which is ugly.

  4. Don't forget to publish the new search profile in every target instance. The published state does not travel with an update set – the commit succeeds, but the picker silently returns no results.

We implemented it exactly this way and it works well in the Service Operations Workspace. Agents search the catalog from the chat, pick an item, and the user receives a clickable link.

Hope this helps.