User's Timezone

Problem

You want to know the user’s timezone.

Solution

Use a markup interaction map node to get location from the browser and use timezonedb baas to convert lat lng to timezone. Provide alternative dropdown buttons path as means of error handling and if user declines location permission.

Example

user-timezone.png

[{"id":"114c726b.47f4be","type":"dialogue","z":"9e999abd.870ae8","name":"Print region","message":"payload.user.region","messageType":"msg","displayTimer":1.5,"enableDisplay":false,"x":940,"y":1060,"wires":[["5fa7f8ba.9d0708"]]},{"id":"cc05ec84.fa619","type":"change","z":"9e999abd.870ae8","name":"America/New_York","rules":[{"p":"payload.user.region","tot":"str","to":"America/New_York","t":"set","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":940,"wires":[["114c726b.47f4be"]]},{"id":"8db6caa7.18abe8","type":"change","z":"9e999abd.870ae8","name":"America/Chicago","rules":[{"p":"payload.user.region","tot":"str","to":"America/Chicago","t":"set","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":980,"wires":[["114c726b.47f4be"]]},{"id":"2b3ca4a.f1b2a5c","type":"change","z":"9e999abd.870ae8","name":"America/Los_Angeles","rules":[{"p":"payload.user.region","tot":"str","to":"America/Los_Angeles","t":"set","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":1020,"wires":[["114c726b.47f4be"]]},{"id":"fc9879ce.9ec6f8","type":"change","z":"9e999abd.870ae8","name":"Europe/Paris","rules":[{"p":"payload.user.region","tot":"str","to":"Europe/Paris","t":"set","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":1060,"wires":[["114c726b.47f4be"]]},{"id":"6566c2b6.66bb1c","type":"change","z":"9e999abd.870ae8","name":"Europe/Dublin","rules":[{"p":"payload.user.region","tot":"str","to":"Europe/Dublin","t":"set","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1100,"wires":[["114c726b.47f4be"]]},{"id":"be73f3b6.abf38","type":"markup","z":"9e999abd.870ae8","name":"","markup":"<TimelineMessage>\n  <Dropdown value=\"1\" description=\"Select your Region please.\">\n    <DropdownItem id=\"1\" title=\"US East\" />\n    <DropdownItem id=\"2\" title=\"US Central\" />\n    <DropdownItem id=\"3\" title=\"US West\" />\n    <DropdownItem id=\"4\" title=\"Central Europe\" />\n    <DropdownItem id=\"5\" title=\"UK Ireland\" />\n  </Dropdown>\n</TimelineMessage>","markupType":"str","syntax":"markdown","x":140,"y":1040,"wires":[["a04c7b43.ba13b8"]]},{"id":"a04c7b43.ba13b8","type":"input","z":"9e999abd.870ae8","name":"","x":270,"y":1040,"wires":[["c4867bb5.af7268"]]},{"id":"c4867bb5.af7268","type":"switch","z":"9e999abd.870ae8","name":"","property":"payload.user.message","propertyType":"msg","rules":[{"t":"eq","v":"US East","vt":"str"},{"t":"eq","v":"US Central","vt":"str"},{"t":"eq","v":"US West","vt":"str"},{"t":"eq","v":"Central Europe","vt":"str"},{"t":"eq","v":"UK Ireland","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":6,"x":410,"y":1040,"wires":[["cc05ec84.fa619"],["8db6caa7.18abe8"],["2b3ca4a.f1b2a5c"],["fc9879ce.9ec6f8"],["6566c2b6.66bb1c"],["28170a59.8f9816"]]},{"id":"28170a59.8f9816","type":"dialogue","z":"9e999abd.870ae8","name":"invalid","message":"Invalid Region, please select from the provided list.","messageType":"str","displayTimer":1.5,"enableDisplay":false,"x":230,"y":1140,"wires":[["be73f3b6.abf38"]]},{"id":"15886b3c.0b7ac5","type":"markupInteraction","z":"9e999abd.870ae8","name":"Confirm location","markup":"<TimelineMessage>\n  <StaticMap\n    title=\"Please confirm your location\"\n    interactionType=\"event\"\n  />\n</TimelineMessage>","syntax":"markdown","outputs":3,"x":200,"y":860,"wires":[["724e60c9.5646d"],["be73f3b6.abf38"],["be73f3b6.abf38"]]},{"id":"724e60c9.5646d","type":"baas","z":"9e999abd.870ae8","name":"Timezone","alias":"Timezone","contexts":[{"sourceType":"msg","target":"lat","source":"payload.markupInteraction.lat"},{"sourceType":"msg","target":"lng","source":"payload.markupInteraction.lng"}],"x":400,"y":850,"wires":[["d90aa618.d49148"],["be73f3b6.abf38"]]},{"id":"d90aa618.d49148","type":"change","z":"9e999abd.870ae8","name":"set zone name","rules":[{"p":"payload.user.region","tot":"msg","to":"baas.Timezone.response.zoneName","t":"set","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":850,"wires":[["114c726b.47f4be"]]}]

To try it out simply copy the above json and import it in the flow designer.
Key shortcut Ctrl/⌘-i, Menu option Import

Discussion

Get timezonedb.com account and API key

https://timezonedb.com/ Ask Botbuilders team if they can provide this for you.

Set up timezone baas

  "Description": "timezonedb.com",
  "RequestMapping": {
    "lng": {
      "type": "requestURL",
      "requestParameter": "lng",
      "inputPath": "$.lng"
    },
    "lat": {
      "type": "requestURL",
      "requestParameter": "lat",
      "inputPath": "$.lat"
    }
  },
  "ResponseMapping": {},
  "Body": {},

  "Method": "GET",
  "Endpoint": "http://api.timezonedb.com/v2.1/get-time-zone?key={API_KEY}&format=json&by=position&lat=${lat}&lng=${lng}",
  "Alias": "Timezone",