Pinnacle whatsapp plugin
Pinnacle Whatsapp plugin official library is useful for sending Outbound messages of all types (text, images, stickers, location pins, contact cards, audio, video, and templates). It can also be used for sending and fetching opt-in requests to the users, as well as the opted-in users list.
Note: API does not support Inbound APIs such as receiving messages from end clients though webhooks.
Installation
npm install pinnacle_whatsapp_plugin
For API Key You will have to create an account with Pinnacle Teleservices PVT LTD. (https://console.pinbot.ai/) Once you create an account with Pinnacle you can obtain the api key from the email with all the credentials . The same can be used for your specific app or if you are testing with the sandbox application.
const pinnacle= require('pinnacle_whatsapp_plugin');
const apikey = "<Your API Key>";
Session Messages
1. Send Text Message
{
"from": "<Your Waba Number>",
"to": "<Contact Number>",
"type": "text",
"message": {
"text": "<Msg>"
}
}
2. Send Image Message
{
"from": "<wabanumber>",
"to": "<contact number>",
"type": "image",
"message": {
"url": "<image url>",
"caption": "<caption>",
"filename": "<filename>"
}
}
3. For Video Messages
{
"from": "<wabanumber>",
"to": "<contact number>",
"type": "video",
"message": {
"url": "<video url>",
"caption": "<caption>",
"filename": "<filename>"
}
}
4. For Interactive List Messages
{
"from": "<wabanumber>",
"to": "<contact number>",
"type": "interactive",
"message": {
"interactive": {
"type": "list",
"header": {
"type": "text",
"text": "Test Header"
},
"body": {
"text": "msgtext"
},
"footer": {
"text": "Test Footer"
},
"action": {
"button": "Button1",
"sections": [
{
"title": "Section1",
"rows": [
{
"id": "1",
"title": "Row1",
"description": "Desc1"
}
]
},
{
"title": "Section2",
"rows": [
{
"id": "2",
"title": "Row2",
"description": "Desc2"
}
]
}
]
}
}
}
}
5. For Interactive Button Messages
{
"from": "<wabanumber>",
"to": "<contact number>",
"type": "interactive",
"message": {
"interactive": {
"type": "button",
"header": {
"type": "text",
"text": "this is header"
},
"body": {
"text": "this is body"
},
"footer": {
"text": "this is footer"
},
"action": {
"buttons": [
{
"type": "reply",
"reply": {
"id": "1",
"title": "Button 1"
}
},
{
"type": "reply",
"reply": {
"id": "2",
"title": "Button 2"
}
}
]
}
}
}
}
6. For Contact Card Messages
{
"from": "<wabanumber>",
"to": "<contact number>",
"type": "contact",
"message": {
"contacts": {
"name": {
"first_name": "<first_name>",
"last_name": "<last_name>"
},
"phones": [
{
"phone": "<phone>",
"type": "<type>"
},
{
"phone": "<phone>",
"type": "<type>"
}
]
}
}
}
7. For Current Location Messages.
{
"from": "<wabanumber>",
"to": "<contact number>",
"type": "location",
"message": {
"longitude": "<longitude>",
"latitude": "<latitude>",
"name": "<location name>",
"address": "<loaction address>"
}
}
7. For Sticker Messages.
{
"from": "<wabanumber>",
"to": "<contact number>",
"type": "sticker",
"message": {
"url": "<sticker URL>",
"caption": "Test Sticker",
"filename": "<filename>"
}
}
Common Function for calling the Plugin for Sending Message:
pinnacle.send_session_msg (apikey, Payload).then((repositories) => {
console.log(repositories)
});
Template Messages
Note: For Sending template messages we need to initiate the text message After that we can send Template messages such as text, Image, video and document
1. For Sending Template Text Messages
{
"from": "<wabanumber>",
"to": "<contact number>",
"type": "template",
"message": {
"templateid": "<template id>",
"placeholders": ["<placeholders>"]
}
}
2. For Sending Template Image Messages
{
"from": "<wabanumber>",
"to": "<contact number>",
"type": "template",
"message": {
"templateid": "<template id>",
"url": "<image url>",
"placeholders": ["<placeholders>"]
}
}
3. For Sending Template Video Messages
{
"from": "<wabanumber>",
"to": "<contact number>",
"type": "template",
"message": {
"templateid": "<template id>",
"url": "<video url>",
"placeholders": ["<placeholders>"]
}
}
4. For Sending Template Document Messages
{
"from": "<wabanumber>",
"to": "<contact number>",
"type": "template",
"message": {
"templateid": "<template id>",
"url": "<document url>",
"placeholders": ["<placeholders>"]
}
}
Common Function for calling the Plugin for Sending Message:
pinnacle.send_template_msg (apikey, Payload).then((repositories) => {
console.log(repositories)
});
The following Response Message will be received
{
"code": "200",
"status": "SUCCESS",
"message": "Message Processed Successfully",
"data": {
"messageid": "<messageid>"
}
}
Request Body
Property | Type | Description | Required |
---|
From | string | Customer's Whatsapp number | true |
To | string | Your Whatsapp business number | true |
message | Message Payload | Payload for the sending message | true |
Type | string | Text | true |
Message Payload
Property | Type | Description | Required |
---|
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 |
Type | string | Text | true |
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 |
Pinnacle Support
Call +91 83088 00004, +91 83088 00005 or email at support@pinnacle.in