[Feature Request]: WhatsApp Typing Indicator
Problem
Preflight Checklist - [x] I have read the Contributing Guidelines for this project. - [x] I agree to follow the Code of Conduct that this project adheres to. - [x] I have searched the issue tracker for a feature request that matches the one I want to file, without success. - [x] This is not a general Twilio feature request or bug report. It is a feature request for the twilio-node JavaScript package. Problem Description Hello Twilio Team, We're writing to request support for typing indicators on the WhatsApp channel. This is a critical feature for our user experience, and we’ve noticed that WhatsApp has supported this natively in their Cloud API since 2023 (Meta Docs). We understand that typing indicators are available in the Conversations SDK, but this doesn't seem to apply to WhatsApp, leaving a significant gap for us. The absence of this feature is becoming a blocker for our product roadmap and is a major factor in our long-term platform decisions. Could you share if supporting WhatsApp typing indicators is on your roadmap? Any timeline you can provide would be crucial as we evaluate our future with Twilio. Thanks for your attention to this. Proposed Solution Meta Docs Alternatives Considered Migrate to other providers Additional Information _No response_
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Implement WhatsApp Typing Indicator Support in Twilio Node Package
The Twilio Node.js package currently does not support the WhatsApp typing indicator feature, which has been available in WhatsApp's Cloud API since 2023. This gap prevents developers from providing a seamless user experience that includes real-time typing notifications, which are critical for engagement on the platform.
Awaiting Verification
Be the first to verify this fix
- 1
Update Twilio Node.js Package
Modify the Twilio Node.js package to include methods for sending typing indicators to WhatsApp users. This involves creating a new function that utilizes the WhatsApp Cloud API's typing indicator endpoint.
javascriptconst sendTypingIndicator = async (to) => { const response = await twilioClient.messages.create({ to: to, from: 'whatsapp:+14155238886', // Your Twilio WhatsApp number body: '', // Empty body for typing indicator statusCallback: 'https://your-callback-url.com' }); return response; }; - 2
Add Typing Indicator Endpoint
Implement an endpoint in the Twilio Node.js package that allows developers to trigger the typing indicator. This should be a RESTful endpoint that accepts the recipient's phone number and sends the typing indicator.
javascriptapp.post('/sendTypingIndicator', async (req, res) => { const { to } = req.body; await sendTypingIndicator(to); res.status(200).send('Typing indicator sent'); }); - 3
Update Documentation
Ensure that the Twilio Node.js package documentation is updated to include instructions on how to use the new typing indicator feature. This should include examples and any necessary configurations.
markdown// Documentation should include usage examples and API details // Example: // sendTypingIndicator('+1234567890'); - 4
Testing the Implementation
Create unit tests to verify that the typing indicator functionality works as expected. This will involve mocking the Twilio API responses and ensuring that the correct requests are made.
javascriptconst assert = require('assert'); const nock = require('nock'); nock('https://api.twilio.com') .post('/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXX/Messages.json') .reply(200, { sid: 'SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' }); // Test case (async () => { const response = await sendTypingIndicator('+1234567890'); assert.strictEqual(response.sid, 'SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'); })();
Validation
To confirm the fix worked, send a typing indicator using the new endpoint and verify that the recipient sees the typing notification in their WhatsApp application. Additionally, check the Twilio logs for successful message delivery.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep