Ask Location

Collect and validate location data in your WhatsApp chatbot flows using the Ask Location action with error handling and response storage.

The Ask Location action prompts users to send their current location via WhatsApp, utilizing the location-sharing feature. The action is essential for use cases such as deliveries, appointments, or any scenario that requires geographical data. You can configure error handling, validate responses, and store the location data in a bot variable for future use.

Step-by-Step Instructions

  1. Compose Your Message:

    • Enter the message that will prompt the user to share their location. The message can be up to 4096 characters.

    • You can format the message text to make it more user-friendly:

      • Bold: Select text and click the "B" button to enclose it in double asterisks (*).

      • Italic: Highlight the text and click the "I" button to enclose it in underscores (_).

      • Strikethrough: Select text and click the "s" button to enclose it in tildes (~).

    • Add emojis by clicking on the emoji icon to enhance the message.

  2. Adding Variables:

    • Insert variables into the message by clicking on the "Add Variables" button. This helps customize the message with dynamic content, such as the user’s name or other data. Tip: Ensure the variable has the correct data for seamless integration into the message.

  3. Error Handling:

    • Error Attempt: Specify the number of allowed attempts for the user to send a valid location. If the user sends anything other than a location (e.g., an image or text), this setting defines how many wrong inputs are permitted before triggering an error.

    • Error Message: Craft an error message to notify the user when they have provided an invalid response. For example, "Please share your location using the location button on WhatsApp."

  4. Action on Invalid Input:

    • End the Flow: If the user exceeds the allowed number of invalid attempts, the bot will stop the flow, and no further actions will be triggered.

    • Fall Back Flow: Define an alternative flow if the user fails to provide a valid location after several attempts. This helps recover from errors and continue user engagement.

    • Skip the Question: If the user cannot provide a valid location, the bot will skip this action and continue with the next one.

  5. Store Response in a Variable (Optional):

    • You can save the user’s location data by selecting a bot variable from the dropdown list. The location will be stored in this variable for future use in the flow. Example: Store the location in a variable like user_location.

Sample Output

  {
  "latitude": 10.7698289,
  "longitude": 79.638391
  }
  • Accessing Stored Location:

    • Latitude: {variable.user_location.latitude}

    • Longitude: {variable.user_location.longitude}

FAQs

  1. How does the user share their location?

    • The user needs to tap the "Send Location" button on WhatsApp to share their current location.

  2. What happens if the user doesn't send a valid location?

    • If the user sends an invalid response (e.g., an image or text), the bot will follow the error handling process, which may include retry attempts, fallback actions, or skipping the question.

Troubleshooting Tips

  • Invalid Inputs: Ensure the message instructs the user to use the correct WhatsApp feature for sharing locations to avoid confusion.

  • Too Many Invalid Attempts: Adjust the error attempt settings if users consistently fail to provide a valid location.

Last updated