Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
// Sandbox fixture: registers a search provider whose handler returns canned SearchResults derived from
// the query, so the integration test can assert the full search RPC round-trip
// (host dispatch -> worker handler -> search-result). The handler echoes the query term into the hit.
module.exports = class SearchPlugin {
async onEnable(ctx) {
ctx.registerSearchProvider(async (query) => {
const term = String(query.q || '');
return {
hits: term
? [
{
messageId: 'm1',
waMessageId: 'wamid1',
sessionId: 's1',
chatId: '[email protected]',
body: `match for ${term}`,
snippet: `<mark>${term}</mark>`,
timestamp: 1700000000,
type: 'text',
direction: 'outgoing',
from: '[email protected]',
},
]
: [],
total: term ? 1 : 0,
tookMs: 2,
provider: 'plugin:search-fixture',
};
});
}
};