Send Whatsapp message via Gupshup

Before proceeding to this, we would recommend you to check how to create connector campaigns. You can use connectors to send WhatsApp message for approved templates via Gupshup. In this example we will explain how to send WhatsApp Message using Gupshup WhatsApp API.

This article explains how you can:

First of all, ensure that you have:

  1. UserId and Password for that Gupshup Account. These are the credentials to login into your Gupshup account. If you are not able to find these, reach out to your contact in Gupshup.
  2. Have approved template messages that you want to send out to your users

Before you start sending business-initiated messages to your users, WhatsApp has mandated that you must first collect the user’s explicit consent. Please go through the opt-in guidelines here

Create WhatsApp Campaign

Sending notifications on WhatsApp requires adherence to opt-in policies and message template approval process instituted by WhatsApp. You will be able to send messages only to those users who are marked Opt-In. Here is a step by step guideline on this.

To create a WhatsApp campaign, move to Create Campaign and go to SMS & Connectors. Click on Create Connector campaign.

Screen_Shot_2019-11-28_at_1.06.35_PM.png

Step 1: 

Add a suitable name for your campaign (e.g. the message to inform user of the 1st transaction they have done)

 Choose the Sending Type as per your use case. Say you want to send the message based on certain trigger condition, then choose sending type as At trigger event. 

Screen_Shot_2019-11-28_at_1.08.52_PM.png

Choose the target audience once you have decided the sending type. You can target all the users or users who fulfill certain user criteria/behavior criteria.

Step 2:

Configure Webhook URL

Use GET Method to send the API request.

Webhook URL : Just copy this in Webhook URL Field :

https://media.smsgupshup.com/GatewayAPI/rest?method=SendMessage&format=text&userid=userid&password=password&send_to=91%7B%7BUserAttribute%5B'Mobile%20Number'%5D%7D%7D&v=1.1&auth_scheme=plain&msg_type=HSM&msg=Dear%20%7B%7BUserAttribute%5B'First%20Name'%5D%7D%7D,%20recharge%20of%20Rs.1000%20is%20successful%20in%20your%20ABC%20wallet.%20Happy%20shipping!&data_encoding=text

Once copied, URL params will be populated automatically. You should be able to see something like this:

mceclip6.png

Change value for these keys: 

  • Userid and Password - Set as per your account credentials
  • send_to - you can personalize [using @] it to select user's mobile number. Ensure that selected attribute consists of user's mobile number with country code - 91. 

    mceclip2.png

 If you are saving the Mobile Number without country code, prefix country code (e.g. 91 for India) to your selected attribute
          mceclip3.png

  • msg - The text message to be sent to the customer. It must be URL encoded. You can personalise your messages [using @], if say you want to address each user by their first name. 
  • msg_type - It is recommended to send msg_type="HSM" when sending Notifications on WhatsApp.
  • data_encoding - The default value is “text”. If your message is in another language or contains special characters / emoji, set data_encoding = "Unicode_text". If value is “text”, then maximum message length supported is 1024 characters. If value is “Unicode_text”, then maximum message length supported is 500 characters.

Note: Before sending WhatsApp campaign to your users, please ensure that 2 or more active/installed users are not mapped to same Mobile Number. If they are, those users will receive multiple WhatsApp messages. You should add Mobile Number as De-dup key in Step 3 to avoid that.

Screen_Shot_2017-05-22_at_7.05.33_PM.png

Once you are done with campaign, you will be take to campaign analytics page. Analytics will be generated with-in an hour from the time your campaign starts sending. 

Read more about campaign analytics.

Opt-in Users

Once you have obtained the opt-in from a user, you have to call the Gupshup Messaging API using the OPT_IN API method to mark the user as ‘Opt-In’.

This is only a one-time step, until the user remains opted-in. But, if the user opts-out and opt-in again, you will need to pass this information again to Gupshup. 

Here's how you can do it:

Go to Create Campaign and go to SMS & Connectors. Click on Create Connector campaign.

Screen_Shot_2019-11-28_at_1.06.35_PM.png

Step 1: 

Add a suitable name for your campaign (e.g. WhatsApp OptIn)

 Choose the Sending Type as per your use case. Say you take the consent from user on your app/website by ticking a checkbox and want to mark a user as Opt-In immediately so that they can start receiving WhatsApp messages immediately, choose sending type as At trigger event. Make sure you are passing the tick checkbox event to MoEngage. 

mceclip0.png

Choose the target audience once you have decided the sending type. You can target all the users or users who fulfill certain user criteria/behavior criteria.

Step 2:

Configure Webhook URL

Use GET Method to send the API request.

