Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open chat #41

Open
alpires opened this issue May 23, 2018 · 5 comments
Open

Open chat #41

alpires opened this issue May 23, 2018 · 5 comments

Comments

@alpires
Copy link

alpires commented May 23, 2018

Hi Guys, exist some way to open a contact chat with this api?

@yotam180
Copy link
Owner

What do you mean by opening a contact chat? Visually open it on the screen? Or just start the conversation with them?

@alpires
Copy link
Author

alpires commented May 23, 2018

Hi @yotam180 I need visually open it on the screen.

@yotam180
Copy link
Owner

Haven't found a way yet. If I find one I'll let you know here.

@idoenk
Copy link

idoenk commented Jun 20, 2019

While there's no proper way to do this via api, yet;
It can be done by make a link element with specific href value, then simply attach it to body;
trigger click to it; built-in event to open chat should be triggered;

eg. Contact number = 123456789

<a href="http://wa.me/123456789" class="fakelink-openchat">123456789</a>
let el = document.createElement('a');
el.setAttribute('href', 'http://wa.me/123456789');
el.setAttribute('class', 'fakelink-openchat');
el.innerHTML = '123456789';
document.body.appendChild(el);

el.click();

you can add an event click to observe/setTimeout/setInterval to check whether chat target is active, hence chat is opened;

setTimeout(function(){
 let ca = Store.Chat.active();
 if (ca && ca.id && ca.id.user == '123456789'){
  // Chat is opened; should we remove element? 
  // $('.fakelink-openchat').remove()
  // do something more..
 }
}, 2 * 1000);

@yotam180
Copy link
Owner

Surely that's cool. Would you like to open a PR for that? If not, I can do that too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants