Rocketchat.closechat avatar
2 years ago
1.4 kB
  /* You must provid the Botpress App Webhook from Rocketchat */
  const rocketWebhook = 'https://localhost:3000/api/apps/public/6a8e6b6c-7a25-47c9-94e8-5af5075981ad/incoming'

  const axios = require('axios')

   * @title Close a chat session
   * @category Channel Rocket.Chat
   * @author LigeroSmart
  const callApi = async () => {
    // Prepare the message
    const message = {
      type: 'text',
      text: 'Chat encerrado. Fora do horário de expediente.',
      // Markdown enables rich content, for example links or bold text. Otherwise, content will be displayed as-is
      markdown: true

    // Send the message to the user (note the array, since you can send multiple payloads in the same reply)
    await, [message])
    const RoomIdAndVisitorToken =':')

    // Transfer user
    const { data } = await, {
      sessionId: RoomIdAndVisitorToken[0],
      action: 'close-chat'

    // The first element returned is the most recent release
    //const mostRecentRelease = data[0]

    //const latestVersion =

    // You could also save the complete response in the session, then use it later
    //session.response = data

  // Actions are async, so make sure to return a promise
  return callApi()