What users see#
In any chat, + › Services lists the apps that declare shareableObjectTypes or chatActions. Picking your app shows:
- your search actions as chips (they run your search),
- your open actions, and
- «Open service».
The user can then do one of two things.
- Search and send. SALOPHA calls
POST /v1/share/search; the hub asks your serverPOST <webhookUrl>/objects/search(signed) and shows the previews. Sending one creates a share: the hub asksPOST <webhookUrl>/objects/resolvefor the real card, never trusting the page, and posts it in the chat. An empty query asks for suggestions (popular, nearby, recent). - Open for the chat. Your app opens at the action's
path.getLaunchContext()returns{ source: "chat", actionId, chat: { kind, title }, canSendToChat: true }. The conversation id is never given to your page. Show «Send to chat» buttons;sendToChat()asks the user to confirm (card preview plus an optional message), posts the card and the message into that chat and returns to it.
Partner apps answer the same search for SALOPHA's global search and for the «from the app» lists on business profiles.
Declare them in the manifest#
"scopes": ["share.object"],
"shareableObjectTypes": ["store", "item"],
"chatActions": [
{ "id": "find_food", "kind": "search", "title": { "ar": "ابحث عن وجبة أو مطعم", "en": "Find food or a restaurant" }, "icon": "food", "objectTypes": ["item", "store"] },
{ "id": "browse", "kind": "open", "title": { "ar": "تصفح المطاعم", "en": "Browse restaurants" }, "icon": "store", "path": "/" }
]
- At most 6 actions. Ids match
^[a-z][a-z0-9_]{1,30}$and are unique; titles are at most 40 characters. kind: "search"runs your search, limited toobjectTypes(or allshareableObjectTypes).kind: "open"opens your app atpath.share.objectmust be among your scopes. Official apps can add it toautoGrantScopesto skip its consent sheet.- Icons:
search cart order bag add new calendar booking receipt orders store restaurant food flight travel location gift tag offer car. - Chat actions need SALOPHA 0.1.6 or later (bridge protocol 1.2). Older apps simply don't offer them.
Answer search and resolve on your server#
The server SDK verifies the platform's signature and routes by path:
api.post("/api/v1/platform/objects/*", express.raw({ type: "*/*" }), async (req, res) => {
const r = await platform.handlePlatformCall({ method: req.method, path: req.originalUrl, headers: req.headers, rawBody: req.body }, {
// { query, actionId?, objectTypes, viewer: { pairwiseUserId, actorType }, locale, limit }
search: async (q) => (await catalog.search(q.query, q.objectTypes, q.limit)).map((p) => ({
objectType: "item", objectId: p.id, title: p.name, subtitle: p.storeName,
imageUrl: p.image, // https only
price: { minor: p.price, currency: "IQD" },
})),
// { ref: { objectType, objectId }, viewer, purpose } -> the card, or null when it no longer exists
resolve: async (q) => cardFor(q.ref.objectType, q.ref.objectId),
});
res.status(r.status).json(r.body);
});
A search hit (ObjectSearchItem): objectType, objectId, title, and optionally subtitle, imageUrl, price, priceLabel, badges, isAvailable, rating.
A card (ObjectSnapshot):
{
title: "Family masgouf",
subtitle: "Al-Rabee Restaurant",
image: { source: "network", value: "https://shop.example.com/img/42.jpg" },
price: { minor: 25000, currency: "IQD" },
isAvailable: true,
actions: [{ id: "open", label: { ar: "فتح", en: "Open" }, kind: "deepLink", deepLink: "/item/42", isPrimary: true }],
}
Return null from resolve when the object is gone; the card then shows as unavailable. Unsigned calls get 401, calls for another app 403, unknown paths 404.
| Call | Timeout |
|---|---|
objects/search | 4 seconds |
objects/resolve | 3 seconds |
Users are waiting, so there are no retries. Answer fast.
Rules for cards#
- Other members of the chat see the card. Return public catalog data only: no customer names, phones, addresses or bookings.
deepLinkis a path inside your app; tapping the card opens your app there (asentryDeepLink).- Images must be absolute
httpsURLs. - Titles at most 120 characters, subtitles at most 160, at most 4 badges.
Send to chat from your page#
const launch = await app.getLaunchContext();
if (launch.source === "chat") showBanner(`Choosing for ${launch.chat?.title}`);
const r = await app.sendToChat({ objectType: "item", objectId: "42", text: "What about this one?" });
// From a chat: { sent: true, closing: true } and SALOPHA returns to that chat.
// From anywhere else: the usual chat picker.
Make «Send to chat» prominent, with the chat's title, when source === "chat". The card is re-resolved from your server; whatever the page passes as title, subtitle or imageUrl is only a preview.
Test it#
- In a browser:
devSimulator: { launch: { source: "chat", actionId: "find_food", chat: { kind: "direct", title: "Ali" } } }plays a chat launch. - End to end: from a chat, search and send a card; then open an action, press «Send to chat» and check you are back in the chat with the card.