> ## Documentation Index
> Fetch the complete documentation index at: https://docs.twenty.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 5. An AI agent

> السماح لوكيل بتوليد مستندات من محادثة، باستخدام أداتك.

لأن `وثيقة توليد الطاقة` مكشوفة كـ **أداة**، يمكن لوكيل الذكاء الاصطناعي أن يطلق عليها.
دعونا نضيف وكيلا ومهارة حتى يمكن للمستخدمين أن يقولوا فقط *"إنشاء اقتراح لـ
Jeffery Griffin"*.

## المهارة

A [skill](/l/ar/developers/extend/apps/logic/skills-and-agents) قابل لإعادة الاستخدام- المعرفة التي تربطها بالوكلاء. علمنا النموذج كيفية استخدام
الأداة.

```ts filename="src/skills/document-drafting.skill.ts" theme={null}
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](/l/ar/developers/extend/apps/logic/skills-and-agents) يزوج موجه مع نموذج
. تعيين 'استمارة الاستجابة' بشكل صريح لتجنب تحذير البناء.

```ts filename="src/agents/document-assistant.agent.ts" theme={null}
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(' '),
});
```

<Note>
  ولا يمكن للوكيل الاتصال بالأداة إلا إذا كان دوره يسمح بذلك. لقد قمنا بالفعل بتعيين
  'cancessAllTools: true' و 'canBeAssignedToAgents: true' على دور التطبيق في
  [الفصل 2](/l/ar/developers/extend/apps/tutorials/document-generator/generating-documents#grant-it-access).
</Note>

## جرب ذلك

افتح محادثة مع **مساعد مستندات** واطلب منها إعداد وثيقة لشخص
في إدارة علاقات العملاء الخاصة بك. يجد السجل، يستدعي `generate-document`، ويُرجِع
المستند الذي أنشأه — الذي يظهر الآن في عرض **Documents** لديك،
تمامًا مثل مسارات قائمة الأوامر وسير العمل.

هذه هي ثمرة إتاحة المنطق كأداة: **دالة واحدة، وكثير من نقاط الدخول** —
قائمة الأوامر، وHTTP، وخطوة سير العمل، والآن اللغة الطبيعية.

**بعد هذه الخطوة:** التطبيق كامل الميزة ومفيد حقا. حان الوقت
لإطلاقه.

<Card title="التالي: النشر →" icon="rocket" href="/l/ar/developers/extend/apps/tutorials/document-generator/النشر">
  إضافة بيانات التعريف للسوق والنشر.
</Card>
