Slack
Occult API destekli bir slash komutuyla Slack'e astroloji özellikleri ekleyin.
Slack uygulaması
api.slack.com/apps adresinde bir Slack uygulaması oluşturun ve /horoscope gibi bir slash komutu ekleyin. Komut URL'sini backend endpoint'iniz olarak ayarlayın.
Endpoint
Slash komutunu sunucunuzdaki yola yönlendirin; örneğin https://your-domain.com/slack/horoscope.
Node.js işleyicisi
Occult API'yi çağırıp sonucu döndüren bir Express işleyicisi:
app.post('/slack/horoscope', async (req, res) => {
const text = req.body.text || 'aries';
const sign = text.trim().split(' ')[0];
const response = await fetch('https://api.occultapi.com/api/astro/rashifal/daily/', {
method: 'POST',
headers: { 'X-API-Key': process.env.OCCULT_API_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({ rashi: sign }),
});
const data = await response.json();
res.json({ response_type: 'in_channel', text: data.get_daily_rashifal.general_prediction });
});Kullanım
Aslan burcunun günlük yorumunu almak için herhangi bir Slack kanalına /horoscope leo yazın.