Tasker and Telegram integration: live location
In this story, I’ll integrate the task to share your location shown in Tasker and Telegram integration sending a Live Location instead.
The fundamental thing to understand is that the bot cannot update the live location on its own. The task has to do it.
Telegram Bot API
You can find all the APIs used below on the Available Methods page.
The %par1 in the following tasks is the chat identifier. Read the article linked at the beginning to understand how to get it.
Method sendLocation
The call sendLocation has the optional parameter live_period that allows us to send a live location by specifying a positive number of seconds between 60 (1 minute) and 86400 (24 hours).
In the following screenshot, you can see the task to call this method.
It performs the following actions:
- Get Location v2: obtains my current location. You can read more details in the Get Location v2 user guide.
- HTTP Request: calls the API as shown in the screenshot on the right. %telegramToken is the token BotFather gave me, %par1 and %par2 are the parameters the task received.
- Return: gives the caller task a value. With %http_data[message_id] it returns the message identifier to later update and/or stop the live location.
Method editMessageLiveLocation
The call editMessageLiveLocation allows the bot to update the live location sent with the previous method. The parameters are quite the same except the message_id, which is the identifier of the live location message.
In the following screenshot, you can see the task to call this method.
It performs the following actions:
- Get Location v2: obtains my current location.
- HTTP Request: calls the API as shown in the screenshot on the right to update the live location message identified by %par2.
Method stopMessageLiveLocation
The call stopMessageLiveLocation ends the live location sent with the first method before the live_period ends. It requires the parameter message_id.
In the following screenshot, you can see the task to call this method.
It performs an HTTP Request that calls the API as shown in the screenshot on the right to end the live location message identified by %par2.
You can download all the tasks explained here.
Send Live Location Task
It is now possible to send a live location message, update it and eventually stop it.
The following task asks the user how often it should update the live location, for how many times, and shows a notification to update or stop it at any moment.
It performs the following actions:
- Input dialog: asks the user how often, in minutes, it should update the location.
- Variable Set: saves the user input in the %familyLocationInterval variable.
- Input dialog: asks the user how many times it should update the location.
- Variable Set: saves the user input in the %familyLocationTimes variable.
- Variable Set: calculate the live_period parameter like this: (%familyLocationInterval * (%familyLocationTimes + 1)) * 60. It adds one to the times to make sure that slow networks don’t interfere.
- Notify: sends a notification to let the user update and stop the location manually.
- Perform Task: sends a Telegram message to the group to notify them what it is doing.
- Variable Set: sets the %familyLocationIndex variable to 0.
- Perform Task: sends the live location to the group using the first method explained earlier. It saves the return value in the %familyLocationMessageId variable.
- If: checks that the message was sent and an id was returned.
- Wait: waits %familyLocationInterval minutes.
- Perform Task: updates the live location using the editMessageLiveLocation method.
- Variable Add: increments the %familyLocationIndex variable by 1.
- Goto: if the index is less than the times, it goes back to the Wait action at position 11.
The last action calls the following task.
It dismisses the notification, clears the variables, and uses the stopMessageLiveLocation method to stop the live location message.
Ten articles before and after
800 Minutes to Hours ▷ What is 800 Minutes in Hours and Minutes?
Google Sheets Formula & Telegram Message ✈️ – Telegram Group
KGF Chapter 2 Movie Telegram Link to Download Movie for Free – Telegram Channels -Telegram
Best telegram groups for May and June 2022 – Telegram GURU
Best Telegram Furry Groups to Join In 2022 – TelegramGuru
How to Write/Draw on a Shared Screen or Whiteboard in Zoom- Telegram Tutorial
17 Best Telegram Tamil Movie Channels 2022 (Latest Collection)
How to enable comments in Telegram channel – Telegram Group
3 Ways to Get Refund If You Get Fake Product From Amazon or Flipkart- Telegram Tutorial