<request>
Discription
The <request>
tag allows you to send a complete request object and can be used to pass any request parameters. Fields that do not match the BotRequest
format are not available in the script.
Body
JSON-BotRequest
object.
caution
Please note that the
query
parameter is required in the body of the tag <request>
.How to use
- Checking if the dialog has started in the Telegram channel.
Script:
state: Start
q!: $regex</start>
if: $request.channelType === "telegram"
a: Telegram.
else:
a: Chat widget.
Script test:
<test>
<test-case>
<request>{
"query": "/start",
"channelType": "telegram"
}</request>
<a>Telegram.</a>
</test-case>
</test>
- Checking the data from the request.
Script:
state: Request
q!: request
a: {{ $request.channelType }}, {{ $request.data.field }}
state: Unknown
q!: unknown
a: unknownField: {{ $request.unknownField }}
Script test:
...
<test-case id="1">
<request>{
"query": "request",
"channelType": "mockTest",
"data": {
"field": "data from the request"
}
}</request>
<a>mockTest, data from the request</a>
</test-case>
<test-case id="2">
<request>{
"query": "unknown",
"unknownField": "mockTest"
}</request>
<a>unknownField: </a>
</test-case>
...