![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
gupshup-whatsapp-api
Advanced tools
An unofficial library to help with the usage of GupShup WhatsApp APIs(v2) for messages and user opt-ins
This is an unofficial library to leverage Gupshup Whatsapp API (v2) to be able to send Outbound messages of types (text, templates, video, audio, location, contact card, stickers, images) and fetch/send the opt-in requests to the users and the opted-in users list.
Note: It dooes not connect with the Inbound APIs (that are responsible for receiving messages from customers through webhooks)
npm i gupshup-whatsapp-api
or
yarn add gupshup-whatsapp-api
You will be needed to create gupshup instance with provided apiKey
. You can obtain the api key from Whatsapp Dashboard (https://www.gupshup.io/whatsapp/dashboard) for your specific app or if you are testing with the sandbox application.
const Gupshup = require('gupshup-whatsapp-api')
let client = new Gupshup({
apiKey: 'YOUR_API_KEY'
});
Property | Type | Description | Required |
---|---|---|---|
channel | string | The channel name, i.e.whatsapp | true |
destination | string | Customer's Whatsapp number | true |
source | string | Your Whatsapp business number | true |
message | Message Payload | Payload for the sending message | true |
src.name | string | Your whatsapp application name | false (required for sandbox apps) |
Property | Type | Description | Required |
---|---|---|---|
isHSM | string | true (for template message) and false (for session message) | false |
type | string | Whatsapp message type( text , audio , video , file , image , location , contact , sticker ) | true |
text | string | The text message to be sent to the customer, in case of type=text | false |
url | string | The public URL where the file / audio / video attachment to be sent to the customer is hosted | false |
originalUrl | string | The public URL where the image to be sent to the customer is hosted. Only to be sent for type = image | false |
previewUrl | string | The public URL where a thumbnail of the image to be sent to the customer is hosted. Only to be sent for type = image | false |
caption | string | Add caption to media messages, applicable to media `type = image | video |
longitude | number | To be sent for type = location | false |
latitude | number | To be sent for type = location | false |
name | string | Name of the location. Only to be sent for type = location | false |
address | string | Postal address of the location. Only to be sent for type = location | false |
contact | Contact Card | Contact details to be sent when type = contact | false |
Property | Type | Description | Required |
---|---|---|---|
addresses | [Contact Address] | Contact address for the person | false |
birthday | string | Person's date of birth | true |
emails | [Contact Email] | Person's email or emails | true |
name | Contact Name | Person's first, last and formatted name | true |
org | Contact Organization | Person's organization details | true |
phones | [Contact Phone] | Person's contact phone numbers | true |
url | [Contact URL] | Person's contact URLs | true |
Property | Type | Description | Required |
---|---|---|---|
city | string | Eg: "Menlo Park" | true |
country | string | Eg: "United States" | true |
countryCode | string | Eg: "us" | true |
state | string | Eg: "CA" | true |
street | string | Eg: "1 Hacker Way" | true |
type | string | Eg: "HOME" | true |
zip | string | Eg: "94025" | true |
Property | Type | Description | Required |
---|---|---|---|
email | string | Eg: "test@fb.com" | true |
type | string | Eg: "WORK" | true |
Property | Type | Description | Required |
---|---|---|---|
firstName | string | Eg: "John" | true |
formattedName | string | Eg: "John Smith" | true |
lastName | string | Eg: "Smith" | true |
Property | Type | Description | Required |
---|---|---|---|
company | string | Eg: "WhatsApp" | true |
department | string | Eg: "Design" | true |
title | string | Eg: "Manager" | true |
Property | Type | Description | Required |
---|---|---|---|
phone | string | Eg: "+1 (650) 555-1234" | true |
type | string | Eg: "WORK" | true |
wa_id | string | Eg: "16505551234" | false |
Property | Type | Description | Required |
---|---|---|---|
url | string | Eg: "https://www.facebook.com" | true |
type | string | Eg: "WORK" | true |
1. Send Text Message
client.message.send({
channel : "whatsapp",
source : "917834811114",
destination : "919876543210",
'src.name': "GupshupAppTest",
message : {
isHSM: "false",
type: "text",
text: "hi there"
}
}).then((response) => {
console.log("Text message sent", response)
}).catch(err => {
console.log("Text message err:", err)
})
2. Send Template Message
client.message.send({
channel : "whatsapp",
source : "917834811114",
destination : "919876543210",
'src.name': "GupshupAppTest",
message : {
isHSM: "true",
type: "text",
text: "Hi Ashwamegh, your order is confirmed and will be delivered to you by 15 Feb"
}
}).then((response) => {
console.log("Template text message sent", response)
}).catch(err => {
console.log("Template text message err:", err)
})
3. Send Image as a Message
client.message.send({
channel : "whatsapp",
source : "917834811114",
destination : "919876543210",
'src.name': "GupshupAppTest",
message : {
type: "image",
originalUrl: "https://www.buildquickbots.com/whatsapp/media/sample/jpg/sample01.jpg",
previewUrl: "https://www.buildquickbots.com/whatsapp/media/sample/jpg/sample01.jpg",
caption:"Sample image"
}
}).then((response) => {
console.log("Image message sent", response)
}).catch(err => {
console.log("Image message err:", err)
})
4. Send Document/File as a Message
client.message.send({
channel : "whatsapp",
source : "917834811114",
destination : "919876543210",
'src.name': "GupshupAppTest",
message : {
type: "file",
url: "https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf",
filename: "Sample file"
}
}).then((response) => {
console.log("Document message sent", response)
}).catch(err => {
console.log("Document message err:", err)
})
5. Send Audio as a Message
client.message.send({
channel : "whatsapp",
source : "917834811114",
destination : "919876543210",
'src.name': "GupshupAppTest",
message : {
type: "audio",
url: "https://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_700KB.mp3"
}
}).then((response) => {
console.log("Audio message sent", response)
}).catch(err => {
console.log("Audio message err:", err)
})
6. Send Video as a Message
client.message.send({
channel : "whatsapp",
source : "917834811114",
destination : "919876543210",
'src.name': "GupshupAppTest",
message : {
type: "video",
url:"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4",
caption:"Sample video"
}
}).then((response) => {
console.log("Video message sent", response)
}).catch(err => {
console.log("Video message err:", err)
})
6. Send Location as a Message
client.message.send({
channel : "whatsapp",
source : "917834811114",
destination : "919876543210",
'src.name': "GupshupAppTest",
message : {
type: "location",
longitude: 43.43,
latitude: 33.34,
name: "Name of the location",
address: "Postal address"
}
}).then((response) => {
console.log("Location message sent", response)
}).catch(err => {
console.log("Location message err:", err)
})
7. Send Contact Card as a Message
client.message.send({
channel : "whatsapp",
source : "917834811114",
destination : "919876543210",
'src.name': "GupshupAppTest",
message : {
type: "contact",
contact: {
addresses: [
{
city: "Menlo Park",
country: "United States",
countryCode: "us",
state: "CA",
street: "1 Hacker Way",
type: "HOME",
zip: "94025"
},
{
city: "Menlo Park",
country: "United States",
countryCode: "us",
state: "CA",
street: "200 Jefferson Dr",
type: "WORK",
zip: "94025"
}
],
birthday: "2012-08-18",
emails: [
{
email: "test@fb.com",
type: "WORK"
},
{
email: "test@whatsapp.com",
type: "WORK"
}],
name: {
firstName: "John",
formattedName: "John Smith",
lastName: "Smith"
},
org: {
company: "WhatsApp",
department: "Design",
title: "Manager"
},
phones: [
{
phone: "+1 (940) 555-1234",
type: "HOME"
},
{
phone: "+1 (650) 555-1234",
type: "WORK",
wa_id: "16505551234"
}
],
urls: [
{
url: "https://www.facebook.com",
type: "WORK"
}
]
}
}
}).then((response) => {
console.log("Contact Card sent", response)
}).catch(err => {
console.log("Contact Card err:", err)
})
8. Send Sticker as a Message
client.message.send({
channel : "whatsapp",
source : "917834811114",
destination : "919876543210",
'src.name': "GupshupAppTest",
message : {
type: 'sticker',
url:"https://cdn.getstickerpack.com/storage/uploads/sticker-pack/tunes-traffic/7.png"
}
}).then((response) => {
console.log("Location message sent", response)
}).catch(err => {
console.log("Location message err:", err)
})
{ "status":"submitted",
"messageId":"ee4a68a0-1203-4c85-8dc3-49d0b3226a35"
}
1. Get Opt-in users list
client.optins.getUsers('GupshupAppTest')
.then((response) => {
console.log("Optins User list: ", response)
}).catch(err => {
console.log("Optins User list error: ", err)
})
{
"status": "success",
"users": [
{
"countryCode": "91",
"lastMessageTimeStamp": 1585593959851,
"optinSource": "URL",
"optinStatus": "OPT_IN",
"optinTimeStamp": 1585504095053,
"phoneCode": "8x98xx21x4"
}
]
}
2. Send User Opt-in Request
client.optins.sendUserOptinRequest({
appName: 'GupshupAppTest',
userMobileNumber: 919876543210
})
.then((response) => {
console.log("Optin request sent: ", response)
}).catch(err => {
console.log("Optin request error: ", err)
})
{
"status": 202
}
yarn install
yarn test
FAQs
An unofficial library to help with the usage of GupShup WhatsApp APIs(v2) for messages and user opt-ins
The npm package gupshup-whatsapp-api receives a total of 0 weekly downloads. As such, gupshup-whatsapp-api popularity was classified as not popular.
We found that gupshup-whatsapp-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.