CrewAI crew එකට Instagram, TikTok සහ WhatsApp tools දෙන්න
CrewAI crew එකකට Instagram, TikTok, WhatsApp සහ තවත් නාලිකා tools ලෙස ලැබෙන්නේ, එක් එක් agent එකේ mcps ලැයිස්තුවේ https://easycoexistence.com/api/mcp සඳහා MCPServerHTTP එකක් ද, එහි Authorization header එකේ easyCoexistence OAuth access token එකක් ද ඇති විටය. CrewAI හි MCP client පුරනය වීමක් ධාවනය නොකර headers යවන බැවින්, crew එක සෑම kickoff එකකදීම token එක refresh කරයි, සහ custom tool එකකට key එකක් සමග posts API වෙත ළඟා විය හැකිය.
MCPServerHTTP හි විකල්ප HTTP headers ශබ්දකෝෂය, CrewAI ලේඛනවල Authorization bearer token එකක් රැගෙන යන බව පෙන්වයි.
crewai.mcp.filters වෙතින් ආයාත කළ, MCP server එකක tools සඳහා CrewAI හි allow සහ block ලැයිස්තු.
CrewAI හි MCP සම්බන්ධතාවයක් සඳහා පෙරනිමි රැඳී සිටීමේ කාලය; ළඟා විය නොහැකි server එකක් අනතුරු ඇඟවීමක් ලෙස ලොග් වන අතර agent එක සෙසු tools රඳවා තබා ගනී.
easyCoexistence MCP access token එකක් කොපමණ කාලයක් පවතින්නේද; දින 60ක් වලංගු refresh token එකක් නව යුගලයක් ලබා දෙයි.
easyCoexistence posts API එක පළ කිරීමක් කොපමණ ඉදිරියට කාලසටහන් කළ හැකිද, මිනිත්තු 1 සිට, පෝලිමට දමන විට media පිටපත් කරමින්.
CrewAI agent එකක් easyCoexistence tools පූරණය කරන්නේ කෙසේද?
mcps field එක හරහා, එක් එක් agent එකට එක MCPServerHTTP එකක් සමග. එය මෙම class එක සඳහා CrewAI හි පෙරනිමි වන Streamable HTTP හරහා සම්බන්ධ වෙන අතර, ඔබ දෙන headers, එනම් easyCoexistence access token එකක් රඳවා ගන්නා Authorization header එක, යවයි. create_static_tool_filter සමග සාදන static tool filter එකක් මගින් එක් එක් agent එකට එහි කාර්යයට අවශ්ය tools පමණක් ලැබෙන අතර, cache_tools_list මගින් පළමු සම්බන්ධතාවයෙන් පසු ලැයිස්තුව තබා ගනී. CrewAI ඉල්ලීම මත සම්බන්ධ වන අතර server එකකට ළඟා විය නොහැකි නම්, අනතුරු ඇඟවීමක් ලොග් කර agent එකට සෙසු tools සමග දිගටම ක්රියා කිරීමට ඉඩ දෙයි, එබැවින් පළමු ධාවනයේදී log එක කියවන්න. Access token එක ඊළඟ කොටසේ helper එකෙන් ලැබේ.
from crewai import Agent, Crew, Task
from crewai.mcp import MCPServerHTTP
from crewai.mcp.filters import create_static_tool_filter
from easycoexistence_token import fresh_token
TOKEN = fresh_token() # one per kickoff: an access token lasts an hour
def easycoexistence(*tools: str) -> MCPServerHTTP:
return MCPServerHTTP(
url="https://easycoexistence.com/api/mcp",
headers={"Authorization": f"Bearer {TOKEN}"},
streamable=True,
cache_tools_list=True,
tool_filter=create_static_tool_filter(allowed_tool_names=list(tools)),
)
analyst = Agent(
role="Social analyst",
goal="Find which of last week's Instagram and TikTok posts reached the most people",
backstory="You read the numbers before anyone writes a caption.",
mcps=[easycoexistence("list_social_accounts", "list_social_posts", "get_social_insights")],
)
scheduler = Agent(
role="Scheduler",
goal="Queue next week's posts at the times the analyst recommends",
backstory="You post only what the brief approves, always with scheduled_at.",
mcps=[easycoexistence("list_social_accounts", "publish_instagram_post",
"publish_tiktok_post", "list_scheduled_posts")],
)
crew = Crew(
agents=[analyst, scheduler],
tasks=[
Task(description="Rank last week's posts by reach and views.",
expected_output="A ranked list with the best posting times", agent=analyst),
Task(description="Schedule the three posts in {brief} for next week.",
expected_output="The post_id of each queued post", agent=scheduler),
],
)
crew.kickoff(inputs={"brief": "<THE WEEK'S BRIEF>"})crew එකේ access token එක කොතැනින් ලැබේද?
එක් browser sign-in එකකින්, ඉන්පසු සෑම kickoff එකකදීම refresh එකකින්. easyCoexistence හි MCP server එක OAuth tokens පමණක් පිළිගනී: dynamic client registration, PKCE සහිත authorization code එකක්, පැයක් පවතින access tokens සහ දින 60ක් පවතින refresh tokens. browser එකක් ඇති යන්ත්රයක MCP Python SDK හි OAuthClientProvider එක එක් වරක් ධාවනය කර එය ලබා දෙන registration සහ tokens සුරකින්න; පහත helper එක SDK හි 1.x රේඛාව භාවිත කරන අතර එය CrewAI ස්ථාපනය කරයි. සෑම kickoff එකකට පෙර fresh_token මගින් සුරැකි refresh token එක easyCoexistence හි token endpoint එක වෙත හුවමාරු කර නව යුගලයක් ගබඩා කරයි, එබැවින් දින 60 තුළ අවම වශයෙන් එක් වරක් ධාවනය වන crew එකකට browser එක නැවත අවශ්ය නොවේ. සුරැකි ගොනුව repository එකේ නොව secret store එකක තබන්න.
import asyncio, json, webbrowser
from pathlib import Path
from urllib.parse import parse_qs, urlparse
import httpx
import requests
from pydantic import AnyUrl
from mcp import ClientSession
from mcp.client.auth import OAuthClientProvider
from mcp.client.streamable_http import streamable_http_client
from mcp.shared.auth import OAuthClientMetadata
URL = "https://easycoexistence.com/api/mcp"
SAVED = Path("easycoexistence-oauth.json") # a secret store in production
class SaveToFile: # the MCP SDK's TokenStorage, writing what the sign-in returns
def __init__(self):
self.saved = {}
async def get_tokens(self): return None
async def get_client_info(self): return None
async def set_tokens(self, tokens): self._put("tokens", tokens)
async def set_client_info(self, info): self._put("client", info)
def _put(self, key, model):
self.saved[key] = model.model_dump(mode="json")
SAVED.write_text(json.dumps(self.saved))
async def open_browser(url: str) -> None:
webbrowser.open(url)
async def code_from_redirect() -> tuple[str, str | None]:
q = parse_qs(urlparse(input("Address after sign-in: ")).query)
return q["code"][0], q.get("state", [None])[0]
async def sign_in_once() -> None:
oauth = OAuthClientProvider(
server_url=URL,
client_metadata=OAuthClientMetadata(
client_name="Acme crew", redirect_uris=[AnyUrl("http://localhost:3030/callback")], scope="mcp"),
storage=SaveToFile(), redirect_handler=open_browser, callback_handler=code_from_redirect,
)
async with httpx.AsyncClient(auth=oauth) as http:
async with streamable_http_client(URL, http_client=http) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize() # completes the sign-in and saves the tokens
def fresh_token() -> str:
"""Trade the saved refresh token for a new pair and return the access token."""
saved = json.loads(SAVED.read_text())
r = requests.post("https://easycoexistence.com/api/oauth/token", data={
"grant_type": "refresh_token",
"refresh_token": saved["tokens"]["refresh_token"],
"client_id": saved["client"]["client_id"],
}, timeout=30)
r.raise_for_status()
saved["tokens"] = r.json() # a new refresh token comes with each refresh
SAVED.write_text(json.dumps(saved))
return saved["tokens"]["access_token"]
if __name__ == "__main__":
asyncio.run(sign_in_once())MCP server එක නොමැතිව crew එකකට කෙසේ පළ කළ හැකිද?
scheduler එකක් මගින් ආරම්භ වන, කිසිවෙක් නොමැති crew එකකට ගැලපෙන custom tool එකක් හරහා, එය easyCoexistence හි posts API එක ඇමතීමෙනි. dashboard එකේ Partner API key එකක් සාදන්න, එය ec_live_ වලින් ආරම්භ වේ, පහත tool එක POST /api/v1/channels/:id/posts වෙත text, media link, type සහ publish_at යවයි. පෝලිමට දමන විට easyCoexistence media පිටපත් කරයි, එම මොහොතේ වෙබ් පිටුවක් හෝ වැරදි format එකක් ලබා දෙන link එකක් ප්රතික්ෂේප කරයි, සහ පළ කිරීම එහි වේලාවට පළ කරයි; Idempotency-Key header එක මගින් නැවත උත්සාහ කළ ඇමතුමක් එය දෙවරක් පෝලිමට දැමීම වළක්වයි. එම key එකම GET /api/v1/channels/:id?credentials=1 වෙතින් නව network tokens කියවයි.
import hashlib, os
import requests
from crewai.tools import tool
@tool("Schedule a social post")
def schedule_post(account_id: str, text: str, media_url: str, media_type: str, publish_at: str) -> str:
"""Queue one post on a connected Instagram, TikTok or Facebook account.
media_type is image or video; publish_at is ISO 8601 with a timezone, 1 minute to 90 days ahead."""
key = hashlib.sha256(f"{account_id}|{publish_at}|{media_url}".encode()).hexdigest()
r = requests.post(
f"https://easycoexistence.com/api/v1/channels/{account_id}/posts",
headers={"Authorization": f"Bearer {os.environ['EC_API_KEY']}", "Idempotency-Key": key},
json={"text": text, "media": [{"url": media_url, "type": media_type}], "publish_at": publish_at},
timeout=60,
)
return r.text # the queued post, or why it was refusedcrew එකේ කුමන agent එකට කුමන tools තිබිය යුතුද?
ඒ කාර්යය අවසන් කිරීමට ඉඩ දෙන අවම ගණන, මන්ද agent එකට ඇති ඕනෑම tool එකක් ඇමතිය හැකි බැවිනි. සතියක content සැලසුම් කර පළ කරන crew එකක් කියවීම, ලිවීම සහ පළ කිරීම විවිධ agents අතර බෙදයි, එබැවින් ඔවුන් අතරින් එකෙකුට පමණක් කිසිවක් සජීවී කළ හැකිය. ලේඛකයාට easyCoexistence tools කිසිවක් නොදෙන්න: එය analyst ගේ සොයාගැනීම් සහ brief එකෙන් වැඩ කරන අතර, එහි captions scheduler එක වෙත task output ලෙස ළඟා වේ. Publishing tools scheduled_at ගන්නා බැවින්, ධාවනය වූ මොහොතේම පළ කිරීම වෙනුවට scheduler එක posts ඒවායේ වේලාවන්ට පෝලිමට දමයි, සහ list_scheduled_posts මගින් ඒවා රැඳී සිටින දේ තහවුරු කළ හැකිය. LinkedIn පළ කිරීම් crews වලින් ඉවත් තබන්න: agent එකක් එක් එක් එකක් ඉල්ලීම මත draft කරයි, උදාහරණයක් ලෙස Claude හෝ ChatGPT හි, එය යවීමට පෙර පුද්ගලයෙකු අනුමත කරයි.
Networks crew එකේ පළ කිරීම් සහ පිළිතුරු වලින් ඉල්ලා සිටින්නේ කුමක්ද?
එක් එක් network API හි නීති, ඒවා agents ගේ goals සහ backstories තුළ තිබිය යුතුය:
- Media: එක් file එකකට public HTTPS link එකක්. Instagram JPEG images ගන්නා අතර, TikTok photo පළ කිරීම් JPEG හෝ WebP ගන්නා අතර, Facebook Page පළ කිරීමක් එක් photo එකක් හෝ එක් video එකක් ගනී.
- වේලාවන්: timezone සහිත ISO 8601, උදාහරණයක් ලෙස 2026-11-20T09:00:00-03:00, මිනිත්තු 1 සිට දින 90 දක්වා ඉදිරියට.
- අදහස්: TikTok පිළිතුරු public වන අතර
post_idලෙස video එකේ ID අවශ්යයි; Instagram හෝ Facebook අදහසකට දින 7ක් ඇතුළත එක් private reply එකක් ලැබිය හැකිය. - DM: Instagram සහ Messenger පිළිතුරු පුද්ගලයාගේ අවසන් පණිවිඩයෙන් පැය 24ක් ඇතුළත ලබා ගනී; WhatsApp හි
send_messageඑම කවුළුවට අනුකූල වන අතරsend_templateවෙනත් ඕනෑම අයෙකුට ළඟා වේ. - Events: අදහසක් හෝ DM එකක් crew එකට ළඟා වන්නේ
set_social_webhook_destinationසමග ඔබ සකසන ඔබේම මාර්ගය හරහා පමණි, එයට event එකක් සමග crew.kickoff ඇමතිය හැකිය.
සාමාන්ය වැරදි
- ඊයේ token එකකින් crew එකක් ආරම්භ කිරීම. easyCoexistence access token එකක් නිකුත් කළ පැයකට පසු කල් ඉකුත් වන අතර, CrewAI ළඟා විය නොහැකි server එකක් නොමැතිව දිගටම යන අතර ලොගයේ අනතුරු ඇඟවීමක් පමණක් තිබේ; සෑම kickoff එකකදීම fresh_token ඇමතීම.
- එක් agent එකකට සම්පූර්ණ server එක දීම. tool_filter නොමැතිව, analyst කෙනෙකුට publishing tools ද පෙනේ; එහි කාර්යයට අවශ්ය නම් සමග create_static_tool_filter පාස් කරන්න.
- publish_at හෝ scheduled_at offset එකක් නොමැතිව ලිවීම. easyCoexistence timezone නැති වේලාවක් ප්රතික්ෂේප කරයි, එබැවින් එය Z හෝ -03:00 වැනි offset එකකින් අවසන් කරන්න.
- සුරැකි sign-in ගොනුව commit කිරීම. එහි refresh token එක එය දරන ඕනෑම කෙනෙකුට දින 60 දක්වා ගිණුමේ tools ලබා දෙයි, එබැවින් එය secret store එකක තබන්න.
easyCoexistence ඔබේ CrewAI agents වලට WhatsApp, Instagram, Facebook, TikTok, YouTube, LinkedIn සහ තවත් නාලිකා මත ගනුදෙනුකරුවන් වෙත ළඟා වීමේ හැකියාව ලබා දෙයි, සෑම එකක්ම ඒවායේ නිල API හරහා: එක් එක් agent එකේ mcps ලැයිස්තුවට 35+ MCP tools, දින 90 ඉදිරියට පෝලිමට දමන posts API එකක්, සහ අදහස් සහ DM සඳහා අත්සන් කළ events, සෑම සම්බන්ධතාවයක්ම 24/7 නිරීක්ෂණය කරයි. සම්බන්ධතාවයකට මාසිකව US$ 9 සිට US$ 0.75 දක්වා, සම්බන්ධතා එකතු කරන විට අඩු වේ, පළමු දින 3ක නොමිලේ trial කාලය ඇත.
නිතර අසන ප්රශ්න
CrewAI හි MCP client එක OAuth sign-in එක තමාම ධාවනය කරනවාද?
එහි ලේඛනය authentication සඳහා headers, environment variables සහ query parameters පෙන්වන අතර OAuth flow එකක් නොමැත. එබැවින් crew එක දැනටමත් දරන bearer token එකක් යවයි, එය MCP Python SDK සමග එක් පුරනය වීමකින් ලැබේ.
crew එකට තමන්ගේ කාලසටහනට අනුව අදහස්වලට පිළිතුරු දිය හැකිද?
ඔව්. list_social_posts, list_social_comments සහ reply_to_comment සහිත community manager agent එකකට සෑම ධාවනයකදීම නව අදහස් හරහා වැඩ කළ හැකි වන අතර, YouTube සහ LinkedIn අදහස් කියවන්නේද එලෙසිනි, මන්ද දෙකම events ඉදිරිපත් නොකරන නිසා.
crew එකට WhatsApp පණිවිඩ යැවිය හැකිද?
ඔව්, agent එකේ tool filter එකේ list_numbers, send_message සහ send_template සමග. send_message පසුගිය පැය 24 තුළ ලිවූ ගනුදෙනුකරුවන්ට පිළිතුරු දෙන අතර, send_template අනුමත template එකක් ඕනෑම අයෙකුට යවයි.
CrewAI crew එකක් සඳහා easyCoexistence කොපමණ වියදම් කරන්නේද?
සම්බන්ධතාවයකට මාසිකව US$ 9 සිට US$ 0.75 දක්වා, සම්බන්ධතා එකතු කරන විට අඩු වේ, සහ සෑම network එකකම එකම ය. MCP server එක, posts API එක සහ යවන ලද events ඇතුළත් වන අතර, පළමු දින 3ක නොමිලේ trial කාලය ඇත.
තවදුරටත් කියවන්න
ඔබේ පළමු channel එක මිනිත්තු දෙකකින් සම්බන්ධ කරන්න.
වේදිකා සමාලෝචන සඳහා බලා සිටීමට අවශ්ය නැත. WhatsApp, Instagram, TikTok හෝ වෙනත් channel එකක් සම්බන්ධ කර, පසුව ඔබේ AI හට පළ කිරීමට, ප්රතිචාර දැක්වීමට හෝ වාර්තා කිරීමට පවසා එය වැඩ කරන ආකාරය බලන්න.
- දින 3ක් නොමිලේ
- ඕනෑම වේලාවක අවලංගු කරන්න
- නිල API පමණි
- 24/7 නිරීක්ෂණය කෙරේ
සත්යාපනය කළේ