您可以为此尝试 rasa REST API。确保您在 endpoints.yml 中有 action_endpoint url。通常是
url: "http://localhost:5055/webhook"
然后确保您的 rasa 机器人已启动,如果有任何自定义操作,请同时启动该服务器。
启动你的webhook后,你可以简单的调用
http://localhost:5005/webhooks/rest/webhook
在有效负载中,您必须将其放在有效负载下方
messagePayload = {
sender: 'default',
message: 'Your message is here'
}
最后添加 httpheader 内容类型为 application/json 如下所示
'Content-Type': 'application/json'
现在你的机器人可以正常工作了。
tldr;
如果您在 python 中使用 request 进行 api 调用,您可以尝试以下代码。
import requests
API_ENDPOINT = "http://localhost:5005/webhooks/rest/webhook"
messagePayload = {
sender: 'default',
message: 'Your message is here'
}
r = requests.post(url = API_ENDPOINT, data = messagePayload)