메인 콘텐츠로 건너뛰기
generate-documenttool로 노출되어 있기 때문에, AI 에이전트가 이를 호출할 수 있습니다. 사용자가 그냥 *“generate a proposal for Jeffery Griffin”*이라고 말하기만 하면 되도록 에이전트와 스킬을 추가해 봅시다.

스킬

skill은(는) 재사용 가능한 지침으로, 에이전트에 연결하는 지식입니다. 우리 스킬은 모델에게 그 도구를 어떻게 사용하는지 알려 줍니다.
import { defineSkill } from 'twenty-sdk/define';

export default defineSkill({
  universalIdentifier: DOCUMENT_SKILL_UNIVERSAL_IDENTIFIER,
  name: 'document-drafting',
  label: 'Document drafting',
  icon: 'IconFileText',
  content: [
    'To generate a document, call the `generate-document` tool with:',
    '- `templateId`: the id of the document template to use.',
    '- `recordId`: the id of the Person or Company the document is for.',
    '',
    'If the user names a template or person instead of an id, find the record first,',
    'then pass its id. Make sure the template target matches the record type.',
  ].join('\n'),
});

에이전트

agent는 프롬프트와 모델을 연결합니다. 빌드 경고를 피하려면 responseFormat을 명시적으로 설정하세요.
import { defineAgent } from 'twenty-sdk/define';

export default defineAgent({
  universalIdentifier: DOCUMENT_AGENT_UNIVERSAL_IDENTIFIER,
  name: 'document-assistant',
  label: 'Document Assistant',
  description: 'Generates documents from your templates and CRM records.',
  icon: 'IconFileText',
  responseFormat: { type: 'text' },
  prompt: [
    'You are the Document Assistant for a CRM.',
    'You help users generate personalized documents from reusable templates',
    'and the data already in their CRM. Use the generate-document tool, and',
    'always confirm what you created.',
  ].join(' '),
});
에이전트는 자신의 역할이 허용할 때만 그 도구를 호출할 수 있습니다. 우리는 이미 2장에서 앱의 역할에 canAccessAllTools: truecanBeAssignedToAgents: true를 설정했습니다.

사용해 보기

Document Assistant와 채팅을 열고, CRM에 있는 사람을 위한 문서를 작성해 달라고 요청하세요. 에이전트는 레코드를 찾고 generate-document를 호출한 다음, 생성한 문서를 다시 알려 줍니다. 이 문서는 이제 Documents 보기에도 표시되며, 명령 메뉴와 워크플로 경로를 사용할 때와 정확히 동일하게 동작합니다. 로직을 도구로 노출하면 이런 이점이 있습니다: 하나의 함수, 여러 개의 진입점 — 명령 메뉴, HTTP, 워크플로 단계, 그리고 이제는 자연어. 이 단계를 마치면: 앱은 기능이 완전해지고 실제로 유용해집니다. 이제 배포할 시간입니다.

다음: 게시 →

마켓플레이스 메타데이터를 추가하고 게시하세요.