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

# Airtable

> أدر حسابات وسائل التواصل الاجتماعي الخاصة بمستخدميك من Airtable

## نظرة عامة

[Airtable](https://www.airtable.com) منصة سحابية متعددة الاستخدامات تمزج بسلاسة بين بنية جدول البيانات وقدرات قاعدة البيانات القوية.

بدمج سكربتات الأتمتة في Airtable — المكتوبة بلغة JavaScript — مع واجهة Ayrshare، يمكنك تبسيط إدارة وسائل التواصل الاجتماعي مباشرةً داخل Airtable. يتيح لك هذا التكامل نشر المحتوى، وتحليل مقاييس الأداء، وإدارة التعليقات بالنيابة عن مستخدميك، كل ذلك من مكان مركزي واحد.

في هذا الدليل، سنرشدك عبر خطوات إعداد التكامل.

## الإعداد

<Warning>
  يتطلّب تشغيل سكربتات أتمتة Airtable خطة [مدفوعة](https://airtable.com/pricing) في Airtable.
  يُرجى التأكد من أن خطتك في Airtable تشمل الأتمتة عبر السكربتات.
</Warning>

يوضّح لك هذا الدليل كيفية النشر تلقائيًا إلى حسابات التواصل الاجتماعي المرتبطة في Airtable عبر [Ayrshare](https://www.ayrshare.com).
يمكنك النشر إلى الحسابات الاجتماعية لشركة واحدة أو إلى حسابات عملائك الذين تديرهم. يمكن الوصول إلى كل الشيفرة أدناه عبر [GitHub](https://github.com/ayrshare/airtable-post-social-media/blob/main/script.js).

<Card horizontal icon="github" href="https://github.com/ayrshare/airtable-post-social-media/blob/main/script.js" title="GitHub: Airtable Post Social Media" />

## احصل على مفتاح API الخاص بك

ابدأ بالحصول على مفتاح API لخطتك المجانية أو المدفوعة من [لوحة تحكم Ayrshare](https://www.ayrshare.com). سيُستخدم المفتاح في السكربت أدناه.

إذا كنت مشتركًا في [خطة Launch](/multiple-users/business-launch-overview) أو [خطة Business](https://www.ayrshare.com/business-plan-for-multiple-users/) وترغب في النشر بالنيابة عن عملائك، اجمع كل Profile Keys الخاصة بعملائك إما عبر نقطتَي النهاية /user أو /create-profile، أو من لوحة تحكم Ayrshare.

<Tip>
  تأكّد من أنك قد ربطت بعض الحسابات الاجتماعية في Ayrshare. يُرجى التحقق من ذلك في [صفحة ربط
  حسابات Ayrshare](https://app.ayrshare.com/social-accounts).
</Tip>

## إنشاء مساحة عمل في Airtable

في [Airtable](https://www.airtable.com)، أنشئ مساحة عمل جديدة بالحقول التالية. يُرجى التأكد من تسمية أعمدة الخلايا كما هو موضح أدناه:

<ul class="custom-bullets">
  <li>`Post` بنوع Long Text</li>

  <li>
    `Platforms` بنوع Multi Select مع الأنواع: facebook، instagram، twitter، linkedin، reddit،
    وtelegram
  </li>

  <li>`Images` بنوع Attachment</li>
  <li>`Profile Keys` بنوع Single Line Text</li>
  <li>`Status` بنوع Single Line Text.</li>
  <li>`Schedule Date` بنوع Date مع Local Format، وIncludeTime Field، وTime Format 24 Hours</li>
</ul>

<img class="center" src="https://mintcdn.com/ayrshare-docs/6mPR4kmwNEz1kMbX/images/packages-guides/airtable-example.webp?fit=max&auto=format&n=6mPR4kmwNEz1kMbX&q=85&s=ac8b91e08f67f7c2432ddfbbf7e65aa0" alt="Airtable Table Example" width="1536" height="161" data-path="images/packages-guides/airtable-example.webp" />

ستُستخدم هذه الحقول في سكربت أتمتة Airtable الذي نحن بصدد بنائه.

اطّلع على [مثال حي في Airtable](https://airtable.com/shrCWY0oA1ghB42tI/tblpnTEiPwyuViqBo).

<Card horizontal icon="book-open" href="https://airtable.com/shrCWY0oA1ghB42tI/tblpnTEiPwyuViqBo" title="مثال Airtable لوسائل التواصل الاجتماعي">
  اطّلع على مثال حي في Airtable
</Card>

## إدخال بيانات اختبار للمنشور

نحتاج إلى بعض البيانات النموذجية لاختبار المنشور. إليك اقتراحًا:

<ul class="custom-bullets">
  <li>`Post`: أدخل *Happy New Year 2025* </li>

  <li>
    `Platforms`: اختر شبكة واحدة أو أكثر تكون قد ربطتها. يُرجى التأكد من أن الاسم بأحرف صغيرة.
  </li>

  <li>
    `Images`: أرفق صورة. نحن نقترح هذه التي يمكنك تنزيلها وإرفاقها:
    [https://img.ayrshare.com/012/gb.jpg](https://img.ayrshare.com/012/gb.jpg)
  </li>

  <li>
    `Profile Keys`: إذا كنت مشتركًا في خطة Business أو Launch وترغب في النشر إلى ملف تعريف عميل،
    أدخل Profile Key الخاص به. *وإلا اترك الحقل فارغًا.*
  </li>

  <li>
    `Status`: أدخل *pending*. لا يجلب السكربت إلا السجلات التي حالتها pending. يُرجى التأكد من
    كتابة `pending` بأحرف صغيرة.
  </li>

  <li>
    `Schedule Date`: اترك الحقل فارغًا لأننا سنختبر النشر الفوري الآن. لاحقًا يمكنك اختيار تاريخ
    مستقبلي لجدولة المنشور.
  </li>
</ul>

## بناء سكربت أتمتة عبر محرر السكربتات

سنبني الآن سكربت أتمتة Airtable الذي يقرأ بياناتك من الجدول، وينشئ منشورًا، ويرسله إلى شبكات التواصل الاجتماعي عبر Ayrshare. ستستخدم محرر سكربتات Airtable.

### إضافة مشغّل (Trigger)

* في مساحة العمل، اضغط على *Automation* ثم *+New automation.*

<img class="center" src="https://mintcdn.com/ayrshare-docs/6mPR4kmwNEz1kMbX/images/packages-guides/new%20automation.webp?fit=max&auto=format&n=6mPR4kmwNEz1kMbX&q=85&s=d2637323e3e540d6e46cf0d45e2f161a" alt="Go to the Automation section of Airtable" width="932" height="144" data-path="images/packages-guides/new automation.webp" />

<ul class="custom-bullets">
  <li>سمِّ الأتمتة.</li>
  <li>اضغط على *Choose a Trigger*.</li>
  <li>اختر When a Record is Created.</li>
  <li>اختر الجدول الذي يحتوي الحقول أعلاه.</li>
  <li>اضغط على Done.</li>
</ul>

## إضافة إجراء (Action)

<ul class="custom-bullets">
  <li>ابدأ بالنقر على *Add Action*.</li>
  <li>اختر *Run Script*. سيُنقلك ذلك إلى محرر السكربتات.</li>
</ul>

**احذف** السطر:

```javascript theme={"system"}
console.log(`Hello, ${base.name}!`);
```

و**انسخ والصق** في محرر السكربتات الشيفرة التالية:

```javascript theme={"system"}
const API_KEY = "Your API Key"; // Get a free key at app.ayrshare.com

console.log(`Starting Post ${base.name}!`);

const sendPost = async (data) => {
  const { post, platforms, imageUrls, profileKeys, scheduleDate, shortenLinks } = data;

  const body = Object.assign(
    {},
    post && { post },
    platforms && { platforms },
    profileKeys && { profileKeys: profileKeys.split(",") },
    Array.isArray(imageUrls) &&
      imageUrls.length > 0 && {
        mediaUrls: imageUrls.map((image) => image.url)
      },
    scheduleDate && { scheduleDate },
    shortenLinks !== undefined && shortenLinks !== null && { shortenLinks }
  );

  console.log("Posting JSON:", JSON.stringify(body, null, 2));

  if (profileKeys) {
    body.profileKeys = profileKeys.split(",");
  }

  const response = await fetch("https://api.ayrshare.com/api/post", {
    method: "POST",
    body: JSON.stringify(body),
    headers: {
      "Content-Type": "application/json",
      Authorization: `Bearer ${API_KEY}`
    }
  }).then((res) => res.json());

  return response;
};

const table = base.getTable("Posts");
const query = await table.selectRecordsAsync();
const filteredRecords = query.records.filter((record) => {
  const status = record.getCellValue("Status");
  return status === "pending";
});

for (let record of filteredRecords) {
  const post = record.getCellValue("Post");
  const images = record.getCellValue("Images");
  const platforms = record.getCellValue("Platforms");
  const profileKeys = record.getCellValue("Profile Keys");
  const scheduleDate = record.getCellValue("Schedule Date");

  const shortenLinks = false;
  const response = await sendPost({
    post,
    platforms: platforms.map((x) => x.name),
    imageUrls: images,
    profileKeys,
    scheduleDate,
    shortenLinks
  });

  console.log(response);

  if (response) {
    let status;
    if (Array.isArray(response)) {
      status = response.map((x) => x.status).every((x) => x === "success") ? "success" : "error";
    } else {
      status = response.status;
    }

    await table.updateRecordAsync(record, {
      Status: status
    });
  }
}
```

ستقرأ هذه الشيفرة من الجدول الخاص بك وتنشر إلى Ayrshare. لكن عليك أولًا إضافة مفتاح API الخاص بك (الذي جمعته سابقًا).

استبدل `Your API Key` بمفتاح API الحقيقي.

## اختبار السكربت

في محرر السكربتات، اضغط على *>Test*

سيُشغَّل السكربت ويعرض الاستجابة من مكالمة API. إذا نجح كل شيء، فسترى رسالة نجاح مُعادة، وحقل pending في سجلاتك يتغيّر إلى success، ومنشورك على الشبكة الاجتماعية المُختارة.

بمجرد إنشاء سجل جديد في الجدول، سيُشغَّل السكربت ويعالج السجلات المعلقة.

## وثائق Airtable

إذا رغبت في مزيد من المعلومات، اطّلع على [وثائق Airtable](https://www.airtable.com/developers).
تتضمن تفاصيل حول كيفية استخدام محرر سكربتات Airtable.

## فيديو تعليمي

هذا فيديو تعليمي رائع من فريق Automate All The Things. يستعرض هذا الفيديو كيفية دمج Ayrshare في مشروع Airtable حي.

<div class="video-container">
  <iframe width="560" height="315" src="https://www.youtube.com/embed/U_jo6f5hsyY" title="Post To Social Media From Airtable" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" />
</div>

يُرجى الاطلاع على المزيد من [أمثلة دمج Airtable مع وسائل التواصل الاجتماعي](https://www.ayrshare.com/blog/automatically-post-to-social-media-from-airtable/).

## أسئلة

إذا كان لديك أي سؤال أو تعليق، يُرجى التواصل معنا عبر [البريد الإلكتروني](mailto:contact@ayrshare.com) أو <a href="javascript:void(0)" onClick={() => window.Intercom && window.Intercom('show')}>تحدّث معنا في الدردشة</a>.
