start a chat from my chatbot if I enter there number or username - dialogflow-es

I want to start a chat from my chatbot if I enter their number on the bot. For example if I say, "start chat for 9111*****3", it should start a chat on their number on Whatsapp.

Related

Multiple react elements with socket io rooms

I have a chat app I am playing around to learn more about sockets, its has the following structure:
[Home page = Contains MULTIPLE chat previews - last message info and user name]
[Chat page = The rest of the messages]
Each Chat and Chat Preview is its own separate socket room, but whenever I fire an event in one of them it's received on all of the previews (idk about each room as only one room can be mounted at the same time, but multiple chat previews can).
(eg 1) I have Chat A, Chat B and Chat C
(eg 1.1) A user types in chat A, all chat previews receive the event.
(eg 1.2) A message is sent to Chat A, all chat previews receive the event
I don't know if it is a problem with multiple React components being mounted at the same time or something else.
This is how I sub to all events on React (this is on multiple components rendered at the same time)
And this is how I receive/emit events on the server

How can I get clients to send messages from whatsup to the cell phone number they used to register on my website with nodeJS and twilio?

how can I get with the twilio whatsap api that clients can send messages to the user who registers on my website.
For example, if the user registered with the number 12345, the clients can send messages to the number 12345 of the cell phone.
Then if another user registers with the number 456789, their clients can send messages to the cell phone number 456789 and so on.
At the moment I am thinking of using twilio, but if you can recommend another api that works with nodejs I would appreciate it
i am working with nodejs
thanks

How can I track unread messages in a messenger app

I am building a chat app using Node.js, Express, React and Socket.io. I want to keep track of unread messages so I can notify the user with unread messages count. Should this be implemented on both server and client sides?
Check this to see some of the tradeoff doing it either on client or server side.
Also it depends on how you are implementing it.
I'm currently doing something very similar and I chose to keep track of the last time the user checked the chatroom/ conversation and compare it to the created_at date of the messages. So the server sends off all the chatrooms and their last 50 messages to the client. I then calculate the number of unread messages directly in redux via a helper function and display it on the chatroom badge.

User not in a room receive messages from users in a room - Socket.io - Emitter

I am using the socket.io emitter and the socket.io redis component.
This is my code on the server which occurs when the user wants to start chat with others in a room :
emitter.to(roomId).emit('someonejoined', data);
socket.join(roomId);
The problem is that if the person doesnt click on the button "start chat" on a particular room but successfully connected to the server, he/she can get the messages being sent by the people on that chat room.
How can I fix this ?

integrate a chat in a web-app powered by Node.js

I am developing a Web-app with Angular (client-side) and Node (server-side). I'd like to integrate some social features, including a chat. So a user can discover near users and send them a message.
I want to know the best way to implement this. I have an idea, but it seems to me very raw, and I am afraid that it could overload the server.
my idea is to send each minute from the client, a request to the
server about new messages
the server looks for new messages among
all the conversations of that user, checking the last-message's
time for each conversation
the server sends back the conversations
with new messages
if the client receives conversations with new messages, a
notification appears, so the user can open the chat.
once the chat is opened, the request to the server for
new messages is sent each 3 seconds (instead of 1 minute)
Example of conversations of a user, stored in MongoDB
{'conversations':
[
{'to':{'user-id':'101010', 'name':'Michela', 'location':'Alba Adriatica',
'img':'http://graph.facebook.com...jpg'
},
'last-msg':12345, //epoch
'msgs':[
{'from-me':'ciao come stai?', 'date':''},
{'from-you':'bene grazie, tu?', 'date':''},
{'from-me':'eh insomma..mi so rott lu cazz', 'date':''},
{'from-you':'dai poi vai alle Hawaii', 'date':''}
]
},
...
]
}
You realy should learn about websockets and how they can provide 'push and pull' of information.
the approach your suggesting called 'long polling'. And yes, if the time between is not very long, the server will be under heavy load if the number of clients increases.
Using websockets you can let the server communicatie only with the clients that actually need the information.
Do a google search for "node.js chat application tutorial". It is not that difficult.

Resources