#openChatWindow

3 messages · Page 1 of 1 (latest)

ionic zodiac
#

Hello, can anyone help?) I tried a bunch of everything, nothing comes out 😦
I want to make a redirect to the group chat, by clicking on a button, with the openChatWindow function executed, but there is not a single live example, I don’t understand how it works (and works or is)

  if (msg.type == 'buttons_response') {
    // data from widget
    const widgetUser = {
      phone: msg._data?.quotedMsg?.footer,
      name: msg._data?.quotedMsg?.title,
    }
    const broker = msg._data?.id?.participant
    
    let isRegistredUser = await client.getNumberId(widgetUser.phone)
  
    if (isRegistredUser) {
      const groupParticipants = new Array(
        msg.to,
        broker,
        isRegistredUser._serialized
      )
      // нужно чекнуть есть ли с ним чат
      let chat = await getChatId(widgetUser.phone) // custom function (return chat id by chat name)
      // let code = await chat.getIviteCode()
      // console.log(code)
      // create group
      if (!chat) {
        let newChat = await client.createGroup(
          widgetUser.phone,
          groupParticipants
        )
        await client.interface.openChatWindow(newChat)
      }

      await client.interface.openChatWindow(chat)

    } else {
      console.log('User have not whatsapp :(')
    }
  }
})```
robust briar
#

......

#

client.interface controls the current user