Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
add function to detect if the request is coming from the Google Crawler
Browse files Browse the repository at this point in the history
  • Loading branch information
Volkmar Vogel committed Feb 25, 2019
1 parent 201bc07 commit 7ea42fa
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ class DialogflowHandler(private val webhookRequest: WebhookRequest) {
*/
fun getArgument(key: String) = arguments[key]

fun isGoogleCrawler() = webhookRequest.originalDetectIntentRequest?.payload?.user?.profile
.let {
it?.givenName == "Google" && it.familyName == "Crawler"
}

/**
* Checks if on the last request a permission was successfully granted.
*/
Expand Down Expand Up @@ -192,7 +197,7 @@ class DialogflowHandler(private val webhookRequest: WebhookRequest) {
operator fun set(contextName: String, parameter: String, value: Any) {
if (this[contextName] == null) {
this[contextName] =
OutputContext(contextName, lifespanCount = 4, parameters = mutableMapOf(parameter to value))
OutputContext(contextName, lifespanCount = 4, parameters = mutableMapOf(parameter to value))
} else {
this[contextName]?.parameters?.set(parameter, value)
}
Expand Down

0 comments on commit 7ea42fa

Please sign in to comment.