Twilio Chat typing() is not working

i’m successfully integrate the twilio chat api on javascript, however i got problem on .typing() function, it seems the typing function is not triggering the

‘typingStarted’ and ‘typingEnded’, can i have some advice?

here is my code

  var chatChannel;
  var chatClient;
  var username;

  $.post("/tokens", function(data) {
    username = data.username;
    chatClient = new Twilio.Chat.Client(data.token);
    chatClient.getSubscribedChannels().then(createOrJoinGeneralChannel);
  });

  function createOrJoinGeneralChannel() {
    // Get the general chat channel, which is where all the messages are
    // sent in this simple application
    // print('Attempting to join "general" chat channel...');
    var promise = chatClient.getChannelByUniqueName("#{params[:chat_channel]}");
    promise.then(function(channel) {
        chatChannel = channel;
        console.log("#{params[:chat_channel]} is exist");
        console.log(chatChannel);
        setupChannel();
    }).catch(function() {
        // If it doesn't exist, let's create it
        console.log("creating #{params[:chat_channel]} channel");
        chatClient.createChannel({
            uniqueName: "#{params[:chat_channel]}",
            friendlyName: 'General Chat Channel'
        }).then(function(channel) {
            console.log("Created #{params[:chat_channel]} channel:");
            console.log(channel);
            chatChannel = channel;
            setupChannel();
        });
    });
  }

  function setupChannel() {
    chatChannel.join().then(function(channel) {
      printMessage(username + ' joined the chat.');
      chatChannel.on('typingStarted', showTypingStarted);
      chatChannel.on('typingEnded', hideTypingStarted);
    });
    chatChannel.on('messageAdded', function(message) {
      printMessage(message.author + ": " + message.body);
    });
  }

  function showTypingStarted(member) {
    console.log('somebody is typing');
    $('#is_typing').html(member.identity + ' is typing...')
  }

  function hideTypingStarted(member) {
    $('#is_typing').html('');
  }

  var $input = $('#chat-input');
  $input.on('keydown', function(e) {
    if (e.keyCode == 13) {
      chatChannel.sendMessage($input.val());
      $input.val('');
    } else {
      //console.log('typing');
      chatChannel.typing();
    }
  });


Source: stackoverflow-javascript

Send SMS via Twilio npm package – Error cannot find – Error: Cannot find module ‘./webhooks’

I am trying to send a simple SMS via Twilios npm package, I have tried some of the current packages out there with no avail. So I thought I would go the good old fashioned npm route. That also seems to fail at the following server error message:

W20170306-13:50:46.118(-8)? (STDERR) Error: Cannot find module ‘./webhooks’
W20170306-13:50:46.118(-8)? (STDERR) at require (packages/modules-runtime.js:123:19)
W20170306-13:50:46.119(-8)? (STDERR) at meteorInstall.node_modules.twilio.lib.index.js (packages/modules.js:342:16)
W20170306-13:50:46.119(-8)? (STDERR) at fileEvaluate (packages/modules-runtime.js:197:9)
W20170306-13:50:46.119(-8)? (STDERR) at require (packages/modules-runtime.js:120:16)
W20170306-13:50:46.120(-8)? (STDERR) at meteorInstall.server.server.js (server/server.js:3:14)
W20170306-13:50:46.120(-8)? (STDERR) at fileEvaluate (packages/modules-runtime.js:197:9)
W20170306-13:50:46.120(-8)? (STDERR) at require (packages/modules-runtime.js:120:16)
W20170306-13:50:46.121(-8)? (STDERR) at /Users/nicholas/Desktop/meteor/esoLounge/.meteor/local/build/programs/server/app/app.js:15:1
W20170306-13:50:46.123(-8)? (STDERR) at /Users/nicholas/Desktop/meteor/esoLounge/.meteor/local/build/programs/server/boot.js:303:34
W20170306-13:50:46.124(-8)? (STDERR) at Array.forEach (native)

This is my server code:

let accountSid = 'ACxxxxxxxxxxxxxxxxxxxxa',
    authToken = 'a91xxxxxxxxxxxxxxxxxxxxxxxxxa',
    twilio = require("../node_modules/twilio/lib"),
    client = new twilio.RestClient(accountSid, authToken);

client.messages.create({
    body: 'Hello from Node',
    to: '+15555555551', 
    from: '+15555555551'
}, function(err, message) {
    console.log(message.sid);
});

I am also open to working solutions outside of Twilio, if there is any. Thanks!


Source: stackoverflow-javascript