How to Send Reminders to Conversations (Scheduled ...
# 📖tutorials
p
Want your bot to send proactive reminders like “Drink water!” or “Finish checkout”? Here's how to set up scheduled reminders using the Botpress API and a little code magic. 🛠️ What You’ll Need: 1. Fixed Schedule Trigger * This card kicks off the reminder workflow on a set interval (e.g., every hour or day). 2. Execute Code Card * This card contains the logic to send the message to all active conversations. 💻 Example Code to Use: Paste this in your Execute Code card and modify the values as needed:
Copy code
js
const botId = '<your-bot-id>' // Replace with your actual bot ID (found in the URL)
const botpressApiUrl = 'https://api.botpress.cloud/v1/chat/conversations'
const botpressApiKey = env.PERSONAL_ACCESS_TOKEN // Create the variable in bot settings under Configuration Variables
// Create the PAT in the dashboard

const response = await axios.get(botpressApiUrl, {
  headers: {
    Authorization: `Bearer ${botpressApiKey}`,
    'x-bot-id': botId
  }
})

// Optional: Log the list of conversations
console.log(response.data)

response.data.conversations.forEach((conversation) => {
  const conversationId = conversation.id
  client.createMessage({
    conversationId,
    userId: botId,
    tags: {},
    type: 'text',
    payload: {
      text: "Don't forget to drink water!", // Your reminder message
    },
  })
})
📌 Notes: * Secure your token: Always use env.PERSONAL_ACCESS_TOKEN, never hardcode it. * Customize your schedule: You can run the Fixed Schedule card every few minutes, hourly, or daily. * Conversation-aware logic: Want to only message certain users? Add filters inside the forEach loop. https://cdn.discordapp.com/attachments/1384263331694776531/1384263331938041906/Screenshot_2025-06-16_at_2.55.25_PM.png?ex=6851cb30&is=685079b0&hm=e1b67b6c137d93218245587deeb2b44cc342e28d8c31055b117f7823a52dd5bf&
w
great ! thanks @prehistoric-airplane-85682 !
g
Hi i to send reminder messages on telegram will this work for telegramif yes how?
p
You could make an api call to telegram within the execute code card but there might be authentication complications.
g
I made it work somehow 😄 with botpress AI and claude 🙂
everything is working fine thanks 🙂
p
Happy to hear!!
4 Views