v1.2.0

Web search + LLM with timeline write-back

Two-step RAG: ask any web-search provider, run the result through your LLM with N citations, post the answer as a CRM timeline comment on a deal.

What it does

Bitrix24 REST has no native web search or LLM endpoint. This recipe demonstrates the bridge pattern: use any external provider for search/LLM, then push the answer back into Bitrix24 via the SDK. The handler writes the LLM's cited answer to the deal's timeline as a comment.

Stack

Node.js 18+, openai. Web search is BYOC — replace webSearch() with your call to Tavily, Brave, SerpAPI, or any other provider.

Install

pnpm add openai

Environment

export B24_HOOK='https://your.bitrix24.com/rest/1/secret'
export OPENAI_API_KEY='sk-...'
export SEARCH_API_KEY='...'   # your provider's key

Run

npx tsx 09-web-search-llm.ts <DEAL_ID> "<question>"

Source

skills/b24jssdk-recipes/examples/09-web-search-llm.ts.

Notes

  • The webSearch() function in the recipe is a stub. Replace it with the actual call for your provider; the rest of the recipe is unaffected.
  • The LLM is told to cite every fact with [N] where N is results[].id. The recipe appends the matching URL list to the timeline comment.
  • crm.timeline.comment.add is a classic API method. The recipe uses the numeric ENTITY_TYPE_ID: 2 (≡ EnumCrmEntityTypeId.deal) — that form is accepted on every portal version we've tested. The string form ENTITY_TYPE: 'deal' also works on most modern portals; swap to it if your downstream expects the symbolic name.
  • For VibeCode-managed AI Router or Bitrix-search instead of an external provider, see the b24jssdk-vibecode skill.