/**
* We have apps. (scroll down to see them)
* We have chat widgets for your websites (check it out on the bottom right).
* We have APIs.
* And we have AWESOME TypeScript packages for our APIs published on npm :)
*/
import * as sioApi from '@social.io/api';
const mySioAccount = sioApi.SioAccount.createFromApiKey('123xyz');
// yes, it is just rxjs ;)
mySioAccount.conversationsObservable.subscribe(conversation => {
// lets do something with a new conversation
// e.g. you don't want the conversation to pop up in the agent dashboard.
conversation.preventDefault();
// subscribe to messages :)
const messageSubscription = conversation.messageObservable.subscribe(message => {
if (
message.text.contains('hello')
&& conversation.originDomain === 'mycompany.com'
) {
// you can inject your own bot logic here
// let your imagination run free :)
message.reply('hello there, too!', {
delay: 300,
fromName: 'My Awesome Bot or Agent Name',
fromImageUrl: 'https://mycompany.com/team/peter/profile.jpg'
})
// you can then hand over to an agent on the web
messageSubscription.unsubscribe();
conversation.handOffToAgentDashboard();
}
})
})