Webhook URL : Just copy this in Webhook URL Field :

https://media.smsgupshup.com/GatewayAPI/rest?method=OPT_IN&format=json&userid=userid&password=password&phone_number=919898989898&v=1.1&auth_scheme=plain&channel=WHATSAPP

Once copied, URL params will be populated automatically. You should be able to see something like this:

mceclip1.png

Change value for these keys: 

  • Userid and Password - Set as per your account credentials
  • phone_number - you can personalize [using @] it to select user's mobile number. Ensure that selected attribute consists of user's mobile number with country code - 91. 

    mceclip2.png

 If you are saving the Mobile Number without country code, prefix country code (e.g. 91 for India) to your selected attribute
          mceclip3.png

Note: Before sending WhatsApp campaign to your users, please ensure that 2 or more active/installed users are not mapped to same Mobile Number. If they are, those users will receive multiple WhatsApp messages. You should add Mobile Number as De-dup key in Step 3 to avoid that.

Screen_Shot_2017-05-22_at_7.05.33_PM.png

Once you are done with campaign, you will be take to campaign analytics page which will tell you that for how many users opt-in request was successful. Analytics will be generated with-in an hour from the time your campaign starts sending. Read more about campaign analytics.

Please use this method responsibly and do not make an Opt-in API call unless the user has legitimately and explicitly provided their consent to your business to send notifications on WhatsApp. Please make sure to read the Opt-in Guidelines mentioned below.

Opt-in Requirements

A user must first consent to receive messages in WhatsApp by opting into them via a third-party channel. This can be any channel your business uses to communicate with its users — your website, mobile app, missed call, IVR, email, SMS, retail location, contact centre, etc.

  • The opt-in must be an explicit i.e. triggered by a user action, such as entering a phone number or ticking a checkbox to indicate consent.
  • Clear opt-in messaging so that a user knows what types of messaging the person is signing up for.
  • Opt-ins must be maintained by the business, and should be produced in the event that WhatsApp requests for this information.
  • A customer initiating a conversation on WhatsApp cannot be considered as an opt-in, as it does not fulfil the requirement of being a third-party channel.

Opt-out Users

WhatsApp recommends that the you provide opted-in users with an option to opt-out from receiving further notifications on WhatsApp. One recommended method is to inform users about a STOP keyword on WhatsApp to opt-out.

To mark a user as Opt-out: 

Go to Create Campaign and go to SMS & Connectors. Click on Create Connector campaign.

Screen_Shot_2019-11-28_at_1.06.35_PM.png

Step 1: 

Add a suitable name for your campaign (e.g. WhatsApp OptOut)

 Choose the Sending Type as per your use case. Say you want to periodically mark the users as Opted out and want to update this information every week, then choose sending type as Periodic. Set the start type, recurrence frequency and an end time

mceclip7.png

Choose the target audience once you have decided the sending type. You can target all the users or users who fulfill certain user criteria/behavior criteria.

Step 2:

Configure Webhook URL

Use GET Method to send the API request.

Webhook URL : Just copy this in Webhook URL Field :

https://media.smsgupshup.com/GatewayAPI/rest?method=OPT_OUT&format=text&userid=userid&password=password&phone_number=91%7B%7BUserAttribute%5B'Mobile%20Number'%5D%7D%7D&v=1.1&auth_scheme=plain&channel=WHATSAPP

Once copied, URL params will be populated automatically. You should be able to see something like this:

mceclip8.png

Change value for these keys: 

  • Userid and Password - Set as per your account credentials
  • phone_number - you can personalize [using @] it to select user's mobile number. Ensure that selected attribute consists of user's mobile number with country code - 91. 

    mceclip2.png

 If you are saving the Mobile Number without country code, prefix country code (e.g. 91 for India) to your selected attribute
          mceclip3.png

Note: Before sending WhatsApp campaign to your users, please ensure that 2 or more active/installed users are not mapped to same Mobile Number. If they are, those users will receive multiple WhatsApp messages. You should add Mobile Number as De-dup key in Step 3 to avoid that.

Screen_Shot_2017-05-22_at_7.05.33_PM.png

Once you are done with campaign, you will be take to campaign analytics page which will tell you that for how many users opt-in request was successful. Analytics will be generated with-in an hour from the time your campaign starts sending. Read more about campaign analytics.

In absence of Opt-Out option, users might feel intruded and block the Business phone number or report it as Spam. This will affect your quality rating and might result in quality rating based rate limits being applied. In worst case scenario, the Business account might get suspended if the quality rating does not improve over time.

Was this article helpful?
0 out of 1 found this helpful